Returns true if the give $userAgent is from a desktop device

@param string $userAgent

@return bool
544364
public static function isDesktopBrowser($userAgent)
    {
        if (self::$isDesktopBrowser !== null) {
            return self::$isDesktopBrowser;
        }

        self::$isDesktopBrowser = false;
        $userAgent              = strtolower($userAgent);

        foreach (self::$desktopBrowsers as $key) {
            if (strpos($userAgent, $key) !== false) {
                self::$isDesktopBrowser = true;
                break;
            }
        }

        return self::$isDesktopBrowser;
    }
255824
public function applyRecoveryMatch($userAgent)
    {
        if (Utils::checkIfContainsAnyOf($userAgent, array('WPDesktop', 'ZuneWP7'))
            || Utils::checkIfContainsAll($userAgent, array('Mozilla/5.0 (Windows NT ', ' ARM;', ' Edge/'))
        ) {
            if (Utils::checkIfContainsAll($userAgent, array('Mozilla/5.0 (Windows NT ', ' ARM;', ' Edge/'))) {
                return 'generic_ms_phone_os10_desktopmode';
            }

            if (Utils::checkIfContains($userAgent, 'WPDesktop')) {
                return 'generic_ms_phone_os8_desktopmode';
            }

            if (Utils::checkIfContains($userAgent, 'Trident/5.0')) {
                return 'generic_ms_phone_os7_5_desktopmode';
            }

            return 'generic_ms_phone_os7_desktopmode';
        }

        $version = self::getWindowsPhoneVersion($userAgent);

        if ($version === '10.0') {
            return 'generic_ms_phone_os10';
        }

        if ($version === '8.1') {
            return 'generic_ms_phone_os8_1';
        }

        if ($version === '8.0') {
            return 'generic_ms_phone_os8';
        }

        if ($version === '7.8') {
            return 'generic_ms_phone_os7_8';
        }

        if ($version === '7.5') {
            return 'generic_ms_phone_os7_5';
        }

        if ($version === '7.0') {
            return 'generic_ms_phone_os7';
        }

        if ($version === '6.5') {
            return 'generic_ms_winmo6_5';
        }

        //These are probably UAs of the type "Windows Phone Ad Client (Xna)/5.1.0.0 BMID/E67970D969"
        if (Utils::checkIfStartsWithAnyOf($userAgent, array('Windows Phone Ad Client', 'WindowsPhoneAdClient'))) {
            return 'generic_ms_phone_os7';
        }

        return WurflConstants::NO_MATCH;
    }
868806
public function applyConclusiveMatch($userAgent)
    {
        // Mozilla/5.0 (Ubuntu; Mobile) WebKit/537.21
        // Mozilla/5.0 (Ubuntu; Tablet) WebKit/537.21
        //                      ^ RIS tolerance
        // Mozilla/5.0 (Linux; Ubuntu 14.04 like Android 4.4) AppleWebKit/537.36 Chromium/35.0.1870.2 Mobile Safari/537.36
        //                                  ^ RIS tolerance
        if (Utils::checkIfContains($userAgent, 'like Android')) {
            $search = 'like Android';
        } else {
            $search = 'WebKit/';
        }
        $idx = strpos($userAgent, $search);
        if ($idx !== false) {
            // Match to the end of the search string
            $tolerance = strlen($idx + strlen($search));

            return $this->getDeviceIDFromRIS($userAgent, $tolerance);
        }

        return WurflConstants::NO_MATCH;
    }
