可以在【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{


附件:http://down.51cto.com/data/2367428