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); }
private function get_upath($path, $type = 'u') { $path = WF_SYS_WIN ? wf_g2u($path) : $path; if ('r' == $type) { $path = substr($path, strlen(WF_REAL_ROOT_PATH) - 1); } if ('u' == $type) { $path = substr($path, strlen(WF_REAL_USER_PATH) - 1); } return str_replace('//', '/', $path); }