/** * @param string $userAgent * * @return bool */ public function canHandle($userAgent) { if (Utils::isDesktopBrowser($userAgent)) { return false; } return Utils::checkIfStartsWithAnyOf($userAgent, array('Mot-', 'MOT-', 'MOTO', 'moto')) || Utils::checkIfContains($userAgent, 'Motorola'); }
/** * @param string $userAgent * * @return bool */ public function canHandle($userAgent) { if (Utils::isMobileBrowser($userAgent)) { return false; } return Utils::checkIfContains($userAgent, 'Safari') && Utils::checkIfStartsWithAnyOf($userAgent, array('Mozilla/5.0 (Macintosh', 'Mozilla/5.0 (Windows')); }
/** * @param string $userAgent * * @return null|string */ public function applyConclusiveMatch($userAgent) { $tolerance = Utils::indexOfAnyOrLength($userAgent, array('/', ' '), strpos($userAgent, 'Nokia')); if (Utils::checkIfStartsWithAnyOf($userAgent, array('Nokia/', 'Nokia '))) { $tolerance = strlen($userAgent); } return $this->getDeviceIDFromRIS($userAgent, $tolerance); }
/** * @param string $userAgent * * @return null|string */ public function applyConclusiveMatch($userAgent) { $tolerance = Utils::toleranceToRisDelimeter($userAgent); if ($tolerance !== false) { return $this->getDeviceIDFromRIS($userAgent, $tolerance); } //Return no match for UAs with no extractable Android version, model and that do not start with either Mozilla or Dalvik if (!Utils::checkIfStartsWithAnyOf($userAgent, array('Mozilla', 'Dalvik'))) { return WurflConstants::NO_MATCH; } if (self::getAndroidModel($userAgent, false) === null) { return $this->getDeviceIDFromRIS($userAgent, strlen($userAgent)); } // Standard RIS Matching $tolerance = Utils::indexOfAnyOrLength($userAgent, array(' Build/', ' AppleWebKit')); return $this->getDeviceIDFromRIS($userAgent, $tolerance); }
/** * @param string $userAgent * * @return string */ public function normalize($userAgent) { if (Utils::checkIfContainsAnyOf($userAgent, array('WPDesktop', 'ZuneWP7')) || Utils::checkIfContainsAll($userAgent, array('Mozilla/5.0 (Windows NT ', ' ARM;', ' Edge/'))) { $model = WindowsPhoneHandler::getWindowsPhoneDesktopModel($userAgent); $version = WindowsPhoneHandler::getWindowsPhoneDesktopVersion($userAgent); } elseif (Utils::checkIfStartsWithAnyOf($userAgent, array('Windows Phone Ad Client', 'WindowsPhoneAdClient'))) { $model = WindowsPhoneHandler::getWindowsPhoneAdClientModel($userAgent); $version = WindowsPhoneHandler::getWindowsPhoneVersion($userAgent); } elseif (Utils::checkIfContains($userAgent, 'NativeHost')) { return $userAgent; } else { $model = WindowsPhoneHandler::getWindowsPhoneModel($userAgent); $version = WindowsPhoneHandler::getWindowsPhoneVersion($userAgent); } if ($model !== null && $version !== null) { // 'WP' is for Windows Phone $prefix = 'WP' . $version . ' ' . $model . WurflConstants::RIS_DELIMITER; return $prefix . $userAgent; } return $userAgent; }
/** * @param string $userAgent * * @return null|string */ 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; }
/** * Applies Catch-All match * * @param string $userAgent * * @return string WURFL deviceID */ public function applyRecoveryCatchAllMatch($userAgent) { if (Utils::isDesktopBrowserHeavyDutyAnalysis($userAgent)) { return WurflConstants::GENERIC_WEB_BROWSER; } if (Utils::checkIfContains($userAgent, 'CoreMedia')) { return 'apple_iphone_coremedia_ver1'; } if (Utils::checkIfContains($userAgent, 'Windows CE')) { return 'generic_ms_mobile'; } if (Utils::checkIfContains($userAgent, 'UP.Browser/7.2')) { return 'opwv_v72_generic'; } if (Utils::checkIfContains($userAgent, 'UP.Browser/7')) { return 'opwv_v7_generic'; } if (Utils::checkIfContains($userAgent, 'UP.Browser/6.2')) { return 'opwv_v62_generic'; } if (Utils::checkIfContains($userAgent, 'UP.Browser/6')) { return 'opwv_v6_generic'; } if (Utils::checkIfContains($userAgent, 'UP.Browser/5')) { return 'upgui_generic'; } if (Utils::checkIfContains($userAgent, 'UP.Browser/4')) { return 'uptext_generic'; } if (Utils::checkIfContains($userAgent, 'UP.Browser/3')) { return 'uptext_generic'; } // Series 60 if (Utils::checkIfContains($userAgent, 'Series60')) { return 'nokia_generic_series60'; } // Access/Net Front if (Utils::checkIfContainsAnyOf($userAgent, array('NetFront/3.0', 'ACS-NF/3.0'))) { return 'generic_netfront_ver3'; } if (Utils::checkIfContainsAnyOf($userAgent, array('NetFront/3.1', 'ACS-NF/3.1'))) { return 'generic_netfront_ver3_1'; } if (Utils::checkIfContainsAnyOf($userAgent, array('NetFront/3.2', 'ACS-NF/3.2'))) { return 'generic_netfront_ver3_2'; } if (Utils::checkIfContainsAnyOf($userAgent, array('NetFront/3.3', 'ACS-NF/3.3'))) { return 'generic_netfront_ver3_3'; } if (Utils::checkIfContains($userAgent, 'NetFront/3.4')) { return 'generic_netfront_ver3_4'; } if (Utils::checkIfContains($userAgent, 'NetFront/3.5')) { return 'generic_netfront_ver3_5'; } if (Utils::checkIfContains($userAgent, 'NetFront/4.0')) { return 'generic_netfront_ver4_0'; } // Contains Mozilla/, but not at the beginning of the UA // ie: MOTORAZR V8/R601_G_80.41.17R Mozilla/4.0 (compatible; MSIE 6.0 Linux; MOTORAZR V88.50) Profile/MIDP-2.0 Configuration/CLDC-1.1 Opera 8.50[zh] if (strpos($userAgent, 'Mozilla/') > 0) { return WurflConstants::GENERIC_XHTML; } if (Utils::checkIfContainsAnyOf($userAgent, array('Obigo', 'AU-MIC/2', 'AU-MIC-', 'AU-OBIGO/', 'Teleca Q03B1'))) { return WurflConstants::GENERIC_XHTML; } // DoCoMo if (Utils::checkIfStartsWithAnyOf($userAgent, array('DoCoMo', 'KDDI'))) { return 'docomo_generic_jap_ver1'; } if (Utils::isMobileBrowser($userAgent)) { return WurflConstants::GENERIC_MOBILE; } return WurflConstants::GENERIC; }