Ejemplo n.º 1
0
 public function applyRecoveryMatch($userAgent)
 {
     if (WURFL_Handlers_Utils::checkIfContains($userAgent, 'Windows CE;')) {
         return 'generic_ms_mobile';
     }
     return $this->getDeviceIDFromRIS($userAgent, 6);
 }
Ejemplo n.º 2
0
 /**
  *
  * @param string $userAgent
  * @return string
  */
 function applyRecoveryMatch($userAgent)
 {
     if (WURFL_Handlers_Utils::checkIfContains($userAgent, "Opera")) {
         return "opera";
     }
     return "opwv_v62_generic";
 }
Ejemplo n.º 3
0
 public function canHandle($userAgent)
 {
     if (WURFL_Handlers_Utils::isDesktopBrowser($userAgent)) {
         return false;
     }
     return WURFL_Handlers_Utils::checkIfContains($userAgent, 'KDDI-');
 }
Ejemplo n.º 4
0
 public function normalize($userAgent)
 {
     if (WURFL_Handlers_Utils::checkIfContainsAnyOf($userAgent, array('WPDesktop', 'ZuneWP7')) || WURFL_Handlers_Utils::checkIfContainsAll($userAgent, array('Mozilla/5.0 (Windows NT ', ' ARM;', ' Edge/'))) {
         $model = WURFL_Handlers_WindowsPhoneHandler::getWindowsPhoneDesktopModel($userAgent);
         $version = WURFL_Handlers_WindowsPhoneHandler::getWindowsPhoneDesktopVersion($userAgent);
     } else {
         if (WURFL_Handlers_Utils::checkIfStartsWithAnyOf($userAgent, array('Windows Phone Ad Client', 'WindowsPhoneAdClient'))) {
             $model = WURFL_Handlers_WindowsPhoneHandler::getWindowsPhoneAdClientModel($userAgent);
             $version = WURFL_Handlers_WindowsPhoneHandler::getWindowsPhoneVersion($userAgent);
         } else {
             if (WURFL_Handlers_Utils::checkIfContains($userAgent, 'NativeHost')) {
                 return $userAgent;
             } else {
                 $model = WURFL_Handlers_WindowsPhoneHandler::getWindowsPhoneModel($userAgent);
                 $version = WURFL_Handlers_WindowsPhoneHandler::getWindowsPhoneVersion($userAgent);
             }
         }
     }
     if ($model !== null && $version !== null) {
         // "WP" is for Windows Phone
         $prefix = 'WP' . $version . ' ' . $model . WURFL_Constants::RIS_DELIMITER;
         return $prefix . $userAgent;
     }
     return $userAgent;
 }
Ejemplo n.º 5
0
 /**
  * if the UA contains "iPhone" return "apple_iphone_ver1"
  * if the UA contains "iPod" return "apple_ipod_touch_ver1"
  *
  * @param string $userAgent
  * @return string
  */
 function applyRecoveryMatch($userAgent)
 {
     if (WURFL_Handlers_Utils::checkIfContains($userAgent, "iPhone")) {
         return "apple_iphone_ver1";
     }
     return "apple_ipod_touch_ver1";
 }
