當前位置: 首頁>>代碼示例>>PHP>>正文


PHP UserAgentUtils類代碼示例

本文整理匯總了PHP中UserAgentUtils的典型用法代碼示例。如果您正苦於以下問題:PHP UserAgentUtils類的具體用法?PHP UserAgentUtils怎麽用?PHP UserAgentUtils使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了UserAgentUtils類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: applyConclusiveMatch

 public function applyConclusiveMatch($ua)
 {
     $matches = array();
     if (preg_match('/^Mozilla\\/4\\.0 \\(compatible; MSIE (\\d)\\.(\\d);/', $ua, $matches)) {
         if (TeraWurflConfig::$SIMPLE_DESKTOP_ENGINE_ENABLE) {
             return WurflConstants::$GENERIC_WEB_BROWSER;
         }
         switch ($matches[1]) {
             // cases are intentionally out of sequnce for performance
             case 7:
                 return 'msie_7';
                 break;
             case 8:
                 return 'msie_8';
                 break;
             case 6:
                 return 'msie_6';
                 break;
             case 4:
                 return 'msie_4';
                 break;
             case 5:
                 return $matches[2] == 5 ? 'msie_5_5' : 'msie_5';
                 break;
             default:
                 return 'msie';
                 break;
         }
     }
     $ua = preg_replace('/( \\.NET CLR [\\d\\.]+;?| Media Center PC [\\d\\.]+;?| OfficeLive[a-zA-Z0-9\\.\\d]+;?| InfoPath[\\.\\d]+;?)/', '', $ua);
     $tolerance = UserAgentUtils::firstSlash($ua);
     $this->wurfl->toLog("Applying " . get_class($this) . " Conclusive Match: RIS with threshold {$tolerance}", LOG_INFO);
     return $this->risMatch($ua, $tolerance);
 }
開發者ID:vuong93st,項目名稱:w-game,代碼行數:34,代碼來源:MSIEUserAgentMatcher.php

示例2: applyConclusiveMatch

 public function applyConclusiveMatch($ua)
 {
     $clean_ua = $ua;
     if (self::contains($ua, "/SN") && !self::contains($ua, "XXXXXXXXXXXX")) {
         //not using RegEx for the time being
         $start_idx = strpos($ua, "/SN") + 3;
         $sub_str = substr($ua, $start_idx);
         $end_idx = strpos($sub_str, " ");
         if ($end_idx !== false && $sub_str != "" && strlen($sub_str) > $end_idx) {
             $num_digits = strlen($sub_str) - $end_idx;
             $new_ua = substr($ua, 0, $start_idx);
             for ($i = 0; $i < $end_idx; $i++) {
                 $new_ua .= "X";
             }
             $new_ua .= substr($ua, $end_idx);
             $clean_ua = $new_ua;
         }
     }
     $tolerance = UserAgentUtils::firstSlash($clean_ua);
     $this->wurfl->toLog("Applying " . get_class($this) . " Conclusive Match: RIS with threshold {$tolerance}", LOG_INFO);
     $match = $this->risMatch($clean_ua, $tolerance);
     if ($match == WurflConstants::$GENERIC) {
         $this->wurfl->toLog("Applying " . get_class($this) . " Conclusive Match: LD", LOG_INFO);
         return $this->ldMatch($ua);
     }
     return $match;
 }
開發者ID:vallejos,項目名稱:samples,代碼行數:27,代碼來源:VodafoneUserAgentMatcher.php

