Ejemplo n.º 1
0
 public function applyConclusiveMatch($userAgent)
 {
     $tolerance = WURFL_Handlers_Utils::ordinalIndexOf($userAgent, '/', 2);
     if ($tolerance === -1) {
         //  DoCoMo/2.0 F01A(c100;TB;W24H17)
         $tolerance = WURFL_Handlers_Utils::indexOfOrLength('(', $userAgent);
     }
     return $this->getDeviceIDFromRIS($userAgent, $tolerance);
 }
Ejemplo n.º 2
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.º 3
0
 public function applyConclusiveMatch($userAgent)
 {
     $idx = strpos($userAgent, 'MobilePhone');
     if ($idx !== false) {
         $tolerance = WURFL_Handlers_Utils::indexOfOrLength($userAgent, '/', $idx);
     } else {
         $tolerance = WURFL_Handlers_Utils::firstSlash($userAgent);
     }
     return $this->getDeviceIDFromRIS($userAgent, $tolerance);
 }
Ejemplo n.º 4
0
 public function applyRecoveryMatch($userAgent)
 {
     if (WURFL_Handlers_Utils::checkIfStartsWith($userAgent, 'SAMSUNG')) {
         $tolerance = 8;
         return $this->getDeviceIDFromLD($userAgent, $tolerance);
     } else {
         $tolerance = WURFL_Handlers_Utils::indexOfOrLength($userAgent, '/', strpos($userAgent, 'Samsung'));
         return $this->getDeviceIDFromRIS($userAgent, $tolerance);
     }
 }
Ejemplo n.º 5
0
 public function applyConclusiveMatch($userAgent)
 {
     // The tolerance is after UCWEB7, not before
     $find = 'UCWEB7';
     $tolerance = WURFL_Handlers_Utils::indexOfOrLength($userAgent, $find) + strlen($find);
     if ($tolerance > strlen($userAgent)) {
         $tolerance = strlen($userAgent);
     }
     $this->getDeviceIDFromRIS($userAgent, $tolerance);
 }
Ejemplo n.º 6
0
 private function tolerance($userAgent)
 {
     if (WURFL_Handlers_Utils::checkIfStartsWith($userAgent, "KDDI/")) {
         return WURFL_Handlers_Utils::secondSlash($userAgent);
     }
     if (WURFL_Handlers_Utils::checkIfStartsWith($userAgent, "KDDI")) {
         return WURFL_Handlers_Utils::firstSlash($userAgent);
     }
     return WURFL_Handlers_Utils::indexOfOrLength($userAgent, ")");
 }
Ejemplo n.º 7
0
 public function applyConclusiveMatch($userAgent)
 {
     if (WURFL_Handlers_Utils::checkIfContains($userAgent, 'BB10')) {
         $tolerance = WURFL_Handlers_Utils::indexOfOrLength($userAgent, ')');
     } elseif (WURFL_Handlers_Utils::checkIfStartsWith($userAgent, 'Mozilla/4')) {
         $tolerance = WURFL_Handlers_Utils::secondSlash($userAgent);
     } elseif (WURFL_Handlers_Utils::checkIfStartsWith($userAgent, 'Mozilla/5')) {
         $tolerance = WURFL_Handlers_Utils::ordinalIndexOf($userAgent, ';', 3);
     } elseif (WURFL_Handlers_Utils::checkIfStartsWith($userAgent, 'PlayBook')) {
         $tolerance = WURFL_Handlers_Utils::firstCloseParen($userAgent);
     } else {
         $tolerance = WURFL_Handlers_Utils::firstSlash($userAgent);
     }
     return $this->getDeviceIDFromRIS($userAgent, $tolerance);
 }
Ejemplo n.º 8
0
 public function applyConclusiveMatch($userAgent)
 {
     $matches = array();
     if (preg_match('/^Mozilla\\/5\\.0 \\(.+?Trident.+?; rv:(\\d\\d)\\.(\\d+)\\)/', $userAgent, $matches) || preg_match('/^Mozilla\\/[45]\\.0 \\(compatible; MSIE (\\d+)\\.(\\d+);/', $userAgent, $matches)) {
         $major = (int) $matches[1];
         $minor = (int) $matches[2];
         // MSIE 5.5 is handled specifically
         if ($major == 5 && $minor == 5) {
             return 'msie_5_5';
         }
         // Look for version in constant ID array
         if (array_key_exists($major, self::$constantIDs)) {
             return self::$constantIDs[$major];
         }
     }
     return $this->getDeviceIDFromRIS($userAgent, WURFL_Handlers_Utils::indexOfOrLength($userAgent, 'Trident'));
 }
