Veno-File-Manager (VFM4)免数据库云盘系统class.location.php文件释义
Veno-File-Manager (VFM4)免数据库云盘系统,根目录/vfm-admin/class/class.location.php文件释义根目录/vfm-admin/class/class.location.php //保存有关路径位置的信息的类location类的成员对象 getDir() //获取当前目录
getDir($prefix, $encoded, $html, $upper, $dir = false)
$prefix, //值为真时前缀包括前缀(“./”)
$encoded, //值为真时URL编码字符串
$html, //值为真时html编码字符串
$upper, //返回父目录
$dir = false//相对路径
经测试,第4个参数如果是 $totdirs -1,返回的始终是根目录,不是父目录
location类的成员对象 getCleanPath() //获取干净的目录路径(路径中去除开始目录'starting_dir'路径)
location类的成员对象 checkUserDir 代码块如下:
/**
* Check if directory is available for user
*
* @param string $relative relative path to index.php
*
* @return true/false
*/
public function checkUserDir($relative = false)
{
global $gateKeeper;
global $setUp;
$thispath = $this->getDir(true, false, false, 0, $relative);
if (!is_dir(realpath($thispath))) {
return false;
}
$getUserInfo = $gateKeeper->getUserInfo('dir');
if ($getUserInfo === null) {
return true;
}
$startdir = $setUp->getConfig('starting_dir');
$userpatharray = $getUserInfo !== null ? json_decode($getUserInfo, true) : array();
$thiscleanpath = ltrim($thispath, './');
$cleanstartdir = rtrim(ltrim($startdir, './'), '/');
$thispatharray = explode('/', $thiscleanpath);
$checkpath = $thispatharray === $cleanstartdir && strlen($cleanstartdir) ? $thispatharray : $thispatharray;
$pathcounter = $thispatharray === $cleanstartdir && strlen($cleanstartdir) ? (int)2 : (int)1;
// Check for multiple folders assigned
foreach ($userpatharray as $value) {
// Check if a sub/sub folder is assigned
$userdirarray = explode('/', $value);
$usersubs = count($userdirarray) - 1;
if ($usersubs > 0) {
$subscounter = $usersubs + $pathcounter;
for ($i = $pathcounter; $i < $subscounter; $i++) {
$checkpath .= '/'.$thispatharray[$i];
}
}
// Finally check if the location is accessible by the user
if ($value === $checkpath) {
return true;
}
}
return false;
}其中部分英文注释释义:
/**
*检查目录是否可供用户使用
*@param(参数) string(字符串) $relative指向index.php的相对路径
*@return(返回) true/false (真/假)
*/
// Check for multiple folders assigned
//检查分配的多个文件夹
// Check if a sub/sub folder is assigned
//检查是否分配了子/子文件夹
// Finally check if the location is accessible by the user
//最后,检查用户是否可以访问该位置
代码中相关成员变量释义如下:
$getDir:./uploads/user/ //url地址中的路径
$thispath:./uploads/user/
//当前路径
$thiscleanpath:uploads/user/
//当前路径去掉“./”
$getUserInfo:["temp","up","uploads","user"]
//当前用户有权访问的目录
$startdir:./uploads/
//上传根目录
$userpatharray: Array ( => temp => up => uploads => user )
//当前用户目录转为数组格式
$cleanstartdir:uploads
//清除上传根目录中的“./”
$thispatharray: Array ( => uploads => user => )
//把当前用户路径转为数组格式,分割符“/”
$checkpath: string(4) "user"
//检查当前用户目录
$pathcounter: 2
//当前目录正确返回数字2,否则返回数字1
此文件中location类的成员函数 editAllowed 代码块如下:
/**
* Check if editing is allowed into the current directory,
* based on configuration settings
*
* @param string $relative relative path to index.php
*
* @return true/false
*/
public function editAllowed($relative = false)
{
global $setUp;
$totdirs = count($this->path);
$father = $this->getDir(false, true, false, $totdirs -1);
$hidden_dirs = $setUp->getConfig('hidden_dirs');
if (!$hidden_dirs) {
return false;
}
if (in_array(basename($father), $hidden_dirs)) {
return false;
}
if ($this->checkUserDir($relative) === true) {
return true;
}
return false;
}其中英文注释释义:
/**
* Check if editing is allowed into the current directory, //检查是否允许编辑当前目录,
* based on configuration settings //基于配置设置
*
* @param string $relative relative path to index.php
*
* @return true/false
*/
页:
[1]