示例3: isDesktopBrowser

 /**
  * Is the given user agent very likely to be a desktop browser
  * @param String User agent
  * @return Bool
  */
 public static function isDesktopBrowser($ua)
 {
     if (UserAgentUtils::isMobileBrowser($ua)) {
         return false;
     }
     if (self::contains($ua, array('HTC', 'PPC', 'Nintendo'))) {
         return false;
     }
     // Firefox
     if (self::contains($ua, "Firefox") && !self::contains($ua, 'Tablet')) {
         return true;
     }
     if (UserAgentUtils::isDesktopBrowser($ua)) {
         return true;
     }
     if (self::startsWith($ua, 'Opera/')) {
         return true;
     }
     if (self::regexContains($ua, array('/^Mozilla\\/5\\.0 \\(compatible; MSIE 9\\.0; Windows NT \\d\\.\\d/', '/^Mozilla\\/4\\.0 \\(compatible; MSIE \\d\\.\\d; Windows NT \\d\\.\\d/'))) {
         return true;
     }
     if (self::contains($ua, array("Chrome", "yahoo.com", "google.com", "Comcast"))) {
         return true;
     }
     return false;
 }
開發者ID:vallejos,項目名稱:samples,代碼行數:31,代碼來源:SimpleDesktopUserAgentMatcher.php

示例4: applyConclusiveMatch

 public function applyConclusiveMatch($ua)
 {
     $deviceId = '';
     $tolerance = UserAgentUtils::indexOfOrLength($ua, ';', 0);
     $this->wurfl->toLog("Applying " . get_class($this) . " Conclusive Match: RIS with threshold  {$tolerance}", LOG_INFO);
     $deviceId = $this->risMatch($ua, $tolerance);
     return $deviceId;
 }
開發者ID:vuong93st,項目名稱:w-game,代碼行數:8,代碼來源:AppleUserAgentMatcher.php

示例5: parseDevice

 protected function parseDevice()
 {
     if (count($this->pendingInsert) > 0) {
         foreach ($this->pendingInsert as $device) {
             $matcher = UserAgentFactory::userAgentType($this->wurfl, $device['user_agent']);
             $uatable = TeraWurflConfig::$TABLE_PREFIX . '_' . $matcher;
         }
         $this->pendingInsert = array();
     }
     $this->pendingInsert[$this->xml->getAttribute('id')] = array();
     $device =& $this->pendingInsert[$this->xml->getAttribute('id')];
     $device = array('id' => $this->xml->getAttribute('id'), 'user_agent' => UserAgentUtils::cleanUserAgent($this->xml->getAttribute('user_agent')), 'fall_back' => $this->xml->getAttribute('fall_back'));
     if ($this->xml->getAttribute('actual_device_root')) {
         $device['actual_device_root'] = $this->xml->getAttribute('actual_device_root') == "true" ? 1 : 0;
     }
     $groupdevice = '';
     $groupname = '';
     $filtering = TeraWurflConfig::$CAPABILITY_FILTER ? true : false;
     $includegroup = false;
     while ($this->xml->read()) {
         if ($this->xml->nodeType != XMLReader::ELEMENT) {
             continue;
         }
         // recurse back into this function for the rest of the devices
         switch ($this->xml->name) {
             case "device":
                 $this->parseDevice();
                 break;
             case "group":
                 $groupname = $this->xml->getAttribute('id');
                 if ($filtering && $this->enabled($this->xml->getAttribute('id'))) {
                     $includegroup = true;
                 } else {
                     $includegroup = false;
                     continue;
                 }
                 $device[$groupname] = array();
                 break;
             case "capability":
                 if (!$filtering || $filtering && $includegroup) {
                     // the groupdevice array must already exist
                     $device[$groupname][$this->xml->getAttribute('name')] = self::cleanValue($this->xml->getAttribute('value'));
                     continue;
                 }
                 if ($filtering && !$includegroup && $this->enabled($this->xml->getAttribute('name'))) {
                     // the groupdevice array might already exists
                     if (!array_key_exists($groupname, $device)) {
                         $device[$groupname] = array();
                     }
                     $device[$groupname][$this->xml->getAttribute('name')] = self::cleanValue($this->xml->getAttribute('value'));
                     continue;
                 }
                 break;
         }
     }
 }
開發者ID:vuong93st,項目名稱:w-game,代碼行數:56,代碼來源:TeraWurflXMLParser_XMLReader_LowMem.php