Ejemplo n.º 6
0
 public function normalize($userAgent)
 {
     $ucb_version = WURFL_Handlers_UcwebU3Handler::getUcBrowserVersion($userAgent);
     if ($ucb_version === null) {
         return $userAgent;
     }
     //Android U3K Mobile + Tablet
     if (WURFL_Handlers_Utils::checkIfContains($userAgent, 'Android')) {
         // Apply Version+Model--- matching normalization
         $model = WURFL_Handlers_AndroidHandler::getAndroidModel($userAgent, false);
         $version = WURFL_Handlers_AndroidHandler::getAndroidVersion($userAgent, false);
         if ($model !== null && $version !== null) {
             $prefix = "{$version} U3Android {$ucb_version} {$model}" . WURFL_Constants::RIS_DELIMITER;
             return $prefix . $userAgent;
         }
     } else {
         if (WURFL_Handlers_Utils::checkIfContains($userAgent, 'iPhone;')) {
             if (preg_match('/iPhone OS (\\d+)(?:_(\\d+))?(?:_\\d+)* like/', $userAgent, $matches)) {
                 $version = $matches[1] . '.' . $matches[2];
                 $prefix = "{$version} U3iPhone {$ucb_version}" . WURFL_Constants::RIS_DELIMITER;
                 return $prefix . $userAgent;
             }
         } else {
             if (WURFL_Handlers_Utils::checkIfContains($userAgent, 'iPad')) {
                 if (preg_match('/CPU OS (\\d)_?(\\d)?.+like Mac.+; iPad([0-9,]+)\\) AppleWebKit/', $userAgent, $matches)) {
                     $version = $matches[1] . '.' . $matches[2];
                     $model = $matches[3];
                     $prefix = "{$version} U3iPad {$ucb_version} {$model}" . WURFL_Constants::RIS_DELIMITER;
                     return $prefix . $userAgent;
                 }
             }
         }
     }
     return $userAgent;
 }
Ejemplo n.º 7
0
 /**
  * If the User Agent contains "MIB/2.2" or "MIB/BER2.2", 
  * return "mot_mib22_generic"
  *
  * @param string $userAgent
  * @return string
  */
 function applyRecoveryMatch($userAgent)
 {
     if (WURFL_Handlers_Utils::checkIfContains($userAgent, "MIB/2.2") || WURFL_Handlers_Utils::checkIfContains($userAgent, "MIB/BER2.2")) {
         return "mot_mib22_generic";
     }
     return WURFL_Constants::GENERIC;
 }
Ejemplo n.º 8
0
 /**
  * Intercept all UAs Containing AOL and are not mobile browsers
  *
  * @param string $userAgent
  * @return boolean
  */
 public function canHandle($userAgent)
 {
     if (WURFL_Handlers_Utils::isMobileBrowser($userAgent)) {
         return false;
     }
     return WURFL_Handlers_Utils::checkIfContains($userAgent, "AOL");
 }
Ejemplo n.º 9
0
 public function canHandle($userAgent)
 {
     if (WURFL_Handlers_Utils::isDesktopBrowser($userAgent)) {
         return false;
     }
     return WURFL_Handlers_Utils::checkIfStartsWith($userAgent, 'UCWEB') && WURFL_Handlers_Utils::checkIfContains($userAgent, 'UCBrowser');
 }
Ejemplo n.º 10
0
 public function normalize($userAgent)
 {
     // Normalize Android version
     $userAgent = preg_replace('/(Android)[ \\-\\/](\\d\\.\\d)([^; \\/\\)]+)/', '$1 $2', $userAgent);
     // Opera Mobi/Tablet
     $is_opera_mobi = WURFL_Handlers_Utils::checkIfContains($userAgent, 'Opera Mobi');
     $is_opera_tablet = WURFL_Handlers_Utils::checkIfContains($userAgent, 'Opera Tablet');
     if ($is_opera_mobi || $is_opera_tablet) {
         $opera_version = WURFL_Handlers_AndroidHandler::getOperaOnAndroidVersion($userAgent, false);
         $android_version = WURFL_Handlers_AndroidHandler::getAndroidVersion($userAgent, false);
         if ($opera_version !== null && $android_version !== null) {
             $opera_model = $is_opera_tablet ? 'Opera Tablet' : 'Opera Mobi';
             $prefix = $opera_model . ' ' . $opera_version . ' Android ' . $android_version . WURFL_Constants::RIS_DELIMITER;
             return $prefix . $userAgent;
         }
     }
     // Stock Android
     if (!WURFL_Handlers_Utils::checkIfContainsAnyOf($userAgent, $this->skip_normalization)) {
         $model = WURFL_Handlers_AndroidHandler::getAndroidModel($userAgent, false);
         $version = WURFL_Handlers_AndroidHandler::getAndroidVersion($userAgent, false);
         if ($model !== null && $version !== null) {
             $prefix = $version . ' ' . $model . WURFL_Constants::RIS_DELIMITER;
             return $prefix . $userAgent;
         }
     }
     return $userAgent;
 }
 public function canHandle($userAgent)
 {
     if (WURFL_Handlers_Utils::isDesktopBrowser($userAgent)) {
         return false;
     }
     return WURFL_Handlers_Utils::checkIfContains($userAgent, 'Android') && WURFL_Handlers_Utils::checkIfContains($userAgent, 'NetFrontLifeBrowser/2.2');
 }