24878
protected function detectBrowser($userAgent)
	{
		// Attempt to detect the browser type.  Obviously we are only worried about major browsers.
		if ((stripos($userAgent, 'MSIE') !== false) && (stripos($userAgent, 'Opera') === false))
		{
			$this->browser = self::IE;
			$patternBrowser = 'MSIE';
		}
		elseif ((stripos($userAgent, 'Firefox') !== false) && (stripos($userAgent, 'like Firefox') === false))
		{
			$this->browser = self::FIREFOX;
			$patternBrowser = 'Firefox';
		}
		elseif (stripos($userAgent, 'Chrome') !== false)
		{
			$this->browser = self::CHROME;
			$patternBrowser = 'Chrome';
		}
		elseif (stripos($userAgent, 'Safari') !== false)
		{
			$this->browser = self::SAFARI;
			$patternBrowser = 'Safari';
		}
		elseif (stripos($userAgent, 'Opera') !== false)
		{
			$this->browser = self::OPERA;
			$patternBrowser = 'Opera';
		}

		// If we detected a known browser let's attempt to determine the version.
		if ($this->browser)
		{
			// Build the REGEX pattern to match the browser version string within the user agent string.
			$pattern = '#(?<browser>Version|' . $patternBrowser . ')[/ ]+(?<version>[0-9.|a-zA-Z.]*)#';

			// Attempt to find version strings in the user agent string.
			$matches = array();

			if (preg_match_all($pattern, $userAgent, $matches))
			{
				// Do we have both a Version and browser match?
				if (count($matches['browser']) == 2)
				{
					// See whether Version or browser came first, and use the number accordingly.
					if (strripos($userAgent, 'Version') < strripos($userAgent, $patternBrowser))
					{
						$this->browserVersion = $matches['version'][0];
					}
					else
					{
						$this->browserVersion = $matches['version'][1];
					}
				}
				elseif (count($matches['browser']) > 2)
				{
					$key = array_search('Version', $matches['browser']);

					if ($key)
					{
						$this->browserVersion = $matches['version'][$key];
					}
				}
				else
				// We only have a Version or a browser so use what we have.
				{
					$this->browserVersion = $matches['version'][0];
				}
			}
		}

		// Mark this detection routine as run.
		$this->detection['browser'] = true;
	}
837540
protected function detectDevice($userAgent)
    {
        // Attempt to detect the client platform.
        switch (true) {
            case stripos($userAgent, 'Windows') !== false:
                $this->device = self::DEVICE_WINDOWS;

                // Let's look at the specific mobile options in the Windows space.
                if (stripos($userAgent, 'Windows Phone') !== false) {
                    $this->mobile = true;
                    $this->device = self::DEVICE_WINDOWS_PHONE;
                } elseif (stripos($userAgent, 'Windows CE') !== false) {
                    $this->mobile = true;
                    $this->device = self::DEVICE_WINDOWS_CE;
                }

                break;

            case stripos($userAgent, 'iPhone') !== false:
                // Interestingly 'iPhone' is present in all iOS devices so far including iPad and iPods.
                $this->mobile = true;
                $this->device = self::DEVICE_IPHONE;

                // Let's look at the specific mobile options in the iOS space.
                if (stripos($userAgent, 'iPad') !== false) {
                    $this->device = self::DEVICE_IPAD;
                } elseif (stripos($userAgent, 'iPod') !== false) {
                    $this->device = self::DEVICE_IPOD;
                }

                break;

            case stripos($userAgent, 'iPad') !== false:
                // In case where iPhone is not mentioned in iPad user agent string
                $this->mobile = true;
                $this->device = self::DEVICE_IPAD;

                break;

            case stripos($userAgent, 'iPod') !== false:
                // In case where iPhone is not mentioned in iPod user agent string
                $this->mobile = true;
                $this->device = self::DEVICE_IPOD;

                break;

            case preg_match('/macintosh|mac os x/i', $userAgent):
                // This has to come after the iPhone check because mac strings are also present in iOS devices.
                $this->device = self::DEVICE_MAC;

                break;

            case stripos($userAgent, 'Blackberry') !== false:
                $this->mobile = true;
                $this->device = self::DEVICE_BLACKBERRY;

                break;

            case stripos($userAgent, 'Android') !== false:
                $this->mobile = true;
                $this->device = self::DEVICE_ANDROID;
                /*
                 * Attempt to distinguish between Android phones and tablets
                 * There is no totally foolproof method but certain rules almost always hold
                 * Android 3.x is only used for tablets
                 * Some devices and browsers encourage users to change their UA string to include Tablet.
                 * Google encourages manufacturers to exclude the string Mobile from tablet device UA strings.
                 * In some modes Kindle Android devices include the string Mobile but they include the string Silk.
                 */
                if (stripos($userAgent, 'Android 3') !== false || stripos($userAgent, 'Tablet') !== false
                    || stripos($userAgent, 'Mobile') === false || stripos($userAgent, 'Silk') !== false) {
                    $this->device = self::ANDROID_TABLET;
                }

                break;

            case stripos($userAgent, 'Linux') !== false:
                $this->device = self::DEVICE_LINUX;

                break;
        }

        // Mark this detection routine as run.
        $this->detection['device'] = true;
    }
497154
private static function checkWindowsPhone(Device $device, UserAgent $userAgent)
    {
        if (stripos($userAgent->getUserAgentString(), 'Windows Phone') !== false) {
            if (preg_match('/Microsoft; (Lumia [^)]*)\)/', $userAgent->getUserAgentString(), $matches)) {
                $device->setName($matches[1]);
                return true;
            }

            $device->setName($device::WINDOWS_PHONE);
            return true;
        }
        return false;
    }
