Example #1
0
 /**
  * @param string $userAgent
  *
  * @return string
  */
 public function normalize($userAgent)
 {
     // Normalize Android version
     $model = AndroidHandler::getAndroidModel($userAgent, false);
     $version = AndroidHandler::getAndroidVersion($userAgent, false);
     if ($model !== null && $version !== null) {
         $prefix = $version . ' ' . $model . WurflConstants::RIS_DELIMITER;
         return $prefix . $userAgent;
     }
     return $userAgent;
 }
 /**
  * @param string $userAgent
  *
  * @return string
  */
 public function normalize($userAgent)
 {
     $isOperaMobile = Utils::checkIfContains($userAgent, 'Opera Mobi');
     $isOperaTablet = Utils::checkIfContains($userAgent, 'Opera Tablet');
     if ($isOperaMobile || $isOperaTablet) {
         $operaVersion = OperaMobiOrTabletOnAndroidHandler::getOperaOnAndroidVersion($userAgent, false);
         $androidVersion = AndroidHandler::getAndroidVersion($userAgent, false);
         if ($operaVersion !== null && $androidVersion !== null) {
             $operaModel = $isOperaTablet ? 'Opera Tablet' : 'Opera Mobi';
             $prefix = $operaModel . ' ' . $operaVersion . ' Android ' . $androidVersion . WurflConstants::RIS_DELIMITER;
             return $prefix . $userAgent;
         }
     }
     return $userAgent;
 }
 /**
  * @param string $userAgent
  *
  * @return null|string
  */
 public function applyRecoveryMatch($userAgent)
 {
     $isOperaMobi = Utils::checkIfContains($userAgent, 'Opera Mobi');
     $isOperaTablet = Utils::checkIfContains($userAgent, 'Opera Tablet');
     if ($isOperaMobi || $isOperaTablet) {
         $androidVersion = AndroidHandler::getAndroidVersion($userAgent);
         $androidVersionString = str_replace('.', '_', $androidVersion);
         $type = $isOperaTablet ? 'tablet' : 'mobi';
         $deviceID = 'generic_android_ver' . $androidVersionString . '_opera_' . $type;
         if (in_array($deviceID, self::$constantIDs)) {
             return $deviceID;
         } else {
             return $isOperaTablet ? 'generic_android_ver2_1_opera_tablet' : 'generic_android_ver2_0_opera_mobi';
         }
     }
     return WurflConstants::NO_MATCH;
 }
Example #4
0
 /**
  * @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;
 }
Example #5
0
 private function applyRecoveryAndroid($userAgent)
 {
     if (!Utils::checkIfContains($userAgent, 'Android')) {
         return null;
     }
     $version = AndroidHandler::getAndroidVersion($userAgent, false);
     $significant_version = explode('.', $version);
     //We only care about major version
     if (count($significant_version) >= 1) {
         $deviceID = 'generic_ucweb_android_ver' . $significant_version[0];
         if (in_array($deviceID, self::$constantIDs)) {
             return $deviceID;
         }
     }
     return 'generic_ucweb_android_ver1';
 }