Ejemplo n.º 12
0
 public function canHandle($userAgent)
 {
     if (WURFL_Handlers_Utils::isMobileBrowser($userAgent)) {
         return false;
     }
     return WURFL_Handlers_Utils::checkIfContains($userAgent, 'Safari') && WURFL_Handlers_Utils::checkIfStartsWithAnyOf($userAgent, array('Mozilla/5.0 (Macintosh', 'Mozilla/5.0 (Windows'));
 }
Ejemplo n.º 13
0
 public function applyRecoveryMatch($userAgent)
 {
     if (WURFL_Handlers_Utils::checkIfContains($userAgent, 'MSIE 10.0')) {
         return 'microsoft_xbox360_ver1_subie10';
     }
     return 'microsoft_xbox360_ver1';
 }
Ejemplo n.º 14
0
 public function applyRecoveryMatch($userAgent)
 {
     if (WURFL_Handlers_Utils::checkIfContains($userAgent, 'Froyo')) {
         return 'generic_android_ver2_2';
     }
     $android_version = self::getAndroidVersion($userAgent);
     $version_string = str_replace('.', '_', $android_version);
     $deviceID = 'generic_android_ver' . $version_string;
     if ($deviceID == 'generic_android_ver2_0') {
         $deviceID = 'generic_android_ver2';
     }
     if ($deviceID == 'generic_android_ver4_0') {
         $deviceID = 'generic_android_ver4';
     }
     if (($android_version < 3.0 || $android_version >= 4.0) && WURFL_Handlers_Utils::checkIfContains($userAgent, 'Safari') && !WURFL_Handlers_Utils::checkIfContains($userAgent, 'Mobile')) {
         // This is probably a tablet (Android 3.x is always a tablet, so it doesn't have a "_tablet" ID)
         if (in_array($deviceID . '_tablet', self::$constantIDs)) {
             return $deviceID . '_tablet';
         }
         return 'generic_android_ver1_5_tablet';
     }
     if (in_array($deviceID, self::$constantIDs)) {
         return $deviceID;
     }
     return 'generic_android';
 }
Ejemplo n.º 15
0
 public function applyRecoveryMatch($userAgent)
 {
     if (WURFL_Handlers_Utils::checkIfContains($userAgent, 'Windows CE;')) {
         return 'generic_ms_mobile';
     }
     return WURFL_Constants::NO_MATCH;
 }
Ejemplo n.º 16
0
 public function applyRecoveryMatch($userAgent)
 {
     if (WURFL_Handlers_Utils::checkIfContains($userAgent, 'Trident/5.0')) {
         return 'generic_ms_phone_os7_5_desktopmode';
     }
     return 'generic_ms_phone_os7_desktopmode';
 }
Ejemplo n.º 17
0
 public function applyRecoveryMatch($userAgent)
 {
     if (WURFL_Handlers_Utils::checkIfContains($userAgent, 'Skyfire/2.')) {
         return 'generic_skyfire_version2';
     }
     return 'generic_skyfire_version1';
 }
Ejemplo n.º 18
0
 public function canHandle($userAgent)
 {
     if (WURFL_Handlers_Utils::isDesktopBrowser($userAgent)) {
         return false;
     }
     return WURFL_Handlers_Utils::checkIfStartsWithAnyOf($userAgent, array('Mot-', 'MOT-', 'MOTO', 'moto')) || WURFL_Handlers_Utils::checkIfContains($userAgent, 'Motorola');
 }