1123001
public function isMobile(string $useragent): bool
    {
        if (preg_match('/xbox|googletv|eeepc|smart-?tv|sonydtv|hbbtv|gxt_dongle_3188|apple tv|mxl661l32|nettv|crkey|lenovog780|windows iot|netcast|raspbian|bravia|tablet pc [12]\.|automobile|netgem|wordpress/i', $useragent)) {
            return false;
        }

        if (preg_match('/iphone.*windows nt.*micromessenger/i', $useragent)) {
            return true;
        }

        if (preg_match('/windows nt.*arm;/i', $useragent)) {
            return true;
        }

        // ignore mobile safari token if windows nt token is available
        if (preg_match('/windows nt.*(mobile safari|opera mobi|iphone)/i', $useragent)) {
            return false;
        }

        if (preg_match('/Puffin\/[\d\.]+WD/', $useragent)) {
            return false;
        }

        if (preg_match('/UCWEB|Puffin\/[\d\.]+[AIWM][TP]?|TBD\d{4}|TBD[BCG]\d{3,4}/', $useragent)) {
            return true;
        }

        if (preg_match('/fbid\/desktop/i', $useragent)) {
            return false;
        }

        if (preg_match('/mobile;|mobileok|-mobile|office mobile|tablet|(?<!a)phone|wireless|wpdesktop|zunewp7|xblwp7|(?<!ninesky-)android|adr |iphone|ip[ao]d|samsung(?!browser|-agent)|j2me|micromax|htc|karbonn|hisense|docomo|siemens(?! ?(a\/s|testmanager|lms|ag))|ktouch|portalmmm|rim tablet|jolla|iball|windows mobile|windows ce|symbos|symbian|remixos|webos|velocitymicro|samsung-(gt|sph)|lenovo|lumia|surftab|padfone|xda_diamond_2|transformer tf|touchpad|toshiba_ac_and_az|hpwos|silk|wap-browser|sailfish|crowsnest|folio_and_a|steelcore|m2 note|spice qt-75|spark284|lemon b556|terra_101|dino762|wetab|dataaccessd|lenovotablet|qtcarbrowser|onebrowser|stitcher|rss_?radio|antennapod|antenna\/|podcruncher|captivenetworksupport|(?<!c)ios;|audioboom.com\/boos|beyondpod|st80208|\[fban|wap2|up\.link|up\.browser|series ?[46]0|pocket ?pc|playstation|palm(?!a)|opera mobi|opera mini|openwave|obigo|nokia|nintendo|netfront|mqqbrowser|midp|meego|maemo|look-alike|linux armv|like mac os x|kindle|juc ?\(linux; ?u;|j2me|iuc\(u;ios|iris|hp-tablet|hd_mini_t|gingerbread|folio100|foma|firefox or ie|embider|danger hiptop|cldc|blazer|dalvik|bolt|blackberry|\b(bb10|bada|brew|mtk)\b|\btcl\b(?! http client)|aspen simulator|arm; touch|wap browser|kyy21|ebrd1101|ebrd1201|huawei-u8651|tizen/i', $useragent)) {
            return true;
        }

        return false;
    }
629866
public static function isSmartTV($userAgent)
    {
        if (self::$isSmartTv !== null) {
            return self::$isSmartTv;
        }
        self::$isSmartTv = false;
        $userAgent       = strtolower($userAgent);
        foreach (self::$smartTVBrowsers as $key) {
            if (strpos($userAgent, $key) !== false) {
                self::$isSmartTv = true;
                break;
            }
        }

        return self::$isSmartTv;
    }
519044
public function applyRecoveryCatchAllMatch($userAgent) {
		if (WURFL_Handlers_Utils::isDesktopBrowserHeavyDutyAnalysis($userAgent)) {
			return WURFL_Constants::GENERIC_WEB_BROWSER;
		}
		$mobile = WURFL_Handlers_Utils::isMobileBrowser($userAgent);
		$desktop = WURFL_Handlers_Utils::isDesktopBrowser($userAgent);
		
		if (!$desktop) {
			$deviceId = WURFL_Handlers_Utils::getMobileCatchAllId($userAgent);
			if ($deviceId !== WURFL_Constants::NO_MATCH) {
				return $deviceId;
			}
		}
		
		if ($mobile) return WURFL_Constants::GENERIC_MOBILE;
		if ($desktop) return WURFL_Constants::GENERIC_WEB_BROWSER;
		return WURFL_Constants::GENERIC;
	}
