예제 #1
0
 public function init()
 {
     // 基本参数
     $this->path = wf_gpc('fs-path', 'g');
     $this->name = wf_gpc('fs-name', 'g');
     $this->type = wf_gpc('fs-type', 'g');
     // 处理用户根目录
     $REAL_ROOT_PATH = realpath($_SESSION['wf_uroot']);
     $REAL_USER_PATH = realpath($_SESSION['wf_uroot'] . '/' . (WF_SYS_WIN ? wf_u2g($_SESSION['wf_upath']) : $_SESSION['wf_upath']));
     if (!empty($REAL_ROOT_PATH) && is_readable($REAL_ROOT_PATH)) {
         $REAL_ROOT_PATH = str_replace('\\', '/', $REAL_ROOT_PATH . '/');
     } else {
         $this->code = 300;
         $this->mess = '文件系统错误,无法访问 ROOT 目录!';
         $this->show();
     }
     if (!empty($REAL_USER_PATH) && is_readable($REAL_USER_PATH)) {
         $REAL_USER_PATH = str_replace('\\', '/', $REAL_USER_PATH . '/');
     } else {
         $this->code = 300;
         $this->mess = '文件系统错误,无法访问 USER 目录!';
         $this->show();
     }
     if (strlen($REAL_USER_PATH) < strlen($REAL_ROOT_PATH)) {
         $this->code = 300;
         $this->mess = '文件系统错误,无法访问ROOT-USER-Error!';
         $this->show();
     }
     // 定义文件系统根路径常量 - 唯一的全局路径
     define('WF_REAL_ROOT_PATH', $REAL_ROOT_PATH);
     define('WF_REAL_USER_PATH', WF_SYS_WIN ? wf_g2u($REAL_USER_PATH) : $REAL_USER_PATH);
 }
예제 #2
0
 /**
  * get_gpath获取以/开头的虚拟路径,GB2312 用于访问文件系统
  * get_upath获取以/开头的虚拟路径,UTF-8  用于页面输出
  * @param unknown_type $path
  * @param unknown_type $type
  * @return unknown
  */
 public function get_gpath($path, $type = 'u')
 {
     if ('r' == $type) {
         $path = str_replace('//', '/', WF_REAL_ROOT_PATH . $path);
     }
     if ('u' == $type) {
         $path = str_replace('//', '/', WF_REAL_USER_PATH . $path);
     }
     $path = WF_SYS_WIN ? wf_u2g($path) : $path;
     return $path;
 }