Ejemplo n.º 19
0
 public function canHandle($userAgent)
 {
     if (WURFL_Handlers_Utils::isMobileBrowser($userAgent)) {
         return false;
     }
     return WURFL_Handlers_Utils::checkIfStartsWith($userAgent, 'Mozilla') && WURFL_Handlers_Utils::checkIfContains($userAgent, 'Safari');
 }
Ejemplo n.º 20
0
 public function canHandle($userAgent)
 {
     if (WURFL_Handlers_Utils::isDesktopBrowser($userAgent)) {
         return false;
     }
     return WURFL_Handlers_Utils::checkIfStartsWithAnyOf($userAgent, array('Sanyo', 'SANYO')) || WURFL_Handlers_Utils::checkIfContains($userAgent, 'MobilePhone');
 }
Ejemplo n.º 21
0
 protected function compute()
 {
     $ua = $this->request->userAgentNormalized;
     $ua_original = $this->request->userAgent;
     // ->contains() can take an array
     if (WURFL_Handlers_Utils::checkIfContainsAnyOf($ua, $this->third_party_browsers)) {
         return false;
     }
     // Lollipop implementation of webview adds a ; wv to the UA
     if ($this->device->device_os == "Android" && strpos($ua_original, '; wv) ') !== false) {
         return true;
     }
     // Handling Chrome separately
     if ($this->device->device_os == "Android" && WURFL_Handlers_Utils::checkIfContains($ua, "Chrome") && !WURFL_Handlers_Utils::checkIfContains($ua, "Version")) {
         return false;
     }
     // iOS webview logic is pretty simple
     if ($this->device->device_os == "iOS" && !WURFL_Handlers_Utils::checkIfContains($ua, "Safari")) {
         return true;
     }
     // So is Mac OS X's webview logic
     if ($this->device->advertised_device_os == "Mac OS X" && !WURFL_Handlers_Utils::checkIfContains($ua, "Safari")) {
         return true;
     }
     if ($this->device->device_os == "Android") {
         if ($this->request->originalHeaderExists("HTTP_X_REQUESTED_WITH")) {
             $requested_with = $this->request->getOriginalHeader("HTTP_X_REQUESTED_WITH");
             // The whitelist is an array with X-Requested-With header field values sent by known apps
             if (in_array($requested_with, $this->whitelist)) {
                 return true;
             } else {
                 if (in_array($requested_with, $this->blacklist)) {
                     return false;
                 }
             }
         }
         // Now we handle Android UAs that haven't been eliminated above (No X-Requested-With header and not a third party browser)
         // Make sure to use the original UA and not the normalized one
         if (preg_match("#Mozilla/5.0 \\(Linux;( U;)? Android.*AppleWebKit.*\\(KHTML, like Gecko\\)#", $ua_original)) {
             // Among those UAs in here, we are interested in UAs from apps that contain a webview style UA and add stuff to the beginning or the end of the string(FB, Flipboard etc.)
             // Android >= 4.4
             if ((strpos($ua, 'Android 4.4') !== false || strpos($ua, 'Android 5.') !== false) && !preg_match("#^Mozilla/5.0 \\(Linux; Android [45]\\.[\\d\\.]+; .+ Build/.+\\) AppleWebKit/[\\d\\.+]+ \\(KHTML, like Gecko\\) Version/[\\d\\.]+ Chrome/([\\d]+)\\.[\\d\\.]+? (?:Mobile )?Safari/[\\d\\.+]+\$#", $ua_original)) {
                 if (preg_match("#Chrome/(\\d+)\\.#", $ua, $matches)) {
                     if ($matches[1] < 30) {
                         return false;
                     }
                 }
                 return true;
             }
             // Android < 4.4
             if (preg_match("#Android [1234]\\.[123]#", $ua) && !preg_match("#^Mozilla/5.0 \\(Linux;( U;)? Android [1234]\\.[\\d\\.]+(-update1)?; [a-zA-Z]+-[a-zA-Z]+; .+ Build/.+\\) AppleWebKit/[\\d\\.+]+ \\(KHTML, like Gecko\\) Version/[\\d\\.]+ (Mobile )?Safari/[\\d\\.+]+\$#", $ua_original)) {
                 return true;
             }
         }
         return false;
     }
     // Return is_app_webview = false for everything else
     return false;
 }
