/data/webroot/top51.cn/APP/plugins/Auth.php(8)
01 <?php use Illuminate\Database\Capsule\Manager as DB; 02 class AuthPlugin extends Yaf_Plugin_Abstract { 03 public function routerShutdown(Yaf_Request_Abstract $request, Yaf_Response_Abstract $response) { 04 /***检查控制器是否存在***/ 05 $config = Yaf_Registry::get('config'); 06 if( !file_exists( $config['application']['directory'].'/controllers/' . ucfirst($request->controller) . '.' . $config['application']['ext']) ) 07 throw new Exception('不存在控制器'.$request->controller); 08 09 global $auth; 10 if (!Tools::isSpider()) { $auth = new Auth(_RBACCookieKey_); 11 $ggdata = DB::table('roles')->where('rolename', 'EVERYONE')->first();/***查询公共控制器权限***/ 12 $ggcontrollers = explode(',', $ggdata['controllers']); 13 if( !in_array(strtolower($request->controller), array_map('strtolower', $ggcontrollers)) ){/***权限验证***/ if (!$auth->isLogin()){ redirect( url('public', 'login') ); } 14 //已登陆,但无此控制器权限 15 $owndata= DB::table('roles')->find($auth->role); 16 $owncontrollers = explode(',', $owndata['controllers']); 17 if( !in_array(strtolower($request->controller), array_map('strtolower', $owncontrollers)) ){ 18 throw new Exception('无访问权限.'); 19 } 20 }
#0 |
: AuthPlugin->routerShutdown() |
#1 |
+ – /data/webroot/top51.cn/public/index.php(8): Yaf_Application->run() 1 <?php 2 //error_reporting(7); 3 header('content-type:text/html;charset=utf-8'); 4 date_default_timezone_set('PRC'); 5 define('APP_PATH', dirname(__FILE__).'/..'); 6 7 $application = new Yaf_Application(APP_PATH . "/conf/app.ini"); 8 $application->bootstrap()->run(); |