user-Agent 信息分析
@return bool
339276
protected function _userAgentCheck()
    {
        if (empty($_SERVER['HTTP_USER_AGENT'])) {
            return true;
        }

        $agent = strtolower($_SERVER['HTTP_USER_AGENT']);

        /* @link http://detectmobilebrowser.com/mobile */
        if (preg_match('/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino/i', $agent)
            || preg_match('/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i', substr($agent, 0, 4))) {
            $this->set('isMobile', true);
        } else {
            $this->set('isPc', true);
        }

        //// system check
//        $isLinux = $isMac = $isAndroid = false;

        if (false !== strpos($agent, 'win')) {
            $this->set('isWin', true);
            $os = 'Windows other';

            if (preg_match('/nt 6.0/i', $agent)) {
                $os = 'Windows Vista';
            } else if (preg_match('/nt 6.2/i', $agent)) {
                $os = 'Windows 8';
            } else if (preg_match('/nt 10/i', $agent)) {
                $os = 'Windows 10';
            } else if (preg_match('/nt 6.1/i', $agent)) {
                $os = 'Windows 7';
            } else if (preg_match('/nt 5.1/i', $agent)) {
                $os = 'Windows XP';
            } else if (preg_match('/nt 5/i', $agent)) {
                $os = 'Windows 2000';
            }
        } elseif (strpos($agent, 'linux')) {

            if (strpos($agent, 'android')) {
                $os = 'Android';
                $this->set('isAndroid', true);
            } else {
                $os = 'Linux';
                $this->set('isLinux', true);
            }

        } elseif (strpos($agent, 'android')) {
            $os = 'Android';
            $this->set('isAndroid', true);
        } elseif (strpos($agent, 'iphone')) {
            $os = 'Ios';
            $this->set('isIos', true);
        } elseif (strpos($agent, 'ubuntu')) {
            $os = 'Ubuntu';
            $this->set('isLinux', true);
        } elseif (strpos($agent, 'mac')) {
            $os = 'Mac OS X';
            $this->set('isMac', true);
        } elseif (strpos($agent, 'unix')) {
            $os = 'Unix';
            $this->set('isUnix', true);
        } elseif (strpos($agent, 'bsd')) {
            $os = 'BSD';
        } elseif (strpos($agent, 'symbian')) {
            $os = 'SymbianOS';
        } else {
            $os = 'Unknown';
        }

        $this->set('os', $os);

        //// browser check
        $browser = 'Unknown';

        // myie
        if (strpos($agent, 'myie')) {
            $browser = 'Myie';

            // Netscape
        } else if (strpos($agent, 'netscape')) {
            $browser = 'Netscape';

            // Opera
        } else if (strpos($agent, 'opera')) {
            $browser = 'Opera';

            // netcaptor
        } else if (strpos($agent, 'netcaptor')) {
            $browser = 'NetCaptor';

            // TencentTraveler
        } else if (strpos($agent, 'tencenttraveler')) {
            $browser = 'TencentTraveler';

            // Firefox
        } else if (strpos($agent, 'firefox')) {
            $browser = 'Firefox';

            // ie
        } else if (strpos($agent, 'msie')) {
            $browser = 'IE';

            // chrome
        } else if (strpos($agent, 'chrome')) {
            $browser = 'Chrome';
        }

        $this->set('browser', $browser);

        return true;
    }
263737
protected function checkUserSecurity()
    {
        $allowedGroup = $this->property('security', self::ALLOW_ALL);
        $allowedUserGroups = $this->property('allowedUserGroups', []);
        $isAuthenticated = Auth::check();

        if ($isAuthenticated) {
            if ($allowedGroup == self::ALLOW_GUEST) {
                return false;
            }

            if (!empty($allowedUserGroups)) {
                $userGroups = Auth::getUser()->groups->lists('code');
                if (!count(array_intersect($allowedUserGroups, $userGroups))) {
                    return false;
                }
            }
        }
        else {
            if ($allowedGroup == self::ALLOW_USER) {
                return false;
            }
        }

        return true;
    }
349511
public function index()
    {
        $userQuery = $this->Users->find()
            ->select([
                $this->Users->aliasField('id'),
                $this->Users->aliasField('firstname'),
                $this->Users->aliasField('lastname'),
                $this->Users->aliasField('username'),
                $this->Users->aliasField('email'),
                $this->Users->aliasField('verified'),
                $this->Users->aliasField('active')
            ])
            ->contain([
                'Groups' => [
                    'queryBuilder' => function (Query $q) {
                        return $q
                            ->select([
                                $this->Users->Groups->aliasField('id'),
                                $this->Users->Groups->aliasField('name')
                            ]);
                    }
                ]
            ]);

        $groups = $this->Users->Groups->find('list')->order(['name' => 'ASC'])->toArray();
        $groups[0] = __d('wasabi_core', '--- (unassigned)');

        $this->set([
            'users' => $this->Filter->paginate($this->Filter->filter($userQuery)),
            'groups' => $groups
        ]);
    }
629913
public function getUserAgent(): string
    {
        if (null === $this->cachedUserAgent) {
            $this->cachedUserAgent = $this->generate();
        }

        return $this->cachedUserAgent;
    }
