route.php
文件
1 2 3
| return array ( 'l1n6yun$' => 'admin/Index/index', );
|
``app\admin\controller\AdminBaseController` 类
1 2 3 4 5 6 7 8 9 10 11 12
| protected function initialize() { parent::initialize();
$sessionAdminId = session('ADMIN_ID');
if (empty($sessionAdminId)) { return $this->redirect(url("admin/Public/login")); } }
|
app\admin\controller\IndexController
类
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
| public function initialize() { $adminSettings = cmf_get_option('admin_settings'); if (empty($adminSettings['admin_password']) || $this->request->path() == $adminSettings['admin_password']) { $adminId = cmf_get_current_admin_id(); if (empty($adminId)) { session("__LOGIN_BY_CMF_ADMIN_PW__", 1); } }
parent::initialize(); }
|
app\admin\controller\PublicController
类
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
| class PublicController extends AdminBaseController { public function initialize() { } public function login() { $loginAllowed = session("__LOGIN_BY_CMF_ADMIN_PW__"); if (empty($loginAllowed)) { return redirect(cmf_get_root() . "/"); } session("__SP_ADMIN_LOGIN_PAGE_SHOWED_SUCCESS__", true); return $this->fetch(":login"); } public function doLogin() { $loginAllowed = session("__SP_ADMIN_LOGIN_PAGE_SHOWED_SUCCESS__"); if (empty($loginAllowed)) { $this->error('非法登录!', cmf_get_root() . '/'); }
if($result) { session('ADMIN_ID', $result["id"]); session('name', $result["user_login"]); session("__LOGIN_BY_CMF_ADMIN_PW__", null); session("__SP_ADMIN_LOGIN_PAGE_SHOWED_SUCCESS__", null); $this->success(lang('LOGIN_SUCCESS'), url("admin/Index/index")); } } }
|