Ejemplo n.º 1
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.º 2
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;
 }