/** * @param string $userAgent * * @return string */ public function normalize($userAgent) { $ucbVersion = UcwebU3Handler::getUcBrowserVersion($userAgent); if ($ucbVersion === null) { return $userAgent; } //Android U2K Mobile + Tablet if (Utils::checkIfContains($userAgent, 'Adr ')) { $model = UcwebU3Handler::getUcAndroidModel($userAgent, false); $version = UcwebU3Handler::getUcAndroidVersion($userAgent, false); if ($model !== null && $version !== null) { $prefix = $version . ' U2Android ' . $ucbVersion . ' ' . $model . WurflConstants::RIS_DELIMITER; return $prefix . $userAgent; } } elseif (Utils::checkIfContains($userAgent, 'iPh OS')) { //iPhone U2K 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 ' . $ucbVersion . ' ' . $model . WurflConstants::RIS_DELIMITER; return $prefix . $userAgent; } } elseif (Utils::checkIfContains($userAgent, 'wds')) { //WP7&8 U2K //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 ' . $ucbVersion . ' ' . $model . WurflConstants::RIS_DELIMITER; return $prefix . $userAgent; } } elseif (Utils::checkIfContains($userAgent, 'Symbian')) { //Symbian U2K if (preg_match('/^UCWEB.+; S60 V(\\d); .+; (.+)\\) U2/', $userAgent, $matches)) { $version = 'S60 V' . $matches[1]; $model = $matches[2]; $prefix = $version . ' U2Symbian ' . $ucbVersion . ' ' . $model . WurflConstants::RIS_DELIMITER; return $prefix . $userAgent; } } elseif (Utils::checkIfContains($userAgent, 'Java')) { //Java U2K - check results for regex if (preg_match('/^UCWEB[^\\(]+\\(Java; .+; (.+)\\) U2/', $userAgent, $matches)) { $version = 'Java'; $model = $matches[1]; $prefix = $version . ' U2JavaApp ' . $ucbVersion . ' ' . $model . WurflConstants::RIS_DELIMITER; return $prefix . $userAgent; } } return $userAgent; }
/** * @param string $userAgent * * @return string */ public function normalize($userAgent) { $ucbVersion = UcwebU3Handler::getUcBrowserVersion($userAgent); if ($ucbVersion === null) { return $userAgent; } // Windows Phone goes before Android if (Utils::checkIfContains($userAgent, 'Windows Phone')) { // Apply Version+Model--- matching normalization $model = WindowsPhoneHandler::getWindowsPhoneModel($userAgent); $version = WindowsPhoneHandler::getWindowsPhoneVersion($userAgent); if ($model !== null && $version !== null) { $prefix = $version . ' U3WP ' . $ucbVersion . ' ' . $model . WurflConstants::RIS_DELIMITER; return $prefix . $userAgent; } } elseif (Utils::checkIfContains($userAgent, 'Android')) { // Android U3K Mobile + Tablet // Apply Version+Model--- matching normalization $model = AndroidHandler::getAndroidModel($userAgent, false); $version = AndroidHandler::getAndroidVersion($userAgent, false); if ($model !== null && $version !== null) { $prefix = $version . ' U3Android ' . $ucbVersion . ' ' . $model . WurflConstants::RIS_DELIMITER; return $prefix . $userAgent; } } elseif (Utils::checkIfContains($userAgent, 'iPhone;')) { //iPhone U3K if (preg_match('/iPhone OS (\\d+)(?:_(\\d+))?(?:_\\d+)* like/', $userAgent, $matches)) { $version = $matches[1] . '.' . $matches[2]; $prefix = $version . ' U3iPhone ' . $ucbVersion . WurflConstants::RIS_DELIMITER; return $prefix . $userAgent; } } elseif (Utils::checkIfContains($userAgent, 'iPad')) { //iPad U3K 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 ' . $ucbVersion . ' ' . $model . WurflConstants::RIS_DELIMITER; return $prefix . $userAgent; } } return $userAgent; }