Get the model name from the provided user agent or null if it cannot be determined
@param string $ua
@param boolean $use_default
@return NULL|string
763998
public static function getAndroidModel($ua, $use_default=true) {
		// Normalize spaces in UA before capturing parts
		$ua = preg_replace('|;(?! )|', '; ', $ua);

		// Different logic for Mozillite and non-Mozillite UAs to isolate model name
		// Non-Mozillite UAs get first preference
		if (preg_match('#(^[A-Za-z0-9_\-\+ ]+)[/ ]?(?:[A-Za-z0-9_\-\+\.]+)? +Linux/[0-9\.]+ +Android[ /][0-9\.]+ +Release/[0-9\.]+#', $ua, $matches)) {
			// Trim off spaces and semicolons
			$model = rtrim($matches[1], ' ;');

		// Locales are optional for matching model name since UAs like Chrome Mobile do not contain them
		} else if (preg_match('#Android [^;]+;(?>(?: xx-xx[ ;]+)?)(.+?)(?:Build/|\))#', $ua, $matches)) {
			// Trim off spaces and semicolons
			$model = rtrim($matches[1], ' ;');

		} else {
			return null;
		}

		// The previous RegEx may return just "Build/.*" for UAs like:
		// HTC_Dream Mozilla/5.0 (Linux; U; Android 1.5; xx-xx; Build/CUPCAKE) AppleWebKit/528.5+ (KHTML, like Gecko) Version/3.1.2 Mobile Safari/525.20.1
		if (strpos($model, 'Build/') === 0) {
			return null;
		}

		// Normalize Chinese UAs
		$model = preg_replace('#(?:_CMCC_TD|_CMCC|_TD)\b#', '', $model);

		// Normalize models with resolution
		if (strpos($model, '*') !== false) {
			if (($pos = strpos($model, '/')) !== false) {
				$model = substr($model, 0, $pos);
			}
		}

		// Normalize Huawei UAs
		$model = str_replace('HW-HUAWEI_', 'HUAWEI ', $model);

		// Normalize Coolpad UAs
		if (strpos($model, 'YL-Coolpad') !== false) {
			$model = preg_replace('#YL-Coolpad[ _]#', 'Coolpad ', $model);
		}

		// HTC
		if (strpos($model, 'HTC') !== false) {
			// Normalize "HTC/"
			$model = preg_replace('#HTC[ _\-/]#', 'HTC~', $model);

			// Remove the version
			if (($pos = strpos($model, '/')) !== false) {
				$model = substr($model, 0, $pos);
			}
			$model = preg_replace('#( V| )\d+?\.[\d\.]+$#', '', $model);

		}

		// Samsung
		$model = preg_replace('#(SAMSUNG[^/]+)/.*$#', '$1', $model);

		// Orange
		$model = preg_replace('#ORANGE/.*$#', 'ORANGE', $model);

		// LG
		$model = preg_replace('#(LG-[A-Za-z0-9\-]+).*$#', '$1', $model);

		// Serial Number
		$model = preg_replace('#\[[\d]{10}\]#', '', $model);

		// Remove whitespace
		$model = trim($model);

		// Normalize Samsung and Sony/SonyEricsson model name changes due to Chrome Mobile
		$model = preg_replace('#^(?:SAMSUNG|SonyEricsson|Sony)[ \-]?#', '', $model);

		return (strlen($model) === 0)? null: $model;
	}
538055
@Override
    public String getUserAgent(){
        String[] uas = new String[]{"Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/44.0.2403.157 Safari/537.36",
                "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:42.0) Gecko/20100101 Firefox/42.0",
                "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:42.0) Gecko/20100101 Firefox/38.0"
        };
        return uas[RandomUtils.nextInt(0,uas.length)]+" "+ RandomStringUtils.randomAlphanumeric(8);
    }
870550
public function getUserParam($key, $default = null)
        {
            if (isset($this->_params[$key])) {
                return $this->_params[$key];
            }

            return $default;
        }