Ejemplo n.º 22
0
 public function applyRecoveryMatch($userAgent)
 {
     if (WURFL_Handlers_Utils::checkIfContains($userAgent, 'Tablet')) {
         return 'generic_ubuntu_touch_os_tablet';
     } else {
         return 'generic_ubuntu_touch_os';
     }
 }
Ejemplo n.º 23
0
 public function applyRecoveryMatch($userAgent)
 {
     if (WURFL_Handlers_Utils::checkIfContains($userAgent, "Series30Plus")) {
         return 'nokia_generic_series30plus';
     } else {
         return 'nokia_generic_series40_ovibrosr';
     }
 }
Ejemplo n.º 24
0
 public function normalize($userAgent)
 {
     $ucb_version = WURFL_Handlers_UcwebU3Handler::getUcBrowserVersion($userAgent);
     if ($ucb_version === null) {
         return $userAgent;
     }
     //Android U2K Mobile + Tablet
     if (WURFL_Handlers_Utils::checkIfContains($userAgent, 'Adr ')) {
         $model = WURFL_Handlers_UcwebU3Handler::getUcAndroidModel($userAgent, false);
         $version = WURFL_Handlers_UcwebU3Handler::getUcAndroidVersion($userAgent, false);
         if ($model !== null && $version !== null) {
             $prefix = "{$version} U2Android {$ucb_version} {$model}" . WURFL_Constants::RIS_DELIMITER;
             return $prefix . $userAgent;
         }
     } else {
         if (WURFL_Handlers_Utils::checkIfContains($userAgent, 'iPh OS')) {
             if (preg_match('/iPh OS (\\d)_?(\\d)?[ _\\d]?.+; iPh(\\d), ?(\\d)\\) U2/', $userAgent, $matches)) {
                 $version = $matches[1] . '.' . $matches[2];
                 $model = $matches[3] . '.' . $matches[4];
                 $prefix = "{$version} U2iPhone {$ucb_version} {$model}" . WURFL_Constants::RIS_DELIMITER;
                 return $prefix . $userAgent;
             }
         } else {
             if (WURFL_Handlers_Utils::checkIfContains($userAgent, 'wds')) {
                 //Add spaces and normalize
                 $userAgent = preg_replace('|;(?! )|', '; ', $userAgent);
                 if (preg_match('/^UCWEB.+; wds (\\d+)\\.([\\d]+);.+; ([ A-Za-z0-9_-]+); ([ A-Za-z0-9_-]+)\\) U2/', $userAgent, $matches)) {
                     $version = $matches[1] . '.' . $matches[2];
                     $model = $matches[3] . '.' . $matches[4];
                     //Standard normalization stuff from WP matcher
                     $model = str_replace('_blocked', '', $model);
                     $model = preg_replace('/(NOKIA.RM-.+?)_.*/', '$1', $model, 1);
                     $prefix = "{$version} U2WindowsPhone {$ucb_version} {$model}" . WURFL_Constants::RIS_DELIMITER;
                     return $prefix . $userAgent;
                 }
             } else {
                 if (WURFL_Handlers_Utils::checkIfContains($userAgent, 'Symbian')) {
                     if (preg_match('/^UCWEB.+; S60 V(\\d); .+; (.+)\\) U2/', $userAgent, $matches)) {
                         $version = 'S60 V' . $matches[1];
                         $model = $matches[2];
                         $prefix = "{$version} U2Symbian {$ucb_version} {$model}" . WURFL_Constants::RIS_DELIMITER;
                         return $prefix . $userAgent;
                     }
                 } else {
                     if (WURFL_Handlers_Utils::checkIfContains($userAgent, 'Java')) {
                         if (preg_match('/^UCWEB[^\\(]+\\(Java; .+; (.+)\\) U2/', $userAgent, $matches)) {
                             $version = 'Java';
                             $model = $matches[1];
                             $prefix = "{$version} U2JavaApp {$ucb_version} {$model}" . WURFL_Constants::RIS_DELIMITER;
                             return $prefix . $userAgent;
                         }
                     }
                 }
             }
         }
     }
     return $userAgent;
 }
