assign("rootpath", $this->request->root()); $this->check_login(); $this->check_auth(); } /** * 检测是否登录 */ private function check_login(){ $admin = session('admin'); if(empty($admin)){ $this->redirect($this->request->root().'/base/login/login'); } } /** * 检查权限 */ private function check_auth(){ $m = $this->request->module (); $c = $this->request->controller (); $a = $this->request->action (); $rule_name = '/'.$m.'/'.$c.'/'.$a; $auth = new Auth(); $admin = session('admin'); $result = $auth->check($rule_name, $admin['id']); // if(!$result){ // $this->error('您没有权限访问'); // } } }