示例6: applyConclusiveMatch

 public function applyConclusiveMatch($ua)
 {
     if (self::startsWith($ua, "BlackBerry;")) {
         $tolerance = UserAgentUtils::ordinalIndexOf($ua, ';', 3);
     } else {
         $tolerance = UserAgentUtils::firstSlash($ua);
     }
     $this->wurfl->toLog("Applying " . get_class($this) . " Conclusive Match: RIS with threshold  {$tolerance}", LOG_INFO);
     return $this->risMatch($ua, $tolerance);
 }
開發者ID:vallejos,項目名稱:samples,代碼行數:10,代碼來源:BlackBerryUserAgentMatcher.php

示例7: applyConclusiveMatch

 public function applyConclusiveMatch($ua)
 {
     if (self::startsWith($ua, 'KDDI/')) {
         $tolerance = UserAgentUtils::secondSlash($ua);
     } else {
         $tolerance = UserAgentUtils::firstSlash($ua);
     }
     $this->wurfl->toLog("Applying " . get_class($this) . " Conclusive Match: RIS with threshold {$tolerance}", LOG_INFO);
     return $this->risMatch($ua, $tolerance);
 }
開發者ID:anubhaBhargava,項目名稱:OpenRecommender,代碼行數:10,代碼來源:KddiUserAgentMatcher.php

示例8: recoveryMatch

 public function recoveryMatch($ua)
 {
     if (self::startsWith($ua, "SAMSUNG")) {
         $tolerance = 8;
         return $this->ldMatch($ua, $tolerance);
     } else {
         $tolerance = UserAgentUtils::indexOfOrLength($ua, '/', strpos($ua, 'Samsung'));
         return $this->risMatch($ua, $tolerance);
     }
 }
開發者ID:anubhaBhargava,項目名稱:OpenRecommender,代碼行數:10,代碼來源:SamsungUserAgentMatcher.php

示例9: applyConclusiveMatch

 public function applyConclusiveMatch($ua)
 {
     if (self::contains($ua, "MobilePhone")) {
         $tolerance = UserAgentUtils::indexOfOrLength($ua, '/', strpos($ua, "MobilePhone"));
     } else {
         $tolerance = UserAgentUtils::firstSlash($ua);
     }
     $this->wurfl->toLog("Applying " . get_class($this) . " Conclusive Match: RIS with threshold {$tolerance}", LOG_INFO);
     return $this->risMatch($ua, $tolerance);
 }
開發者ID:vallejos,項目名稱:samples,代碼行數:10,代碼來源:SanyoUserAgentMatcher.php

示例10: applyConclusiveMatch

 public function applyConclusiveMatch($ua)
 {
     // firstSlash() - 1 because some UAs have revisions that aren't getting detected properly:
     // SonyEricssonW995a/R1FA Browser/NetFront/3.4 Profile/MIDP-2.1 Configuration/CLDC-1.1 JavaPlatform/JP-8.4.3
     $tolerance = UserAgentUtils::firstSlash($ua) - 1;
     $this->wurfl->toLog("Applying " . get_class($this) . " Conclusive Match: RIS with threshold {$tolerance}", LOG_INFO);
     if (self::startsWith($ua, "SonyEricsson")) {
         return $this->risMatch($ua, $tolerance);
     }
     $tolerance = UserAgentUtils::secondSlash($ua);
     return $this->risMatch($ua, $tolerance);
 }
開發者ID:anubhaBhargava,項目名稱:OpenRecommender,代碼行數:12,代碼來源:SonyEricssonUserAgentMatcher.php

示例11: applyConclusiveMatch

 public function applyConclusiveMatch($ua)
 {
     $deviceId = '';
     if (UserAgentUtils::numSlashes($ua) >= 2) {
         $tolerance = UserAgentUtils::secondSlash($ua);
     } else {
         //  DoCoMo/2.0 F01A(c100;TB;W24H17)
         $tolerance = UserAgentUtils::firstOpenParen($ua);
     }
     $this->wurfl->toLog("Applying " . get_class($this) . " Conclusive Match: RIS with threshold {$tolerance}", LOG_INFO);
     $deviceId = $this->risMatch($ua, $tolerance);
     return $deviceId;
 }