Ejemplo n.º 25
0
 function applyRecoveryMatch($userAgent)
 {
     foreach ($this->operaMinis as $key => $deviceId) {
         if (WURFL_Handlers_Utils::checkIfContains($userAgent, $key)) {
             return $deviceId;
         }
     }
     return WURFL_Constants::GENERIC;
 }
Ejemplo n.º 26
0
 /**
  *  If the User Agent contains the String Nokia, apply TokensMatcher strategy
  *  using the Nokia Tokens Provider else
  *	Apply then LD with a threshold of 3
  *
  * @param string $userAgent
  * @return string
  */
 function lookForMatchingUserAgent($userAgent)
 {
     $userAgents = array_keys($this->userAgentsWithDeviceID);
     if (WURFL_Handlers_Utils::checkIfContains($userAgent, "Nokia")) {
         $tollearnce = WURFL_Handlers_Utils::indexOfOrLength($userAgent, "/", strpos($userAgent, "Nokia"));
         return parent::applyRisWithTollerance($userAgents, $userAgent, $tollearnce);
     }
     return WURFL_Handlers_Utils::ldMatch($userAgents, $userAgent, self::TOLLERANCE);
 }
Ejemplo n.º 27
0
 public function canHandle($userAgent)
 {
     if (WURFL_Handlers_Utils::isMobileBrowser($userAgent)) {
         return false;
     }
     if (WURFL_Handlers_Utils::checkIfContainsAnyOf($userAgent, array('Tablet', 'Sony', 'Novarra', 'Opera'))) {
         return false;
     }
     return WURFL_Handlers_Utils::checkIfContains($userAgent, 'Firefox');
 }
Ejemplo n.º 28
0
 protected function compute()
 {
     $ua = $this->request->userAgent;
     // Control cap, "controlcap_is_robot" is checked before this function is called
     if ($this->request->originalHeaderExists("HTTP_ACCEPT_ENCODING") && WURFL_Handlers_Utils::checkIfContains($ua, "Trident/") && !WURFL_Handlers_Utils::checkIfContains($this->request->getOriginalHeader("HTTP_ACCEPT_ENCODING"), "deflate")) {
         return true;
     }
     // Check against standard bot list
     return WURFL_Handlers_Utils::isRobot($this->request->getOriginalHeader('HTTP_USER_AGENT'));
 }
Ejemplo n.º 29
0
 public function applyRecoveryMatch($userAgent)
 {
     $map = array('Kindle/1' => 'amazon_kindle_ver1', 'Kindle/2' => 'amazon_kindle2_ver1', 'Kindle/3' => 'amazon_kindle3_ver1', 'Kindle Fire' => 'amazon_kindle_fire_ver1', 'Silk' => 'amazon_kindle_fire_ver1');
     foreach ($map as $keyword => $id) {
         if (WURFL_Handlers_Utils::checkIfContains($userAgent, $keyword)) {
             return $id;
         }
     }
     return 'generic_amazon_kindle';
 }
Ejemplo n.º 30
0
 public function canHandle($userAgent)
 {
     if (WURFL_Handlers_Utils::isMobileBrowser($userAgent)) {
         return false;
     }
     if (WURFL_Handlers_Utils::checkIfContainsAnyOf($userAgent, array('Opera', 'armv', 'MOTO', 'BREW'))) {
         return false;
     }
     return WURFL_Handlers_Utils::checkIfStartsWith($userAgent, 'Mozilla') && WURFL_Handlers_Utils::checkIfContains($userAgent, 'MSIE');
 }