Ejemplo n.º 9
0
 public function applyConclusiveMatch($userAgent)
 {
     if (WURFL_Handlers_Utils::checkIfContains($userAgent, ' Build/')) {
         return $this->getDeviceIDFromRIS($userAgent, WURFL_Handlers_Utils::indexOfOrLength($userAgent, ' Build/'));
     }
     $prefixes = array('Opera/9.80 (J2ME/MIDP; Opera Mini/5' => 'uabait_opera_mini_android_v50', 'Opera/9.80 (Android; Opera Mini/5.0' => 'uabait_opera_mini_android_v50', 'Opera/9.80 (Android; Opera Mini/5.1' => 'uabait_opera_mini_android_v51');
     foreach ($prefixes as $prefix => $defaultID) {
         if (WURFL_Handlers_Utils::checkIfStartsWith($userAgent, $prefix)) {
             // If RIS returns a non-generic match, return it, else, return the default
             $tolerance = strlen($prefix);
             $deviceID = $this->getDeviceIDFromRIS($userAgent, $tolerance);
             if ($deviceID == WURFL_Constants::NO_MATCH) {
                 return $defaultID;
             }
             return $deviceID;
         }
     }
     return WURFL_Constants::NO_MATCH;
 }
Ejemplo n.º 10
0
 public function applyConclusiveMatch($userAgent)
 {
     $model = self::getOperaModel($userAgent, false);
     if ($model !== null) {
         $prefix = $model . WURFL_Constants::RIS_DELIMITER;
         $userAgent = $prefix . $userAgent;
         return $this->getDeviceIDFromRIS($userAgent, strlen($prefix));
     }
     $opera_mini_idx = WURFL_Handlers_Utils::indexOfOrLength($userAgent, 'Opera Mini');
     if ($opera_mini_idx !== false) {
         // Match up to the first '.' after 'Opera Mini'
         $tolerance = strpos($userAgent, '.', $opera_mini_idx);
         if ($tolerance !== false) {
             // +1 to match just after the '.'
             return $this->getDeviceIDFromRIS($userAgent, $tolerance + 1);
         }
     }
     $tolerance = WURFL_Handlers_Utils::firstSlash($userAgent);
     return $this->getDeviceIDFromRIS($userAgent, $tolerance);
 }
	function lookForMatchingUserAgent($userAgent) {
		$tollerance = WURFL_Handlers_Utils::indexOfOrLength ( $userAgent, ";", strpos ( $userAgent, "SPV" ) );
		return parent::applyRisWithTollerance ( array_keys ( $this->userAgentsWithDeviceID ), $userAgent, $tollerance );
	}
Ejemplo n.º 12
0
 public function applyConclusiveMatch($userAgent)
 {
     $skyfire_idx = strpos($userAgent, 'Skyfire');
     // Matches the first decimal point after the Skyfire keyword: Skyfire/2.0
     return $this->getDeviceIDFromRIS($userAgent, WURFL_Handlers_Utils::indexOfOrLength($userAgent, '.', $skyfire_idx));
 }
Ejemplo n.º 13
0
 /**
  * Lowest char index of the first instance of any of the $needles found in $userAgent, starting at $startIndex;
  * if no match is found, the length of the string is returned
  * @param string $userAgent haystack
  * @param array $needles Array of (string)needles to search for in $userAgent
  * @param int $startingIndex Char index for start of search
  * @return int Char index of left-most match or length of string
  */
 public static function indexOfAnyOrLength($userAgent, $needles = array(), $startingIndex = 0)
 {
     if (count($needles) === 0) {
         return strlen($userAgent);
     }
     $min = strlen($userAgent);
     foreach ($needles as $needle) {
         $index = WURFL_Handlers_Utils::indexOfOrLength($userAgent, $needle, $startingIndex);
         if ($index < $min) {
             $min = $index;
         }
     }
     return $min;
 }
Ejemplo n.º 14
0
 public function applyConclusiveMatch($userAgent)
 {
     $tolerance = WURFL_Handlers_Utils::indexOfOrLength($userAgent, '/', stripos($userAgent, 'LG'));
     return $this->getDeviceIDFromRIS($userAgent, $tolerance);
 }
Ejemplo n.º 15
0
 public function applyConclusiveMatch($userAgent)
 {
     return $this->getDeviceIDFromRIS($userAgent, WURFL_Handlers_Utils::indexOfOrLength($userAgent, '.'));
 }
