fixed filemanager was not able to show home directory of user

This commit is contained in:
Ralf Becker 2020-09-17 19:49:28 +02:00
parent 1432502e62
commit 006580a36e
3 changed files with 20 additions and 5 deletions

View File

@ -315,6 +315,7 @@ class Vfs extends Vfs\Base
*
* @param string|array $base base of the search
* @param array $options =null the following keys are allowed:
* <code>
* - type => {d|f|F|!l} d=dirs, f=files (incl. symlinks), F=files (incl. symlinks to files), !l=no symlinks, default all
* - depth => {true|false(default)} put the contents of a dir before the dir itself
* - dirsontop => {true(default)|false} allways return dirs before the files (two distinct blocks)
@ -334,6 +335,7 @@ class Vfs extends Vfs\Base
* - follow => {true|false(default)} follow symlinks
* - hidden => {true|false(default)} include hidden files (name starts with a '.' or is Thumbs.db)
* - show-deleted => {true|false(default)} get also set by hidden, if not explicitly set otherwise (requires versioning!)
* </code>
* @param string|array/true $exec =null function to call with each found file/dir as first param and stat array as last param or
* true to return file => stat pairs
* @param array $exec_params =null further params for exec as array, path is always the first param and stat the last!
@ -352,11 +354,11 @@ class Vfs extends Vfs\Base
// process some of the options (need to be done only once)
if (isset($options['name']) && !isset($options['name_preg'])) // change from simple *,? wildcards to preg regular expression once
{
$options['name_preg'] = '/^'.str_replace(array('\\?','\\*'),array('.{1}','.*'),preg_quote($options['name'])).'$/i';
$options['name_preg'] = '/^'.str_replace(array('\\?','\\*'),array('.{1}','.*'),preg_quote($options['name'], '/')).'$/i';
}
if (isset($options['path']) && !isset($options['preg_path'])) // change from simple *,? wildcards to preg regular expression once
{
$options['path_preg'] = '/^'.str_replace(array('\\?','\\*'),array('.{1}','.*'),preg_quote($options['path'])).'$/i';
$options['path_preg'] = '/^'.str_replace(array('\\?','\\*'),array('.{1}','.*'),preg_quote($options['path'], '/')).'$/i';
}
if (!isset($options['uid']))
{
@ -391,7 +393,11 @@ class Vfs extends Vfs\Base
}
// make all find options available as stream context option "find", to allow plugins to use them
$context = stream_context_create(array(self::SCHEME => array('find' => $options)));
$context = stream_context_create(array_merge_recursive(stream_context_get_options(stream_context_get_default()), [
self::SCHEME => [
'find' => $options,
],
]));
$url = $options['url'];

View File

@ -42,11 +42,16 @@ trait UserContextTrait
{
$this->context = $url_or_context;
}
elseif(is_string($url_or_context))
else
{
$this->context = stream_context_get_default();
if(is_string($url_or_context))
{
$this->check_set_context($url_or_context, true);
}
}
}
/**
* Check if we have no user-context, but an url with a user --> set it as context

View File

@ -21,12 +21,16 @@ Vfs::$is_root = true;
Vfs::mount("$schema://default/home", '/home', false, false);
Vfs::$is_root = false;
var_dump(Vfs::mount());
var_dump(Vfs::scandir('/home'));
var_dump(Vfs::find('/home', ['maxdepth' => 1]));
//var_dump(Vfs::scandir("/home/$sysop"));
var_dump(file_put_contents("vfs://default/home/$sysop/test.txt", "Just a test ;)\n"));
var_dump("Vfs::proppatch('/home/$sysop/test.txt', [['ns' => Vfs::DEFAULT_PROP_NAMESPACE, 'name' => 'test', 'val' => 'something']])=".array2string(Vfs::proppatch("/home/$sysop/test.txt", [['ns' => Vfs::DEFAULT_PROP_NAMESPACE, 'name' => 'test', 'val' => 'something']])),
"Vfs::propfind('/home/$sysop/test.txt')=".json_encode(Vfs::propfind("/home/$sysop/test.txt"), JSON_UNESCAPED_SLASHES));
var_dump($f=fopen("vfs://default/home/$sysop/test.txt", 'r'), fread($f, 100), fclose($f));
//var_dump(Vfs::find("/home/$sysop", ['maxdepth' => 1]));
Vfs::$is_root = true;
var_dump(file_put_contents("vfs://default/home/$other/test.txt", "Just a test ;)\n"));