找回密码
 注册
首页 ≡≡网络技术≡≡ PHP语言 Veno-File-Manager (VFM4)免数据库云盘系统class.locati ...

CMS Veno-File-Manager (VFM4)免数据库云盘系统class.location.php文件释义

灰儿 2022-8-29 06:16:42
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 代码块如下:
  1.         /**
  2.          * Check if directory is available for user
  3.          *
  4.          * @param string $relative relative path to index.php
  5.          *
  6.          * @return true/false
  7.          */
  8.         public function checkUserDir($relative = false)
  9.         {
  10.             global $gateKeeper;
  11.             global $setUp;

  12.             $thispath = $this->getDir(true, false, false, 0, $relative);

  13.             if (!is_dir(realpath($thispath))) {
  14.                 return false;
  15.             }

  16.             $getUserInfo = $gateKeeper->getUserInfo('dir');
  17.             if ($getUserInfo === null) {
  18.                 return true;
  19.             }

  20.             $startdir = $setUp->getConfig('starting_dir');
  21.             $userpatharray = $getUserInfo !== null ? json_decode($getUserInfo, true) : array();
  22.             $thiscleanpath = ltrim($thispath, './');
  23.             $cleanstartdir = rtrim(ltrim($startdir, './'), '/');
  24.             $thispatharray = explode('/', $thiscleanpath);
  25.             $checkpath = $thispatharray[0] === $cleanstartdir && strlen($cleanstartdir) ? $thispatharray[1] : $thispatharray[0];
  26.             $pathcounter = $thispatharray[0] === $cleanstartdir && strlen($cleanstartdir) ? (int)2 : (int)1;

  27.             // Check for multiple folders assigned
  28.             foreach ($userpatharray as $value) {

  29.                 // Check if a sub/sub folder is assigned
  30.                 $userdirarray = explode('/', $value);
  31.                 $usersubs = count($userdirarray) - 1;
  32.                 if ($usersubs > 0) {
  33.                     $subscounter = $usersubs + $pathcounter;
  34.                     for ($i = $pathcounter; $i < $subscounter; $i++) {
  35.                         $checkpath .= '/'.$thispatharray[$i];
  36.                     }
  37.                 }

  38.                 // Finally check if the location is accessible by the user
  39.                 if ($value === $checkpath) {
  40.                     return true;
  41.                 }
  42.             }
  43.             return false;
  44.         }
复制代码
其中部分英文注释释义:

/**
*检查目录是否可供用户使用
*@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 ( [0] => temp [1] => up [2] => uploads [3] => user )
//当前用户目录转为数组格式

$cleanstartdir:uploads            
//清除上传根目录中的“./”

$thispatharray: Array ( [0] => uploads [1] => user [2] => )
//把当前用户路径转为数组格式,分割符“/”

$checkpath: string(4) "user"     
//检查当前用户目录

$pathcounter: 2           
//当前目录正确返回数字2,否则返回数字1

此文件中location类的成员函数 editAllowed 代码块如下:
  1.         /**
  2.          * Check if editing is allowed into the current directory,
  3.          * based on configuration settings
  4.          *
  5.          * @param string $relative relative path to index.php
  6.          *
  7.          * @return true/false
  8.          */
  9.         public function editAllowed($relative = false)
  10.         {
  11.             global $setUp;
  12.             $totdirs = count($this->path);

  13.             $father = $this->getDir(false, true, false, $totdirs -1);
  14.             $hidden_dirs = $setUp->getConfig('hidden_dirs');
  15.             if (!$hidden_dirs) {
  16.                 return false;
  17.             }
  18.             if (in_array(basename($father), $hidden_dirs)) {
  19.                 return false;
  20.             }
  21.             if ($this->checkUserDir($relative) === true) {
  22.                 return true;
  23.             }
  24.             return false;
  25.         }
复制代码
其中英文注释释义:

        /**
         * Check if editing is allowed into the current directory,        //检查是否允许编辑当前目录,
         * based on configuration settings       //基于配置设置
         *
         * @param string $relative relative path to index.php
         *
         * @return true/false
         */








您需要登录后才可以回帖 登录 | 注册
学习中心
站长自定义文字内容,利用碎片时间,随时随地获取优质内容。
Q设计语言 了解更多
Q Design 提供商家设计所需的指导与资源,帮商家快速完成产品设计、降低生产成本。
学习中心
站长自定义文字内容,利用碎片时间,随时随地获取优质内容。
Q设计语言 了解更多
Q Design 提供商家设计所需的指导与资源,帮商家快速完成产品设计、降低生产成本。