Пример #1
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;
 }
Пример #2
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;
 }
Пример #3
0
 public function normalize($userAgent)
 {
     $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;
 }
Пример #4
0
 public function applyRecoveryMatch($userAgent)
 {
     $android_version_string = str_replace('.', '_', WURFL_Handlers_AndroidHandler::getAndroidVersion($userAgent));
     $deviceID = 'generic_android_ver' . $android_version_string . '_ucweb';
     if (in_array($deviceID, self::$constantIDs)) {
         return $deviceID;
     } else {
         return 'generic_android_ver2_0_ucweb';
     }
 }
Пример #5
0
 public function applyRecoveryMatch($userAgent)
 {
     // Windows Phone
     if (WURFL_Handlers_Utils::checkIfContains($userAgent, 'Windows Phone')) {
         $version = WURFL_Handlers_WindowsPhoneHandler::getWindowsPhoneVersion($userAgent);
         $significant_version = explode('.', $version);
         if ($significant_version[0] !== null) {
             if ($significant_version[1] === 0) {
                 $deviceID = 'generic_ms_phone_os' . $significant_version[0] . '_subuaucweb';
             } else {
                 $deviceID = 'generic_ms_phone_os' . $significant_version[0] . '_' . $significant_version[1] . '_subuaucweb';
             }
             if (in_array($deviceID, self::$constantIDs)) {
                 return $deviceID;
             }
         }
         return 'generic_ms_phone_os8_subuaucweb';
     } else {
         if (WURFL_Handlers_Utils::checkIfContains($userAgent, 'Android')) {
             $version = WURFL_Handlers_AndroidHandler::getAndroidVersion($userAgent, false);
             $significant_version = explode('.', $version);
             if ($significant_version[0] !== null) {
                 $deviceID = 'generic_ucweb_android_ver' . $significant_version[0];
                 if (in_array($deviceID, self::$constantIDs)) {
                     return $deviceID;
                 }
             }
             return 'generic_ucweb_android_ver1';
         } else {
             if (WURFL_Handlers_Utils::checkIfContains($userAgent, 'iPhone;')) {
                 if (preg_match('/iPhone OS (\\d+)(?:_\\d+)?.+ like/', $userAgent, $matches)) {
                     $significant_version = $matches[1];
                     $deviceID = 'apple_iphone_ver' . $significant_version . '_subuaucweb';
                     if (in_array($deviceID, self::$constantIDs)) {
                         return $deviceID;
                     }
                 }
                 return 'apple_iphone_ver1_subuaucweb';
             } else {
                 if (WURFL_Handlers_Utils::checkIfContains($userAgent, 'iPad')) {
                     if (preg_match('/CPU OS (\\d+)(?:_\\d+)?.+like Mac/', $userAgent, $matches)) {
                         $significant_version = $matches[1];
                         $deviceID = 'apple_ipad_ver1_sub' . $significant_version . '_subuaucweb';
                         if (in_array($deviceID, self::$constantIDs)) {
                             return $deviceID;
                         }
                     }
                     return 'apple_ipad_ver1_subuaucweb';
                 }
             }
         }
     }
     return 'generic_ucweb';
 }
Пример #6
0
 public function normalize($userAgent)
 {
     if (WURFL_Handlers_Utils::checkIfContainsAll($userAgent, array('Android', 'Kindle Fire'))) {
         $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;
 }
Пример #7
0
 public function normalize($userAgent)
 {
     $userAgent = preg_replace('/(Android)[ \\-](\\d\\.\\d)([^; \\/\\)]+)/', '$1 $2', $userAgent);
     $skip_normalization = array('Opera Mini', 'Opera Mobi', 'Opera Tablet', 'Fennec', 'Firefox', 'UCWEB7', 'NetFrontLifeBrowser/2.2');
     if (!WURFL_Handlers_Utils::checkIfContainsAnyOf($userAgent, $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 normalize($userAgent)
 {
     $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_OperaMobiOrTabletOnAndroidHandler::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;
         }
     }
     return $userAgent;
 }
 public function applyRecoveryMatch($userAgent)
 {
     $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) {
         $android_version = WURFL_Handlers_AndroidHandler::getAndroidVersion($userAgent);
         $android_version_string = str_replace('.', '_', $android_version);
         $type = $is_opera_tablet ? 'tablet' : 'mobi';
         $deviceID = 'generic_android_ver' . $android_version_string . '_opera_' . $type;
         if (in_array($deviceID, self::$constantIDs)) {
             return $deviceID;
         } else {
             return $is_opera_tablet ? 'generic_android_ver2_1_opera_tablet' : 'generic_android_ver2_0_opera_mobi';
         }
     }
     return WURFL_Constants::NO_MATCH;
 }
Пример #10
0
 public function applyRecoveryMatch($userAgent)
 {
     //Android U3K Mobile + Tablet. This will also handle UCWEB7 recovery and point it to the UCWEB generic IDs.
     if (WURFL_Handlers_Utils::checkIfContains($userAgent, 'Android')) {
         // Apply Version+Model--- matching normalization
         $version = WURFL_Handlers_AndroidHandler::getAndroidVersion($userAgent, false);
         $significant_version = explode('.', $version);
         if ($significant_version[0] !== null) {
             $deviceID = 'generic_ucweb_android_ver' . $significant_version[0];
             if (in_array($deviceID, self::$constantIDs)) {
                 return $deviceID;
             }
         }
         return 'generic_ucweb_android_ver1';
     } else {
         if (WURFL_Handlers_Utils::checkIfContains($userAgent, 'iPhone;')) {
             if (preg_match('/iPhone OS (\\d+)(?:_\\d+)?.+ like/', $userAgent, $matches)) {
                 $significant_version = $matches[1];
                 $deviceID = 'apple_iphone_ver' . $significant_version . '_subuaucweb';
                 if (in_array($deviceID, self::$constantIDs)) {
                     return $deviceID;
                 }
             }
             return 'apple_iphone_ver1_subuaucweb';
         } else {
             if (WURFL_Handlers_Utils::checkIfContains($userAgent, 'iPad')) {
                 if (preg_match('/CPU OS (\\d+)(?:_\\d+)?.+like Mac/', $userAgent, $matches)) {
                     $significant_version = $matches[1];
                     $deviceID = 'apple_ipad_ver1_sub' . $significant_version . '_subuaucweb';
                     if (in_array($deviceID, self::$constantIDs)) {
                         return $deviceID;
                     }
                 }
                 return 'apple_ipad_ver1_subuaucweb';
             }
         }
     }
     return 'generic_ucweb';
 }