w_getSysInfo(); // if (isset($sysInfo['swoole_loader']) and isset($sysInfo['swoole_loader_version'])) { // if(!$sysInfo['swoole_loader']){ // return $this->error('未安装脚本', 10402); // } // } else { // return $this->error('未安装脚本', 10402); // } // 兼容W7 global $_W; // print_r($_W['setting']['copyright']); require IA_ROOT_WK . DS . 'config' . DS . 'config.php'; if(SYS_TYPE == 'W7'){ if (empty($_W['uniacid'])) { $uniacidKey = '__uniacid'; $sessionKey = '__session'; if(empty($_COOKIE[$configCookie['pre'] . $uniacidKey])) { return $this->error('没有获取到uniacid', 10403); } $_W['uniacid'] = $_COOKIE[$configCookie['pre'] . $uniacidKey]; if (empty($_COOKIE[$configCookie['pre'] . $sessionKey])) { return $this->error('请重新从总平台登录', 10403); } } if(W7_TYPE=='W7R'){ $_W['uniacid'] = 1; } } else { $_W['uniacid'] = 1; } if (AuthServiceFacade::needLogin()) { $initUser = UserServiceFacade::init($request->header('laytp-admin-token', $request->header('laytpAdminToken', $request->cookie('laytpAdminToken')))); // print_r($request->header('laytp-admin-token', $request->header('laytpAdminToken', $request->cookie('laytpAdminToken')))); if (!$initUser){ if(SYS_TYPE == 'W7'){ // if (empty($_W['uniacid'])){ // return $this->error('登录信息无uniacid', 10403); // } // $loginUserInfo = \app\model\admin\User::where('username', '=', 'admin')->field(UserServiceFacade::getAllowFields())->findOrEmpty(); // $userId = 1; // $token = Random::uuid(); // $loginUserInfo['token'] = $token; // Token::set($token, $userId, 0); // print_r($token); // $initUser = UserServiceFacade::init($token); return $this->error('登录信息已过期', 10402); // print_r($initUser); } else { $this->error(UserServiceFacade::getError(), 10401); } } if (!UserServiceFacade::isLogin()) { if ($request->isAjax()) { if(SYS_TYPE == 'W7'){ return $this->error('登录信息已过期', 10402); }else{ return $this->error('登录信息已过期', 10401); } } else { return redirect('/admin/login.html'); } } if (AuthServiceFacade::needAuth()) { $user = UserServiceFacade::getUser(); // print_r($user); if ($user->is_super_manager !== 1) { $userId = $user->id; $plugin = defined('LT_PLUGIN') ? LT_PLUGIN : ''; $controller = strtolower(str_replace("\\", ".", $request->controller())); if ($plugin) { $node = 'plugin/' . $plugin . '/' . $controller . '/' . $request->action(); } else { $node = trim(app('http')->getName() . '/' . $controller . '/' . $request->action(),'/'); } if (!AuthServiceFacade::hasAuth($userId, $node)) { return $this->error('无权请求:/' . $node); } } } } return $next($request); } public function w_getSysInfo() { global $env; $sysEnv = []; // Get content of phpinfo ob_start(); phpinfo(); $sysInfo = ob_get_contents(); ob_end_clean(); // Explode phpinfo content if ($env['php']['run_mode'] == 'cli') { $sysInfoList = explode('\n', $sysInfo); } else { $sysInfoList = explode('', $sysInfo); } foreach($sysInfoList as $sysInfoItem) { if (preg_match('/thread safety/i', $sysInfoItem)) { $sysEnv['thread_safety'] = (preg_match('/(enabled|yes)/i', $sysInfoItem) != 0); } if (preg_match('/swoole_loader support/i', $sysInfoItem)) { $sysEnv['swoole_loader'] = (preg_match('/(enabled|yes)/i', $sysInfoItem) != 0); } if (preg_match('/swoole_loader version/i', $sysInfoItem)) { preg_match('/\d+.\d+.\d+/s', $sysInfoItem, $match); $sysEnv['swoole_loader_version'] = isset($match[0]) ? $match[0] : false; } } //var_dump($sysEnv);die(); return $sysEnv; } }