61705
public function BD_CheckBotAgent($UserAgent = false)
    {
        // Check if user agent present
        if ($UserAgent === false)
        {
            $UserAgent = trim(\Environment::get('httpUserAgent'));
        }
        return \BugBuster\BotDetection\CheckBotAgentSimple::checkAgent( $UserAgent );
    }
1057916
public function isDisallowed($url, $userAgent = null)
    {
        if ($userAgent !== null) {
            $this->setUserAgent($userAgent);
        }
        $url = $this->encode_url($url);
        return $this->checkRules(self::DIRECTIVE_DISALLOW, $this->getPath($url), $this->userAgentMatch);
    }
690399
public function applyConclusiveMatch($userAgent)
    {
        $match = $this->lookForMatchingUserAgent($userAgent);

        if (!empty($match)) {
            return $this->userAgentsWithDeviceID[$match];
        }

        return WurflConstants::NO_MATCH;
    }
1155355
protected function filterAndroid(array &$userAgent) {
        if ('safari' === $userAgent['browser_name'] && strpos($userAgent['string'], 'android ')) {
            $userAgent['browser_name'] = 'android';
            $userAgent['operating_system'] = 'android';
            $userAgent['browser_version'] = preg_replace('|.+android ([0-9]+(?:\.[0-9]+)+).+|', '$1', $userAgent['string']);
        }
    }
546520
public function applyConclusiveMatch($userAgent)
    {
        $tolerance = Utils::toleranceToRisDelimeter($userAgent);
        if ($tolerance !== false) {
            return $this->getDeviceIDFromRIS($userAgent, $tolerance);
        }

        $operaMiniIndex = Utils::indexOfOrLength($userAgent, 'Opera Mini');

        if ($operaMiniIndex !== false) {
            // Match up to the first '.' after 'Opera Mini'
            $tolerance = strpos($userAgent, '.', $operaMiniIndex);

            if ($tolerance !== false) {
                // +1 to match just after the '.'
                return $this->getDeviceIDFromRIS($userAgent, $tolerance + 1);
            }
        }

        $tolerance = Utils::firstSlash($userAgent);

        return $this->getDeviceIDFromRIS($userAgent, $tolerance);
    }
829227
public function isDesktopDevice(string $useragent): bool
    {
        if (preg_match('/windows ?(phone|iot|mobile|ce)|iemobile|lumia|xblwp7|zunewp7|wpdesktop|mobile version|microsoft windows; ppc| wds |wpos:|netgem/i', $useragent)) {
            return false;
        }

        // windows
        if (preg_match('/davclnt|revolt|microsoft outlook|wmplayer|lavf|nsplayer|windows|win(10|8|7|vista|xp|2000|98|95|nt|3[12]|me|9x)|barca|cygwin|the bat!/i', $useragent)) {
            return true;
        }

        // linux
        if (preg_match('/linux|debian|ubuntu|cros|tinybrowser/i', $useragent)) {
            return true;
        }

        // macOS
        if (preg_match('/macintosh|darwin|mac(_powerpc|book|mini|pro)|(for|ppc) mac|mac ?os|integrity|camino|pubsub|(os\=|i|power)mac/i', $useragent)) {
            return true;
        }

        if (preg_match('/freebsd|openbsd|netbsd|bsd four|os\/2|warp|sunos|hp-?ux|beos|irix|solaris|openvms|aix|esx|unix|w3m|google desktop|eeepc|dillo|konqueror|eudora|masking-agent|safersurf|integrity|davclnt|cybeye|google pp default|microsoft office|nsplayer|ms ?frontpage|revolt|akregator|installatron|lynx|camino|osf1|barca|the bat!|libvlc|openvas|gvfs/i', $useragent)) {
            return true;
        }

        return false;
    }
12919
public static function isMobileBrowser($userAgent)
    {
        if (self::$_is_mobile_browser !== null) {
            return self::$_is_mobile_browser;
        }
        self::$_is_mobile_browser = false;
        $userAgent = strtolower($userAgent);
        foreach (self::$mobileBrowsers as $key) {
            if (strpos($userAgent, $key) !== false) {
                self::$_is_mobile_browser = true;
                break;
            }
        }
        return self::$_is_mobile_browser;
    }
1000009
public function applyRecoveryMatch($userAgent)
    {
        $androidVersion = str_replace('.', '_', AndroidHandler::getAndroidVersion($userAgent));
        $deviceID       = 'generic_android_ver' . $androidVersion . '_ucweb';

        if (in_array($deviceID, self::$constantIDs)) {
            return $deviceID;
        } else {
            return 'generic_android_ver2_0_ucweb';
        }
    }