225775
public function determineCategory($userAgent = null, $defaultGrade = Grades::UNSUPPORTED) {
        $logger = $GLOBALS['logger'];
        $app = $GLOBALS['app'];
        $parsedUA = UA::parse($userAgent);
        if (!empty($app) && !$app->getConfiguration()->isLocal()) {
            try {
                $logger->info('Attempting device lookup in database');
                $browser = $this->_lookupDB($parsedUA);
                return $this->_computeCategory($browser);
            } catch (\Exception $ex) {
                $logger->info("No device database found, defaulting to local file based detection");
                $browser = $this->_lookupLocal($parsedUA, $defaultGrade);
                return $this->_computeCategory($browser);
            }
        } else {
            //$logger->info("Local environment, defaulting to local file based detection");
            $browser = $this->_lookupLocal($parsedUA, $defaultGrade);
            return $this->_computeCategory($browser);
        }
    }
971403
public static function getUserAgent($request, $override_sideloaded_browser_ua = true)
    {
        if (!$override_sideloaded_browser_ua) {
            return $request['HTTP_USER_AGENT'];
        }

        if (isset($request[WURFL_Constants::UA])) {
            return $request[WURFL_Constants::UA];
        }
        
        foreach (self::$userAgentSearchOrder as $header) {
            if (isset($request[$header])) {
                return $request[$header];
            }
        }
        
        return '';
    }
1016909
public function getUserAgent($user_agent = null, $return_array = false, $full_info = false) {
		if ($full_info) { return get_browser($user_agent, $return_array); }

		return $_SERVER['HTTP_USER_AGENT'];
	}
708540
private static URI buildDefaultURI(final String userId) {
        // Construct the default URI for the user ID that is not a URI.
        String userAgentBaseUri = System.getProperty(USER_AGENT_BASE_URI_PROPERTY);
        if (isNullOrEmpty(userAgentBaseUri)) {
            // use the default local user agent base uri
            userAgentBaseUri = DEFAULT_USER_AGENT_BASE_URI;
        }

        final String userAgentUri = userAgentBaseUri + userId;

        LOGGER.trace("Default URI is created for user {}: {}", userId, userAgentUri);
        return URI.create(userAgentUri);
    }
997267
public function getDefaultUserAgent(): string
    {
        $defaultAgent = 'Swoft/' . App::version();
        if (\extension_loaded('curl') && \function_exists('curl_version')) {
            $defaultAgent .= ' curl/' . \curl_version()['version'];
        }
        $defaultAgent .= ' PHP/' . PHP_VERSION;
        return $defaultAgent;
    }
190003
public function paramName($name, $default = null)
    {
        if (($extName = $this->propertyName($name)) && substr($extName, 0, 1) == ':') {
            return substr($extName, 1);
        }

        return $default;
    }
397074
public static function getUcAndroidModel($userAgent)
    {
        // Locales are optional for matching model name since UAs like Chrome Mobile do not contain them
        if (!preg_match('#Adr [\d\.]+; [a-zA-Z]+-[a-zA-Z]+; (.*)\) U2#', $userAgent, $matches)) {
            return null;
        }

        $model = $matches[1];

        // HTC
        if (strpos($model, 'HTC') !== false) {
            // Normalize "HTC/"
            $model = preg_replace('#HTC[ _\-/]#', 'HTC~', $model);
            // Remove the version
            $model = preg_replace('#(/| +V?\d)[\.\d]+$#', '', $model);
            $model = preg_replace('#/.*$#', '', $model);
        }

        // Samsung
        $model = preg_replace('#(SAMSUNG[^/]+)/.*$#', '$1', $model);
        // Orange
        $model = preg_replace('#ORANGE/.*$#', 'ORANGE', $model);
        // LG
        $model = preg_replace('#(LG-[A-Za-z0-9\-]+).*$#', '$1', $model);
        // Serial Number
        $model = preg_replace('#\[[\d]{10}\]#', '', $model);

        $model = trim($model);

        return (strlen($model) === 0) ? null : $model;
    }
