当前位置: 首页>>代码示例>>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;未经允许,请勿转载。