Get a user agent

@param bool $random
@return string
507608
public function getUserAgent($random = false)
    {
        if ($random === false) {
            return 'Mozilla/5.0 (Windows NT 6.1; rv:31.0) Gecko/20100101 Firefox/31.0';
        }

        $headers = [
            'Mozilla/5.0 (Windows NT 6.1; rv:31.0) Gecko/20100101 Firefox/31.0',
            'Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2228.0 Safari/537.36',
            'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2227.0 Safari/537.36',
            'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2227.0 Safari/537.36',
            'Mozilla/5.0 (Windows NT 6.3; rv:36.0) Gecko/20100101 Firefox/36.0',
            'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Ubuntu Chromium/41.0.2272.76 Chrome/41.0.2272.76 Safari/537.36',
            'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:29.0) Gecko/20120101 Firefox/29.0',
        ];

        $randomKey = array_rand($headers);

        return $headers[$randomKey];
    }
2746
private function getUserAgent()
    {
        $curlinfo = curl_version();
        $uagent = array();
        $uagent[] = 'gocardless-pro-php/3.0.0';
        $uagent[] = 'schema-version/2015-07-06';
        $uagent[] = 'GuzzleHttp/' . \GuzzleHttp\Client::VERSION;
        $uagent[] = 'php/' . phpversion();
        if (extension_loaded('curl') && function_exists('curl_version')) {
            $uagent[] = 'curl/' . \curl_version()['version'];
            $uagent[] = 'curl/' . \curl_version()['host'];
        }
        return implode(' ', $uagent);
    }
996823
protected function _getUserAgent()
    {
        $ua = str_replace('%v', self::VERSION, $this->userAgent);
        $ua = str_replace('%m', $this->_getUpdateMethod(), $ua);

        return $ua;
    }
1022862
protected function getUserAgent()
    {
        return sprintf(
            '%s/%s (%s; %s; PHP %s)',
            str_replace(' ', '-', $this->config->get('application.name')),
            $this->config->getVersion(),
            php_uname('s'),
            php_uname('r'),
            PHP_VERSION
        );
    }
891742
public static function getInstance($userAgent = null, $accept = null)
	{
		$signature = serialize(array($userAgent, $accept));

		if (empty(self::$instances[$signature]))
		{
			self::$instances[$signature] = new self($userAgent, $accept);
		}

		return self::$instances[$signature];
	}
522471
public function getSelectedUser()
    {
        static $user = null;

        if ($user !== null) {
            return $user;
        }

        $staffId = $this->_getIdParam();
        if ($staffId) {
            $user   = $this->loader->getUserLoader()->getUserByStaffId($staffId);
            $source = $this->menu->getParameterSource();
            $user->applyToMenuSource($source);
        } else {
            $user = false;
        }

        return $user;
    }
1319524
protected function getRandomUser()
    {
        if ($this->users === null) {
            $this->users = User::all();
        }

        return $this->users->random();
    }
452548
public function getUser()
    {
        if ( ! $this->container->has('security')) {
            return false;
        }

        $security = $this->container->get('security');

        if ( ! $token = $security->getToken()) {
            return false;
        }

        $user = $token->getUser();
        if ( ! $user instanceof UserInterface) {
            return false;
        }

        return $user;
    }
653611
def get_user_agent():
    
    from sys import platform, version_info
    template = "neobolt/{} Python/{}.{}.{}-{}-{} ({})"
    fields = (version,) + tuple(version_info) + (platform,)
    return template.format(*fields)
1235516
public function getDeviceForUserAgent($userAgent = '')
    {
        if (!is_string($userAgent)) {
            $userAgent = '';
        }

        $requestFactory = new Request\GenericRequestFactory();

        $request = $requestFactory->createRequestForUserAgent($userAgent);
        $device  = $this->getDeviceForRequest($request);

        return $device;
    }
1373656
public function getUserAgents($limit = 0)
    {
        $counter = 0;

        foreach ($this->loadFromPath() as $row) {
            if ($limit && $counter >= $limit) {
                return;
            }

            yield trim($row['ua']);
            ++$counter;
        }
    }
1148478
public static function checkAgent($UserAgent=false)
    {
        // Check if user agent present
   	    if ($UserAgent === false) 
   	    {
            return false; // No user agent, no search.
   	    }
   	    
   	    $UserAgent = trim( $UserAgent );
        if (false === (bool) $UserAgent) 
        { 
           return false; // No user agent, no search.
        }
        
        
        // Rough search
        $CheckUserAgent = str_ireplace(static::$_BotsRough, '#', $UserAgent);
        if ($UserAgent != $CheckUserAgent)
        { 
            // found
            return true;
        }
        
        // Fine search
        $CheckUserAgent = str_ireplace(static::$_BotsFine, '#', $UserAgent);
        if ($UserAgent != $CheckUserAgent)
        { 
            // found
            return true;
        }
        
        // Feature #76, search for user bot filter definitions in localconfig.php
        if ( isset($GLOBALS['BOTDETECTION']['BOT_AGENT']) )
        {
            $botagents = array();
            foreach ($GLOBALS['BOTDETECTION']['BOT_AGENT'] as $search)
            {
                $botagents[$search[0]] = $search[1];
            }
            $num = count($botagents);
            $arrBots = array_keys($botagents);
            for ($c=0; $c < $num; $c++)
            {
                $CheckUserAgent = str_ireplace($arrBots[$c], '#', $UserAgent);
                if ($UserAgent != $CheckUserAgent)
                {   
                    // found
                    return true;
                }
            }
        }
        return false;
    }
1232514
protected function determineClientUserAgent($request)
    {
        $userAgent = null;
        $serverParams = $request->getServerParams();
        $userAgent = $serverParams['HTTP_USER_AGENT'];

        $checkProxyHeaders = $this->checkProxyHeaders;
        if ($checkProxyHeaders && !empty($this->trustedProxies)) {
            if (!in_array($userAgent, $this->trustedProxies)) {
                $checkProxyHeaders = false;
            }
        }

        if ($checkProxyHeaders) {
            foreach ($this->headersToInspect as $header) {
                if ($request->hasHeader($header)) {
                    $userAgent = trim(current(explode(',', $request->getHeaderLine($header))));
                    break;
                }
            }
        }
        return $userAgent;
    }
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']:''));
	}
448366
public function normalize($userAgent)
    {
        $index = strpos($userAgent, 'UP.Link');

        if ($index !== false) {
            return substr($userAgent, 0, $index);
        }

        return $userAgent;
    }
1313399
public function getUserAgents($limit = 0)
    {
        $counter   = 0;
        $allAgents = [];

        foreach ($this->getAgents() as $agent) {
            if ($limit && $counter >= $limit) {
                return;
            }

            if (empty($agent)) {
                continue;
            }

            if (array_key_exists($agent, $allAgents)) {
                continue;
            }

            yield $agent;
            $allAgents[$agent] = 1;
            ++$counter;
        }
    }
526881
public function getUser($user)
    {
        $result = null;
        if ($user === 'current') {
            $u = new \User();
            if ($u->isRegistered()) {
                $result = $u;
            }
        } elseif (is_int($user) || (is_string($user) && is_numeric($user))) {
            $result = \User::getByUserID($user);
        } elseif ($user instanceof UserService) {
            $result = $user;
        } elseif ($user instanceof UserEntity) {
            $result = \User::getByUserID($user->getUserID());
        }

        return $result;
    }