115816
public static function getOperaOnAndroidVersion($userAgent, $useDefault = true)
    {
        if (preg_match('/Version\/(\d\d)/', $userAgent, $matches)) {
            $version = $matches[1];

            if (in_array($version, self::$validOperaVersions)) {
                return $version;
            }
        }

        return $useDefault ? self::OPERA_DEFAULT_VERSION : null;
    }
454267
public function parser($use_default = true)
    {
        if ($use_default) {
            return isset($this->parser) ? $this->parser : $this->default_parser;
        }

        return $this->parser;
    }
1177335
public function get($name = null, $default = null)
    {
        $source = $this->_context->_REQUEST;

        if ($name === null) {
            return $source;
        }

        if (isset($source[$name]) && $source[$name] !== '') {
            $value = $source[$name];

            if (is_array($value) && is_scalar($default)) {
                throw new InvalidValueException(['the value of `:name` name is not scalar', 'name' => $name]);
            }

            if ($default !== null) {
                $type = gettype($default);
                if ($type === 'string') {
                    return (string)$value;
                } elseif ($type === 'integer') {
                    return (int)$value;
                } elseif ($type === 'double') {
                    return (float)$value;
                } elseif ($type === 'boolean') {
                    return (bool)$value;
                } else {
                    return $value;
                }
            } else {
                return $value;
            }
        } else {
            if ($default === null) {
                throw new MissingRequiredFieldsException($name);
            }

            return $default;
        }
    }
513052
public function findUserRoleByUsername($username, $executeQuery = true)
    {
        $query = $this->_em
            ->createQuery('
                SELECT r
                FROM Claroline\CoreBundle\Entity\Role r
                WHERE r.type = :type
                AND r.name = :name
                AND r.translationKey = :key
            ')
            ->setParameter('type', Role::USER_ROLE)
            ->setParameter('name', 'ROLE_USER_'.strtoupper($username))
            ->setParameter('key', $username);

        return $executeQuery ? $query->getOneOrNullResult() : $query;
    }
272959
private function _lookupDB($ua)
    {
        $browser = new Browser();
        $browser->setGrade(Grades::UNSUPPORTED);

        $conn = new \Mongo('mongodb://'.DeviceManager::HOST);
        $collection = $conn->selectDB(DeviceManager::DB)->devices;

        // Determine Regex fitting the U/A Category. 
        $pattern = $this->_getMatchingRegex($ua);
        $uaRegex = new \MongoRegex($pattern);

        //$device = $collection->findOne(array("userAgent"=>$nameRegex));
        // Match User Agent independent of OS Version, Check OS Version >= Base Matching Version
        $device = $collection->findOne(
            array (
                '$and'=>array (
                    array ("userAgent"=>$uaRegex), 
                    array ('$or'=> array(
                        array("device.os.version"=>array('$exists'=>false)),
                        array("device.os.version"=>array('$lte'=>"".$ua->osVersion))
                    ))
                )
            )
        );

        if (!empty($device)) {
            $browser = $this->_createBrowser($device);
        } else {
            // TODO : Request for Browser Categorization 
        }
        return $browser;
    }
937430
public static function getDefaultUserAgent()
    {
        static $defaultAgent = '';
        if (!$defaultAgent) {
            $defaultAgent = 'Guzzle/' . self::VERSION;
            if (extension_loaded('curl')) {
                $defaultAgent .= ' curl/' . curl_version()['version'];
            }
            $defaultAgent .= ' PHP/' . PHP_VERSION;
        }

        return $defaultAgent;
    }
434449
public function getActionName()
    {
        $action = $this->app->getAction();
        if (isset($this->actionPermissions[$action])) {
            return $this->actionPermissions[$action];
        }

        foreach ($this->actionPermissions as $actions => $name) {
            $actions = explode(',', $actions);
            if (in_array($action, $actions)) {
                return $name;
            }
        }

        return null;
    }