Exemple #1
0
 /**
  * @param string $userAgent
  *
  * @return bool
  */
 public function canHandle($userAgent)
 {
     if (Utils::isDesktopBrowser($userAgent)) {
         return false;
     }
     return Utils::checkIfStartsWith($userAgent, 'Mozilla') && Utils::checkIfContains($userAgent, 'UCBrowser');
 }
Exemple #2
0
 /**
  * @param string $userAgent
  *
  * @return bool
  */
 public function canHandle($userAgent)
 {
     if (Utils::isDesktopBrowser($userAgent)) {
         return false;
     }
     return Utils::checkIfStartsWith($userAgent, 'portalmmm');
 }
 /**
  * Attempt to find a conclusive match for the given $userAgent
  *
  * @param string $userAgent
  *
  * @return string Matching WURFL deviceID
  */
 public function applyConclusiveMatch($userAgent)
 {
     if (Utils::checkIfContains($userAgent, 'GoogleImageProxy')) {
         return 'google_image_proxy';
     }
     if (Utils::checkIfStartsWith($userAgent, 'Mozilla')) {
         $tolerance = Utils::firstCloseParen($userAgent);
     } else {
         $tolerance = Utils::firstSlash($userAgent);
     }
     return $this->getDeviceIDFromRIS($userAgent, $tolerance);
 }
Exemple #4
0
 /**
  * @param string $userAgent
  *
  * @return bool
  */
 public function canHandle($userAgent)
 {
     if (Utils::isMobileBrowser($userAgent)) {
         return false;
     }
     if (Utils::checkIfStartsWith($userAgent, 'Mozilla') === false) {
         return false;
     }
     if (Utils::checkIfContainsAnyOf($userAgent, array('Opera', 'armv', 'MOTO', 'BREW'))) {
         return false;
     }
     // Edge 12 signature
     $hasEdgeMode = Utils::checkIfContains($userAgent, ' Edge/');
     // IE 11 signature
     $hasTridentRv = Utils::checkIfContains($userAgent, 'Trident') && Utils::checkIfContains($userAgent, 'rv:');
     // IE < 11 signature
     $hasMsie = Utils::checkIfContains($userAgent, 'MSIE');
     return $hasMsie || $hasTridentRv || $hasEdgeMode;
 }
Exemple #5
0
 public function applyConclusiveMatch($userAgent)
 {
     if (Utils::checkIfContains($userAgent, 'BB10')) {
         $tolerance = Utils::indexOfOrLength($userAgent, ')');
     } else {
         if (Utils::checkIfStartsWith($userAgent, 'Mozilla/4')) {
             $tolerance = Utils::secondSlash($userAgent);
         } else {
             if (Utils::checkIfStartsWith($userAgent, 'Mozilla/5')) {
                 $tolerance = Utils::ordinalIndexOf($userAgent, ';', 3);
             } elseif (Utils::checkIfStartsWith($userAgent, 'PlayBook')) {
                 $tolerance = Utils::firstCloseParen($userAgent);
             } else {
                 $tolerance = Utils::firstSlash($userAgent);
             }
         }
     }
     return $this->getDeviceIDFromRIS($userAgent, $tolerance);
 }
Exemple #6
0
 /**
  * @param string $userAgent
  *
  * @return string
  */
 public function normalize($userAgent)
 {
     // Repair Opera user agents using fake version 9.80
     // Normalize: Opera/9.80 (X11; Linux x86_64; U; sv) Presto/2.9.168 Version/11.50
     // Into: Opera/11.50 (X11; Linux x86_64; U; sv) Presto/2.9.168 Version/11.50
     if (Utils::checkIfStartsWith($userAgent, 'Opera/9.80')) {
         if (preg_match('#Version/(\\d+\\.\\d+)#', $userAgent, $matches)) {
             $userAgent = str_replace('Opera/9.80', 'Opera/' . $matches[1], $userAgent);
         }
         //Match to the '.' in the Opera version number
         return $userAgent;
     }
     //Normalize Opera v15 and above UAs, that say OPR, into 'Opera/version UA' format used above
     if (preg_match('#OPR/(\\d+\\.\\d+)#', $userAgent, $matches)) {
         $prefix = 'Opera/' . $matches[1] . ' ';
         $userAgent = $prefix . $userAgent;
     }
     return $userAgent;
 }
 /**
  * @param string $userAgent
  *
  * @return null|string
  */
 public function applyConclusiveMatch($userAgent)
 {
     if (Utils::checkIfContains($userAgent, ' Build/')) {
         return $this->getDeviceIDFromRIS($userAgent, 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 (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 === WurflConstants::NO_MATCH) {
                 return $defaultID;
             }
             return $deviceID;
         }
     }
     return WurflConstants::NO_MATCH;
 }
Exemple #8
0
 /**
  * @param string $userAgent
  *
  * @return bool
  */
 public function canHandle($userAgent)
 {
     return Utils::checkIfStartsWith($userAgent, 'Mozilla/5.0 (Macintosh') && Utils::checkIfContains($userAgent, 'HTC');
 }
Exemple #9
0
 /**
  * @param string $userAgent
  *
  * @return bool
  */
 public function canHandle($userAgent)
 {
     return Utils::checkIfStartsWith($userAgent, 'Mozilla') && Utils::checkIfContains($userAgent, 'Tizen');
 }