mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-12-26 00:29:38 +01:00
Vfs: Fix Stylite/Links/StreamWrapper was not respecting backup parameter
This commit is contained in:
parent
466371fa03
commit
9231b32fce
@ -83,7 +83,10 @@ class Base
|
||||
*/
|
||||
static function mount($url = null, $path = null, $check_url = null, $persistent_mount = true, $clear_fstab = false)
|
||||
{
|
||||
if (is_null($check_url)) $check_url = strpos($url,'$') === false;
|
||||
if(is_null($check_url))
|
||||
{
|
||||
$check_url = strpos($url, '$') === false;
|
||||
}
|
||||
|
||||
if(!isset($GLOBALS['egw_info']['server']['vfs_fstab'])) // happens eg. in setup
|
||||
{
|
||||
@ -103,12 +106,18 @@ class Base
|
||||
}
|
||||
if(is_null($url) || is_null($path))
|
||||
{
|
||||
if (self::LOG_LEVEL > 1) error_log(__METHOD__.'('.array2string($url).','.array2string($path).') returns '.array2string(self::$fstab));
|
||||
if(self::LOG_LEVEL > 1)
|
||||
{
|
||||
error_log(__METHOD__ . '(' . array2string($url) . ',' . array2string($path) . ') returns ' . array2string(self::$fstab));
|
||||
}
|
||||
return self::$fstab;
|
||||
}
|
||||
if(!Vfs::$is_root)
|
||||
{
|
||||
if (self::LOG_LEVEL > 0) error_log(__METHOD__.'('.array2string($url).','.array2string($path).') permission denied, you are NOT root!');
|
||||
if(self::LOG_LEVEL > 0)
|
||||
{
|
||||
error_log(__METHOD__ . '(' . array2string($url) . ',' . array2string($path) . ') permission denied, you are NOT root!');
|
||||
}
|
||||
return false; // only root can mount
|
||||
}
|
||||
if($clear_fstab)
|
||||
@ -117,14 +126,20 @@ class Base
|
||||
}
|
||||
if(isset(self::$fstab[$path]) && self::$fstab[$path] === $url)
|
||||
{
|
||||
if (self::LOG_LEVEL > 0) error_log(__METHOD__.'('.array2string($url).','.array2string($path).') already mounted.');
|
||||
if(self::LOG_LEVEL > 0)
|
||||
{
|
||||
error_log(__METHOD__ . '(' . array2string($url) . ',' . array2string($path) . ') already mounted.');
|
||||
}
|
||||
return true; // already mounted
|
||||
}
|
||||
self::load_wrapper(Vfs::parse_url($url, PHP_URL_SCHEME));
|
||||
|
||||
if($check_url && (!file_exists($url) || opendir($url) === false))
|
||||
{
|
||||
if (self::LOG_LEVEL > 0) error_log(__METHOD__.'('.array2string($url).','.array2string($path).') url does NOT exist!');
|
||||
if(self::LOG_LEVEL > 0)
|
||||
{
|
||||
error_log(__METHOD__ . '(' . array2string($url) . ',' . array2string($path) . ') url does NOT exist!');
|
||||
}
|
||||
return false; // url does not exist
|
||||
}
|
||||
self::$fstab[$path] = $url;
|
||||
@ -157,7 +172,10 @@ class Base
|
||||
$_SESSION[Api\Session::EGW_INFO_CACHE]['user']['preferences']['common']['vfs_fstab'][$path] = $url;
|
||||
}
|
||||
}
|
||||
if (self::LOG_LEVEL > 1) error_log(__METHOD__.'('.array2string($url).','.array2string($path).') returns true (successful new mount).');
|
||||
if(self::LOG_LEVEL > 1)
|
||||
{
|
||||
error_log(__METHOD__ . '(' . array2string($url) . ',' . array2string($path) . ') returns true (successful new mount).');
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -170,12 +188,18 @@ class Base
|
||||
{
|
||||
if(!Vfs::$is_root)
|
||||
{
|
||||
if (self::LOG_LEVEL > 0) error_log(__METHOD__.'('.array2string($path).','.array2string($path).') permission denied, you are NOT root!');
|
||||
if(self::LOG_LEVEL > 0)
|
||||
{
|
||||
error_log(__METHOD__ . '(' . array2string($path) . ',' . array2string($path) . ') permission denied, you are NOT root!');
|
||||
}
|
||||
return false; // only root can mount
|
||||
}
|
||||
if(!isset(self::$fstab[$path]) && ($path = array_search($path, self::$fstab)) === false)
|
||||
{
|
||||
if (self::LOG_LEVEL > 0) error_log(__METHOD__.'('.array2string($path).') NOT mounted!');
|
||||
if(self::LOG_LEVEL > 0)
|
||||
{
|
||||
error_log(__METHOD__ . '(' . array2string($path) . ') NOT mounted!');
|
||||
}
|
||||
return false; // $path not mounted
|
||||
}
|
||||
unset(self::$fstab[$path], $GLOBALS['egw_info']['server']['vfs_fstab'][$path]);
|
||||
@ -194,7 +218,10 @@ class Base
|
||||
{
|
||||
$GLOBALS['egw']->invalidate_session_cache();
|
||||
}
|
||||
if (self::LOG_LEVEL > 1) error_log(__METHOD__.'('.array2string($path).') returns true (successful unmount).');
|
||||
if(self::LOG_LEVEL > 1)
|
||||
{
|
||||
error_log(__METHOD__ . '(' . array2string($path) . ') returns true (successful unmount).');
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -244,7 +271,10 @@ class Base
|
||||
// we do some caching here
|
||||
if(isset(self::$resolve_url_cache[$path]) && $replace_user_pass_host)
|
||||
{
|
||||
if (self::LOG_LEVEL > 1) error_log(__METHOD__."('$path') = '".self::$resolve_url_cache[$path]."' (from cache)");
|
||||
if(self::LOG_LEVEL > 1)
|
||||
{
|
||||
error_log(__METHOD__ . "('$path') = '" . self::$resolve_url_cache[$path] . "' (from cache)");
|
||||
}
|
||||
$mounted = self::$resolve_url_cache[$path]['mounted'];
|
||||
return self::$resolve_url_cache[$path]['url'];
|
||||
}
|
||||
@ -261,14 +291,24 @@ class Base
|
||||
'home' => str_replace(array('\\\\', '\\'), array('', '/'), $GLOBALS['egw_info']['user']['homedirectory']),
|
||||
);
|
||||
$parts = array_merge(Vfs::parse_url($_path), Vfs::parse_url($path), $defaults);
|
||||
if (!$parts['host']) $parts['host'] = 'default'; // otherwise we get an invalid url (scheme:///path/to/something)!
|
||||
if(!$parts['host'])
|
||||
{
|
||||
// otherwise we get an invalid url (scheme:///path/to/something)!
|
||||
$parts['host'] = 'default';
|
||||
}
|
||||
|
||||
if(!empty($parts['scheme']) && $parts['scheme'] != self::SCHEME)
|
||||
{
|
||||
if (self::LOG_LEVEL > 1) error_log(__METHOD__."('$path') = '$path' (path is already an url)");
|
||||
if(self::LOG_LEVEL > 1)
|
||||
{
|
||||
error_log(__METHOD__ . "('$path') = '$path' (path is already an url)");
|
||||
}
|
||||
return $path; // path is already a non-vfs url --> nothing to do
|
||||
}
|
||||
if (empty($parts['path'])) $parts['path'] = '/';
|
||||
if(empty($parts['path']))
|
||||
{
|
||||
$parts['path'] = '/';
|
||||
}
|
||||
|
||||
foreach(array_reverse(self::$fstab) as $mounted => $url)
|
||||
{
|
||||
@ -292,12 +332,27 @@ class Base
|
||||
|
||||
if($replace_user_pass_host)
|
||||
{
|
||||
$url = str_replace(array('$user','$pass','$host','$home'),array($parts['user'],$parts['pass'],$parts['host'],$parts['home']),$url);
|
||||
$url = str_replace(array('$user',
|
||||
'$pass',
|
||||
'$host',
|
||||
'$home'), array($parts['user'],
|
||||
$parts['pass'],
|
||||
$parts['host'],
|
||||
$parts['home']), $url);
|
||||
}
|
||||
if($parts['query'])
|
||||
{
|
||||
$url .= '?' . $parts['query'];
|
||||
}
|
||||
if($parts['fragment'])
|
||||
{
|
||||
$url .= '#' . $parts['fragment'];
|
||||
}
|
||||
if ($parts['query']) $url .= '?'.$parts['query'];
|
||||
if ($parts['fragment']) $url .= '#'.$parts['fragment'];
|
||||
|
||||
if (self::LOG_LEVEL > 1) error_log(__METHOD__."('$path') = '$url'");
|
||||
if(self::LOG_LEVEL > 1)
|
||||
{
|
||||
error_log(__METHOD__ . "('$path') = '$url'");
|
||||
}
|
||||
|
||||
if(($class = self::scheme2class($scheme)) && is_callable([$class, 'replace']))
|
||||
{
|
||||
@ -316,7 +371,8 @@ class Base
|
||||
$old_url = $url;
|
||||
$_url = self::symlinkCache_resolve($url);
|
||||
$url = @readlink($url) ?: (Vfs::parse_url($_url, PHP_URL_PATH) != $parts['path'] ?
|
||||
str_replace([$parts['path'],Vfs::parse_url($old_url,PHP_URL_SCHEME)],[$_url,Vfs::parse_url(Vfs::resolve_url($_url),PHP_URL_SCHEME)],$url) : null) ?:$url;
|
||||
str_replace([$parts['path'], Vfs::parse_url($old_url, PHP_URL_SCHEME)], [$_url,
|
||||
Vfs::parse_url(Vfs::resolve_url($_url), PHP_URL_SCHEME)], $url) : null) ?: $url;
|
||||
$is_link = $old_url == $url;
|
||||
}
|
||||
if($replace_user_pass_host && !$is_link)
|
||||
@ -327,7 +383,10 @@ class Base
|
||||
return $url;
|
||||
}
|
||||
}
|
||||
if (self::LOG_LEVEL > 0) error_log(__METHOD__."('$path') can't resolve path!\n");
|
||||
if(self::LOG_LEVEL > 0)
|
||||
{
|
||||
error_log(__METHOD__ . "('$path') can't resolve path!\n");
|
||||
}
|
||||
trigger_error(__METHOD__ . "($path) can't resolve path!\n", E_USER_WARNING);
|
||||
return false;
|
||||
}
|
||||
@ -349,9 +408,21 @@ class Base
|
||||
{
|
||||
$path = self::get_path($_path);
|
||||
|
||||
if (isset(self::$symlink_cache[$path])) return; // nothing to do
|
||||
|
||||
if ($target[0] != '/') $target = Vfs::parse_url($target,PHP_URL_PATH);
|
||||
if(isset(self::$symlink_cache[$path]))
|
||||
{
|
||||
// nothing to do
|
||||
return;
|
||||
}
|
||||
if($target[0] != '/')
|
||||
{
|
||||
$query = Vfs::parse_url($target, PHP_URL_QUERY);
|
||||
$target = Vfs::parse_url($target, PHP_URL_PATH);
|
||||
if($query)
|
||||
{
|
||||
// Don't cache without query, some StreamWrappers need those parameters
|
||||
$target = "?$query";
|
||||
}
|
||||
}
|
||||
|
||||
self::$symlink_cache[$path] = $target;
|
||||
|
||||
@ -360,7 +431,10 @@ class Base
|
||||
{
|
||||
return strlen($a) - strlen($b);
|
||||
});
|
||||
if (self::LOG_LEVEL > 1) error_log(__METHOD__."($path,$target) cache now ".array2string(self::$symlink_cache));
|
||||
if(self::LOG_LEVEL > 1)
|
||||
{
|
||||
error_log(__METHOD__ . "($path,$target) cache now " . array2string(self::$symlink_cache));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -373,7 +447,10 @@ class Base
|
||||
$path = self::get_path($_path);
|
||||
|
||||
unset(self::$symlink_cache[$path]);
|
||||
if (self::LOG_LEVEL > 1) error_log(__METHOD__."($path) cache now ".array2string(self::$symlink_cache));
|
||||
if(self::LOG_LEVEL > 1)
|
||||
{
|
||||
error_log(__METHOD__ . "($path) cache now " . array2string(self::$symlink_cache));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -398,7 +475,10 @@ class Base
|
||||
|
||||
if($path == $p)
|
||||
{
|
||||
if ($do_symlink) $target = $t;
|
||||
if($do_symlink)
|
||||
{
|
||||
$target = $t;
|
||||
}
|
||||
break;
|
||||
}
|
||||
elseif(substr($path, 0, $strlen_p + 1) == $p . '/')
|
||||
@ -407,7 +487,10 @@ class Base
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (self::LOG_LEVEL > 1 && isset($target)) error_log(__METHOD__."($path) = $target");
|
||||
if(self::LOG_LEVEL > 1 && isset($target))
|
||||
{
|
||||
error_log(__METHOD__ . "($path) = $target");
|
||||
}
|
||||
return isset($target) ? $target : $path;
|
||||
}
|
||||
|
||||
@ -489,12 +572,16 @@ class Base
|
||||
list($app, $app_scheme) = explode('.', $scheme);
|
||||
foreach(array(
|
||||
empty($app_scheme) ? 'EGroupware\\Api\\Vfs\\' . ucfirst($scheme) . '\\StreamWrapper' : // streamwrapper in Api\Vfs
|
||||
'EGroupware\\'.ucfirst($app).'\\Vfs\\'.ucfirst($app_scheme).'\\StreamWrapper', // streamwrapper in $app\Vfs
|
||||
'EGroupware\\' . ucfirst($app) . '\\Vfs\\' . ucfirst($app_scheme) . '\\StreamWrapper',
|
||||
// streamwrapper in $app\Vfs
|
||||
str_replace('.', '_', $scheme) . '_stream_wrapper', // old (flat) name
|
||||
) as $class)
|
||||
{
|
||||
//error_log(__METHOD__."('$scheme') class_exists('$class')=".array2string(class_exists($class)));
|
||||
if (class_exists($class)) return $class;
|
||||
if(class_exists($class))
|
||||
{
|
||||
return $class;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -565,7 +652,10 @@ class Base
|
||||
return false;
|
||||
}
|
||||
$k = (string)Vfs::parse_url($url, PHP_URL_SCHEME);
|
||||
if (!(is_array($scheme2urls[$k]))) $scheme2urls[$k] = array();
|
||||
if(!(is_array($scheme2urls[$k])))
|
||||
{
|
||||
$scheme2urls[$k] = array();
|
||||
}
|
||||
$scheme2urls[$k][$path] = $url;
|
||||
}
|
||||
$ret = array();
|
||||
@ -575,7 +665,10 @@ class Base
|
||||
{
|
||||
if(!class_exists($class = Vfs\StreamWrapper::scheme2class($scheme)) || !method_exists($class, $name))
|
||||
{
|
||||
if (!$fail_silent) trigger_error("Can't $name for scheme $scheme!\n",E_USER_WARNING);
|
||||
if(!$fail_silent)
|
||||
{
|
||||
trigger_error("Can't $name for scheme $scheme!\n", E_USER_WARNING);
|
||||
}
|
||||
return $fail_silent === 'null' ? null : false;
|
||||
}
|
||||
$callback = [$instanciate ? new $class($url) : $class, $name];
|
||||
|
Loading…
Reference in New Issue
Block a user