開發者ID:vallejos,項目名稱:samples,代碼行數:13,代碼來源:DoCoMoUserAgentMatcher.php

示例12: applyConclusiveMatch

 public function applyConclusiveMatch($ua)
 {
     $deviceId = '';
     if (self::startsWith($ua, 'Apple')) {
         if (($tolerance = UserAgentUtils::ordinalIndexOf($ua, ' ', 3)) == -1) {
             $tolerance = strlen($ua);
         }
     } else {
         $tolerance = UserAgentUtils::indexOfOrLength($ua, ';', 0);
     }
     $this->wurfl->toLog("Applying " . get_class($this) . " Conclusive Match: RIS with threshold  {$tolerance}", LOG_INFO);
     $deviceId = $this->risMatch($ua, $tolerance);
     return $deviceId;
 }
開發者ID:anubhaBhargava,項目名稱:OpenRecommender,代碼行數:14,代碼來源:AppleUserAgentMatcher.php

示例13: applyConclusiveMatch

 public function applyConclusiveMatch($ua)
 {
     if (UserAgentUtils::checkIfContains($ua, "Opera/10")) {
         return "opera_10";
     } elseif (UserAgentUtils::checkIfContains($ua, "Opera/9")) {
         return "opera_9";
     } elseif (UserAgentUtils::checkIfContains($ua, "Opera/8")) {
         return "opera_8";
     } elseif (UserAgentUtils::checkIfContains($ua, "Opera/7")) {
         return "opera_7";
     }
     $tolerance = 5;
     $this->wurfl->toLog("Applying " . get_class($this) . " Conclusive Match: LD with threshold {$tolerance}", LOG_INFO);
     return $this->ldMatch($ua, $tolerance);
 }
開發者ID:vuong93st,項目名稱:w-game,代碼行數:15,代碼來源:OperaUserAgentMatcher.php

示例14: recoveryMatch

 public function recoveryMatch($ua)
 {
     if (UserAgentUtils::checkIfContains($ua, 'Froyo')) {
         return 'generic_android_ver2_2';
     }
     if (preg_match('#Android[\\s/](\\d)\\.(\\d)#', $ua, $matches)) {
         $version = 'generic_android_ver' . $matches[1] . '_' . $matches[2];
         if ($version == 'generic_android_ver2_0') {
             $version = 'generic_android_ver2';
         }
         if (in_array($version, self::$constantIDs)) {
             return $version;
         }
     }
     return 'generic_android';
 }
開發者ID:vallejos,項目名稱:samples,代碼行數:16,代碼來源:AndroidUserAgentMatcher.php

示例15: applyConclusiveMatch

 public function applyConclusiveMatch($ua)
 {
     $this->match_type = "conclusive";
     $tolerance = UserAgentUtils::firstSlash($ua);
     if (self::startsWith($ua, "Mozilla")) {
         $tolerance = 5;
         $this->wurfl->toLog("Applying CatchAll Conclusive Match: LD {$tolerance}, UA:\n{$ua}", LOG_INFO);
         $deviceID = $this->ldMatch($ua, $tolerance);
         if ($deviceID != WurflConstants::$GENERIC) {
             $this->match = true;
         }
         return $deviceID;
     }
     $this->wurfl->toLog("Applying " . get_class($this) . " Conclusive Match: RIS with threshold {$tolerance}", LOG_INFO);
     $deviceID = $this->risMatch($ua, $tolerance);
     if ($deviceID != WurflConstants::$GENERIC) {
         $this->match = true;
     }
     return $deviceID;
 }
開發者ID:vallejos,項目名稱:samples,代碼行數:20,代碼來源:CatchAllUserAgentMatcher.php


注:本文中的UserAgentUtils類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。