123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263 |
- <?php
- /**
- * Created by PhpStorm.
- * User: Administrator
- * Date: 2018/2/26/026
- * Time: 9:56
- */
- namespace backend\base;
- use yii\web\Controller;
- use Yii;
- class CommonController extends Controller
- {
- public function beforeAction($action)
- {
- if(empty(Yii::$app->session['user_info'])){
- echo "<script>window.parent.location.href='".'/public/login'."'</script>";
- return false;
- }
- //异地登录
- $model = new \backend\server\Checkauthority();
- $unique = $model->UniqueToken();
- // if($unique == false)
- // {
- // echo "<script>alert('检测到该账号已在别的电脑登录!');window.parent.location.href='".'/public/logout'."'</script>";
- // return false;
- // }
- //超级管理员
- // if(Yii::$app->session['user_info']['user'] === Yii::$app->params['UserSuperadministrator']) return true;
- //权限控制
- $controller = strtolower(Yii::$app->controller->id);
- $action = strtolower(Yii::$app->controller->action->id);
- if(Yii::$app->session['user_info']['user'] === Yii::$app->params['UserSuperadministrator'] || $model->Comparison($controller,$action) === true )
- {
- $record = new \common\models\UserOperationrecord();
- $record->uid = Yii::$app->session['user_info']['uid'];
- $record->controller = $controller;
- $record->action = $action;
- $record->save();
- return true;
- }
- if(Yii::$app->request->isAjax)
- {
- $list['code'] = 500;
- $list['msg'] = '暂无操作权限';
- $list['data'] = '';
- echo json_encode($list);
- return false;
- }
- // echo '<script>alert("暂无权限操作!")</script>';
- return false;
- }
- }
|