Exemplo n.º 1
0
 /**
  * Is the given user agent very likely to be a desktop browser
  * @param string $userAgent
  * @return bool
  */
 public static function isDesktopBrowserHeavyDutyAnalysis($userAgent)
 {
     // Check Smart TV keywords
     if (WURFL_Handlers_Utils::isSmartTV($userAgent)) {
         return false;
     }
     // Chrome
     if (WURFL_Handlers_Utils::checkIfContains($userAgent, 'Chrome') && !WURFL_Handlers_Utils::checkIfContainsAnyOf($userAgent, array('Android', 'Ventana'))) {
         return true;
     }
     // Check mobile keywords
     if (WURFL_Handlers_Utils::isMobileBrowser($userAgent)) {
         return false;
     }
     if (WURFL_Handlers_Utils::checkIfContains($userAgent, 'PPC')) {
         return false;
     }
     // PowerPC; not always mobile, but we'll kick it out
     // Firefox;  fennec is already handled in the WURFL_Constants::$MOBILE_BROWSERS keywords
     if (WURFL_Handlers_Utils::checkIfContains($userAgent, 'Firefox') && !WURFL_Handlers_Utils::checkIfContains($userAgent, 'Tablet')) {
         return true;
     }
     // Safari
     if (preg_match('#^Mozilla/5\\.0 \\((?:Macintosh|Windows)[^\\)]+\\) AppleWebKit/[\\d\\.]+ \\(KHTML, like Gecko\\) Version/[\\d\\.]+ Safari/[\\d\\.]+$#', $userAgent)) {
         return true;
     }
     // Opera Desktop
     if (WURFL_Handlers_Utils::checkIfStartsWith($userAgent, 'Opera/9.80 (Windows NT', 'Opera/9.80 (Macintosh')) {
         return true;
     }
     // Check desktop keywords
     if (WURFL_Handlers_Utils::isDesktopBrowser($userAgent)) {
         return true;
     }
     // Internet Explorer 11
     if (preg_match('/^Mozilla\\/5\\.0 \\(Windows NT.+?Trident.+?; rv:\\d\\d\\.\\d+\\)/', $userAgent)) {
         return true;
     }
     // Internet Explorer 9 or 10
     if (preg_match('/^Mozilla\\/5\\.0 \\(compatible; MSIE (9|10)\\.0; Windows NT \\d\\.\\d/', $userAgent)) {
         return true;
     }
     // Internet Explorer <9
     if (preg_match('/^Mozilla\\/4\\.0 \\(compatible; MSIE \\d\\.\\d; Windows NT \\d\\.\\d/', $userAgent)) {
         return true;
     }
     return false;
 }
Exemplo n.º 2
0
 public function canHandle($userAgent)
 {
     return WURFL_Handlers_Utils::isSmartTV($userAgent);
 }