12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061 |
- <?php
- namespace app\inter\controller;
- use app\admin\library\Auth;
- use app\admin\model\Admin;
- use think\Controller;
- use think\Db;
- use think\Session;
- use think\Config;
- use think\Cookie;
- use think\Cache;
- use think\Log;
- use think\Request;
- class Base extends Controller
- {
- protected $logined = false; //登录状态
- /**
- * 无需登录的方法,同时也就不需要鉴权了
- * @var array
- */
- protected $noNeedLogin = [];
- public $sessionid;
- /**
- * 初始化操作
- */
- public function _initialize()
- {
- $sessionid = Request::instance()->param('sessionid');
- log::record($sessionid);
- log::record('-----------base 页面cache-------------');
- log::record($sessionid);
- log::record('------------------------');
- $admin = Cache::get($sessionid);
- if (!$admin) {
- die(json_encode(['status'=>'fail','code'=>'1010','msg'=>'对不起,您还未进行登录,请先登录']));
- // $this->error('对不起,您还未进行登录,请先登录','inter/index');
- }
- }
- function getRandomString($len, $chars=null)
- {
- if (is_null($chars)){
- $chars = "abcdefghijklmnopqrstuvwxyz0123456789";
- }
- mt_srand(10000000*(double)microtime());
- for ($i = 0, $str = '', $lc = strlen($chars)-1; $i < $len; $i++){
- $str .= $chars[mt_rand(0, $lc)];
- }
- return $str;
- }
- public function _construct()
- {
- $request = Request::instance();
- if($request->method() == 'OPTIONS'){
- return;
- }
- }
- }
|