472150
public static function isSuperUser()
    {
        $authInfo = self::getLoginInfo();
        if (!$authInfo) {//登录超时
            return false;
        }
        $admin = Config::get('administratorid');
        return is_array($admin) ? in_array($authInfo['id'], $admin) : ($authInfo['id'] === $admin);
    }
189254
public function checkAccess()
    {
        $user = \Yii::$app->user->identity;

        if (method_exists($user, 'getIsAdmin')) {
            return $user->getIsAdmin();
        } else if ($this->adminPermission) {
            return \Yii::$app->user->can($this->adminPermission);
        } else {
            return isset($user->username) ? in_array($user->username, $this->admins) : false;
        }
    }
371043
public function info()
    {
        $info = [
            'id' => $this->id,
            'action' => $this->action,
            'condition' => $this->condition,
            'expressions' => $this->expressions,
            'logMessageFormat' => $this->logMessageFormat,
            'logLevel' => $this->logLevel,
            'isFinalState' => $this->isFinalState,
            'createTime' => $this->createTime,
            'finalTime' => $this->finalTime,
            'stackFrames' => array_map(function ($sf) {
                return $sf->info();
            }, $this->stackFrames),
            'evaluatedExpressions' => $this->evaluatedExpressions
        ];
        if ($this->labels) {
            $info['labels'] = $this->labels;
        }
        if ($this->userEmail) {
            $info['userEmail'] = $this->userEmail;
        }
        if ($this->location) {
            $info['location'] = $this->location->info();
        }
        if ($this->status) {
            $info['status'] = $this->status->info();
        }
        if ($this->variableTable) {
            $info['variableTable'] = $this->variableTable->info();
        }
        return $info;
    }
986522
protected  function requestUserInfo() {
        $res = $this->sendRequest('GET', $this->getUrl('oauth', 'userinfo'), array(), array(
            'Authorization' => 'Bearer ' . $this->sessionStorage->read('access_token'),
        ));
        $result = $res->getBody();

        return json_decode($result, true);
    }
1006105
public function getIsAdmin()
	{
		if(!\Yii::$app->user->isGuest)
		{
			if(\Yii::$app->user->identity->role < 2)
			{
				return true;
			}
		}
		return false;
	}
643711
function agent() {
		$headers=$this->hive['HEADERS'];
		return isset($headers['X-Operamini-Phone-UA'])?
			$headers['X-Operamini-Phone-UA']:
			(isset($headers['X-Skyfire-Phone'])?
				$headers['X-Skyfire-Phone']:
				(isset($headers['User-Agent'])?
					$headers['User-Agent']:''));
	}
1071735
public function getCurrentSessionUserInfo()
    {
        $ts = $this->config->table_sessions;
        $tu = $this->config->table_users;

        $query = "
		SELECT {$ts}.uid, {$ts}.expiredate, {$ts}.ip, {$tu}.email, {$tu}.username
		FROM {$ts}, {$tu}
		WHERE hash = :hash AND {$ts}.uid = {$tu}.id";

        $query = $this->dbh->prepare($query);
        $query->execute([
            'hash'	=>	$this->getCurrentSessionHash()
        ]);

        if ($query->rowCount() == 0) {
            return false;
        }

        return $query->fetch(\PDO::FETCH_ASSOC);
    }
432246
public function getMetaInfo()
    {
        if ($this->getAuthenticationDetails() instanceof AuthenticationDetails) {
            $authId     = $this->getAuthenticationDetails()->getAuthId();
            $authMethod = $this->getAuthenticationDetails()->getAuthMethod();
            $authRole   = $this->getAuthenticationDetails()->getAuthRole();
            $authRoles  = $this->getAuthenticationDetails()->getAuthRoles();
        } else {
            $authId     = 'anonymous';
            $authMethod = 'anonymous';
            $authRole   = 'anonymous';
            $authRoles  = [];
        }

        return [
            'realm'         => $this->getRealm()->getRealmName(),
            'authprovider'  => null,
            'authid'        => $authId,
            'authrole'      => $authRole,
            'authroles'     => $authRoles,
            'authmethod'    => $authMethod,
            'session'       => $this->getSessionId(),
            'role_features' => $this->getRoleFeatures()
        ];
    }
711394
public static function checkBrowserAmaya()
    {
        if (stripos(self::$userAgentString, 'amaya') !== false) {
            $aresult = explode('/', stristr(self::$userAgentString, 'Amaya'));
            if (isset($aresult[1])) {
                $aversion = explode(' ', $aresult[1]);
                self::$browser->setVersion($aversion[0]);
            }
            self::$browser->setName(Browser::AMAYA);

            return true;
        }

        return false;
    }
718275
public function isIOS()
    {
        // get user agent
        $browser = $this->getUserAgent();

        return (strpos($browser, 'iphone') || strpos($browser, 'ipod') || strpos($browser, 'ipad'));
    }
518582
public function isAuthorised()
    {

        if (is_array($this->user) === true
            && isset($this->user['error']) === false
        ) {

            return true;
        }

        return $this->getUser();
    }
237518
public function getGroupList()
    {
        $result = $this->httpGet(self::WECHAT_GROUP_LIST_GET_PREFIX, [
            'access_token' => $this->getAccessToken()
        ]);
        return isset($result['groups']) ? $result['groups'] : false;
    }
1008997
public function getUserAgent()
    {
        if (isset($this->_userAgent)) {
            return $this->_userAgent;
        }
        return $this->_userAgent = isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : null;
    }