TP_Auth管理类使用明细
可以在【Common/Controller下||模块/Controller】建一个类
类名可以是AuthController.class.php或CommonController.class.php(whatever)
namespaceCommon\Controller;useThink\Controller;useThink\Auth;classAuthControllerextendsController{publicfunction_initialize(){$auth=newAuth();if(CONTROLLER_NAME.'/'.ACTION_NAME=="Index/index"){if(!$auth->check(CONTROLLER_NAME.'/'.ACTION_NAME,session('aid'))){$this->error("请先登录",U("Login/login"));}}else{if(!$auth->check(CONTROLLER_NAME.'/'.ACTION_NAME,session('aid'))){if(empty($_SESSION['aid'])){echo"<script>";echo"alert('登录已过期,请重新登录!');";echo"</script>";exit();}echo"<script>";echo"alert('你没有操作权限!');";echo"</script>";echo"<h2>你没有操作权限!</h2>";exit();}}}}
需要权限管理的类继承控制类就可以了
classIndexControllerextendsAuthController{
声明:本站所有文章资源内容,如无特殊说明或标注,均为采集网络资源。如若本站内容侵犯了原著者的合法权益,可联系本站删除。