PHPCMS後臺入口地址隱藏方法
阿新 • • 發佈:2019-01-24
1.在站點跟目錄新建一個目錄,目錄名自定,例如manage,這個manage目錄就是今後你登陸後臺需要訪問路徑。
2.在manage目錄裡新建一個index.php檔案,程式碼如下:
<?php
define('PHPCMS_PATH', realpath(dirname(__FILE__) . '/..') . '/');
include '../phpcms/base.php';
$session_storage = 'session_' . pc_base :: load_config('system', 'session_storage');
pc_base :: load_sys_class($session_storage );
session_start();
$_SESSION['right_enter'] = 1;
unset($session_storage);
header('location:../index.php?m=admin&c=index&a=login&pc_hash=');
?>
3.找到\phpcms\modules\admin目錄,在這個目錄中新建一個名為MY_index.php的檔案,程式碼如下:
<?php
defined('IN_PHPCMS') or exit('No permission resources.');
class MY_index extends index {
public function __construct() {
if(empty($_SESSION['right_enter'])) {
header('location:./');
exit();
}
parent::__construct();
}
public function public_logout() {
$_SESSION['right_enter'] = 0;
parent::public_logout();
}
}
?>
最後,將上面新建的目錄和檔案上傳至伺服器對應的路徑後,你的PHPCMS站點就只能通過http://www.xxx.com/manage/這樣的地址訪問後臺的登入入口了。
備註:上述方法僅針對PHPCMS V9版。