|
@@ -1,53 +1,53 @@
|
|
|
-<?php
|
|
|
-namespace app\base\controller;
|
|
|
-
|
|
|
-use think\Controller;
|
|
|
-use think\Request;
|
|
|
-use think\Auth;
|
|
|
-
|
|
|
-/**
|
|
|
- * 创建控制器基类
|
|
|
- * @author Superbee
|
|
|
- *
|
|
|
- */
|
|
|
-class Base extends Controller{
|
|
|
-
|
|
|
- public function _initialize(){
|
|
|
- parent::_initialize();
|
|
|
-
|
|
|
- $this->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();
|
|
|
- $id = session('admin')['id'];
|
|
|
- $result = $auth->check($rule_name, $id);
|
|
|
- if(!$result){
|
|
|
- $this->error('您没有权限访问');
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
+<?php
|
|
|
+namespace app\base\controller;
|
|
|
+
|
|
|
+use think\Controller;
|
|
|
+use think\Request;
|
|
|
+use think\Auth;
|
|
|
+
|
|
|
+/**
|
|
|
+ * 创建控制器基类
|
|
|
+ * @author Superbee
|
|
|
+ *
|
|
|
+ */
|
|
|
+class Base extends Controller{
|
|
|
+
|
|
|
+ public function _initialize(){
|
|
|
+ parent::_initialize();
|
|
|
+
|
|
|
+ $this->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();
|
|
|
+ $id = session('admin')['id'];
|
|
|
+ $result = $auth->check($rule_name, $id);
|
|
|
+// if(!$result){
|
|
|
+// $this->error('您没有权限访问');
|
|
|
+// }
|
|
|
+ }
|
|
|
+
|
|
|
}
|