Ejemplo n.º 16
0
 public function applyConclusiveMatch($userAgent)
 {
     $opera_idx = strpos($userAgent, 'Opera');
     $tolerance = WURFL_Handlers_Utils::indexOfOrLength($userAgent, '.', $opera_idx);
     return $this->getDeviceIDFromRIS($userAgent, $tolerance);
 }
Ejemplo n.º 17
0
 public function applyConclusiveMatch($userAgent)
 {
     // Look for RIS delimited UAs first
     $delimiter_idx = strpos($userAgent, WURFL_Constants::RIS_DELIMITER);
     if ($delimiter_idx !== false) {
         $tolerance = $delimiter_idx + strlen(WURFL_Constants::RIS_DELIMITER);
         return $this->getDeviceIDFromRIS($userAgent, $tolerance);
     }
     // Opera Mini
     if (WURFL_Handlers_Utils::checkIfContains($userAgent, 'Opera Mini')) {
         if (WURFL_Handlers_Utils::checkIfContains($userAgent, ' Build/')) {
             $tolerance = WURFL_Handlers_Utils::indexOfOrLength($userAgent, ' Build/');
             return $this->getDeviceIDFromRIS($userAgent, $tolerance);
         }
         $prefixes = array('Opera/9.80 (J2ME/MIDP; Opera Mini/5' => 'uabait_opera_mini_android_v50', 'Opera/9.80 (Android; Opera Mini/5.0' => 'uabait_opera_mini_android_v50', 'Opera/9.80 (Android; Opera Mini/5.1' => 'uabait_opera_mini_android_v51');
         foreach ($prefixes as $prefix => $defaultID) {
             if (WURFL_Handlers_Utils::checkIfStartsWith($userAgent, $prefix)) {
                 return $this->getDeviceIDFromRIS($userAgent, strlen($prefix));
             }
         }
     }
     // Opera Mobi
     if (WURFL_Handlers_Utils::checkIfContains($userAgent, 'Opera Mobi')) {
         $tolerance = WURFL_Handlers_Utils::secondSlash($userAgent);
         return $this->getDeviceIDFromRIS($userAgent, $tolerance);
     }
     // Opera Tablet
     if (WURFL_Handlers_Utils::checkIfContains($userAgent, 'Opera Tablet')) {
         $tolerance = WURFL_Handlers_Utils::secondSlash($userAgent);
         return $this->getDeviceIDFromRIS($userAgent, $tolerance);
     }
     // Fennec
     if (WURFL_Handlers_Utils::checkIfContainsAnyOf($userAgent, array('Fennec', 'Firefox'))) {
         $tolerance = WURFL_Handlers_Utils::indexOfOrLength($userAgent, ')');
         return $this->getDeviceIDFromRIS($userAgent, $tolerance);
     }
     // UCWEB7
     if (WURFL_Handlers_Utils::checkIfContains($userAgent, 'UCWEB7')) {
         // The tolerance is after UCWEB7, not before
         $find = 'UCWEB7';
         $tolerance = strpos($userAgent, $find) + strlen($find);
         if ($tolerance > strlen($userAgent)) {
             $tolerance = strlen($userAgent);
         }
         return $this->getDeviceIDFromRIS($userAgent, $tolerance);
     }
     // NetFrontLifeBrowser
     if (WURFL_Handlers_Utils::checkIfContains($userAgent, 'NetFrontLifeBrowser/2.2')) {
         $find = 'NetFrontLifeBrowser/2.2';
         $tolerance = strpos($userAgent, $find) + strlen($find);
         if ($tolerance > strlen($userAgent)) {
             $tolerance = strlen($userAgent);
         }
         return $this->getDeviceIDFromRIS($userAgent, $tolerance);
     }
     // Standard RIS Matching
     $tolerance = min(WURFL_Handlers_Utils::indexOfOrLength($userAgent, ' Build/'), WURFL_Handlers_Utils::indexOfOrLength($userAgent, ' AppleWebKit'));
     return $this->getDeviceIDFromRIS($userAgent, $tolerance);
 }
Ejemplo n.º 18
0
 public function applyRecoveryMatch($userAgent)
 {
     $tolerance = WURFL_Handlers_Utils::indexOfOrLength($userAgent, '/', strpos($userAgent, 'Samsung'));
     return $this->getDeviceIDFromRIS($userAgent, $tolerance);
 }