ZB UP类的修改说明笔记
笔记之一如何修改up的地址
修改system/function/lib/upload.php文件.
/** * @param $tmp * 保存文件,使用绝对路径,使用服务器路径 * //$zbp->usersdir * //(ZBP_PATH . "cdns/" * @return bool */ public function SaveFile($tmp) { global $zbp; foreach ($GLOBALS['hooks']['Filter_Plugin_Upload_SaveFile'] as $fpname => &$fpsignal) { $fpreturn = $fpname($tmp, $this); if ($fpsignal == PLUGIN_EXITSIGNAL_RETURN) { $fpsignal = PLUGIN_EXITSIGNAL_NONE; return $fpreturn; } } if (!file_exists(ZBP_PATH . "cdns/" . $this->Dir)) { //$zbp->usersdir @mkdir(ZBP_PATH . "cdns/" . $this->Dir, 0755, true); //$zbp->usersdir } if (PHP_SYSTEM === SYSTEM_WINDOWS) { $fn = iconv("UTF-8", $zbp->lang['windows_character_set'] . "//IGNORE", $this->Name); } else { $fn = $this->Name; } if ($this->CheckExtName()) { @move_uploaded_file($tmp, ZBP_PATH . "cdns/" . $this->Dir . $fn); //$zbp->usersdir return true; } return true; } /** * @param $str64 * * 保存文件,使用绝对路径,使用服务器路径 * //$zbp->usersdir * //(ZBP_PATH . "cdns/" * @return bool */ public function SaveBase64File($str64) { global $zbp; foreach ($GLOBALS['hooks']['Filter_Plugin_Upload_SaveBase64File'] as $fpname => &$fpsignal) { $fpreturn = $fpname($str64, $this); if ($fpsignal == PLUGIN_EXITSIGNAL_RETURN) { $fpsignal = PLUGIN_EXITSIGNAL_NONE; return $fpreturn; } } if (!file_exists(ZBP_PATH . "cdns/" . $this->Dir)) { @mkdir(ZBP_PATH . "cdns/" . $this->Dir, 0755, true); } $s = base64_decode($str64); $this->Size = strlen($s); if (PHP_SYSTEM === SYSTEM_WINDOWS) { $fn = iconv("UTF-8", "GBK//IGNORE", $this->Name); } else { $fn = $this->Name; } if ($this->CheckExtName()) { file_put_contents(ZBP_PATH . "cdns/" . $this->Dir . $fn, $s); //$zbp->usersdir return true; } } /** * @param string $s * * @return bool|string */ public function Time($s = 'Y-m-d H:i:s') { return date($s, $this->PostTime); } /** * @param $name * @param $value */ public function __set($name, $value) { if (in_array($name, array('Url', 'Dir', 'FullFile', 'Author'))) { return; } foreach ($GLOBALS['hooks']['Filter_Plugin_Upload_Set'] as $fpname => &$fpsignal) { $fpname($this, $name, $value); } parent::__set($name, $value); } /** * 返回文件名字..域名路径 * @param $name * //$zbp->usersdir * //(ZBP_PATH . "cdns/" * //cdn. * @return Member|mixed|string */ public function __get($name) { global $zbp; if ($name == 'Url') { foreach ($GLOBALS['hooks']['Filter_Plugin_Upload_Url'] as $fpname => &$fpsignal) { return $fpname($this); } return "https://cdn./" . $this->Dir . rawurlencode($this->Name); } // return "https://cdn./" . $this->Dir . rawurlencode($this->Name); //cdn域名访问 // return $zbp->host ."cdns/" . $this->Dir . rawurlencode($this->Name); //本域名访问. if ($name == 'Dir') { foreach ($GLOBALS['hooks']['Filter_Plugin_Upload_Dir'] as $fpname => &$fpsignal) { return $fpname($this); } $dir = 'upload/' . date('Y', $this->PostTime) . '/' . date('m', $this->PostTime) . '/'; if ($zbp->option['ZC_UPLOAD_DIR_YEARMONTHDAY']) { $dir .= date('d', $this->PostTime) . '/'; } return $dir; } if ($name == 'FullFile') { return "https://cdn./" . $this->Dir . $this->Name; } // return "https://cdn./" . $this->Dir . $this->Name; //cdn域名访问 // return $zbp->host . "cdns/" . $this->Dir . $this->Name; //本域名访问. if ($name == 'Author') { return $zbp->GetMemberByID($this->AuthorID); } foreach ($GLOBALS['hooks']['Filter_Plugin_Upload_Get'] as $fpname => &$fpsignal) { $fpreturn = $fpname($this, $name); if ($fpsignal == PLUGIN_EXITSIGNAL_RETURN) { $fpsignal = PLUGIN_EXITSIGNAL_NONE; return $fpreturn; } } return parent::__get($name); }