TeraWurflUserAgentMatchers
[ class tree: TeraWurflUserAgentMatchers ] [ index: TeraWurflUserAgentMatchers ] [ all elements ]

Source for file CatchAllUserAgentMatcher.php

Documentation is available at CatchAllUserAgentMatcher.php

  1. <?php
  2. /**
  3.  * Tera_WURFL - PHP MySQL driven WURFL
  4.  * 
  5.  * Tera-WURFL was written by Steve Kamerman, and is based on the
  6.  * Java WURFL Evolution package by Luca Passani and WURFL PHP Tools by Andrea Trassati.
  7.  * This version uses a MySQL database to store the entire WURFL file, multiple patch
  8.  * files, and a persistent caching mechanism to provide extreme performance increases.
  9.  * 
  10.  * @package TeraWurflUserAgentMatchers
  11.  * @author Steve Kamerman <stevekamerman AT gmail.com>
  12.  * @version Stable 2.1.3 $Date: 2010/09/18 15:43:21
  13.  * @license http://www.mozilla.org/MPL/ MPL Vesion 1.1
  14.  */
  15. /**
  16.  * Provides a generic user agent matching technique
  17.  * @package TeraWurflUserAgentMatchers
  18.  */
  19.     
  20.     public static $constantIDs array(
  21.         "opwv_v72_generic",
  22.         "opwv_v7_generic",
  23.         "opwv_v62_generic",
  24.         "opwv_v6_generic",
  25.         "upgui_generic",
  26.         "uptext_generic",
  27.         "nokia_generic_series60",
  28.         "generic_netfront_ver3",
  29.         "generic_netfront_ver3_1",
  30.         "generic_netfront_ver3_2",
  31.         "generic_netfront_ver3_3",
  32.         "generic_netfront_ver3_4",
  33.         "generic_netfront_ver3_5",
  34.         "docomo_generic_jap_ver1",
  35.     );
  36.     public $matcher;
  37.     public $match_type;
  38.     public $match = false;
  39.     
  40.     public function __construct(TeraWurfl $wurfl){
  41.         parent::__construct($wurfl);
  42.         $this->matcher = $this->matcherName();
  43.     }
  44.     public function applyConclusiveMatch($ua{
  45.         $this->match_type = "conclusive";
  46.         $tolerance UserAgentUtils::firstSlash($ua);
  47.         if(self::startsWith($ua,"Mozilla")){
  48.             $tolerance 5;
  49.             $this->wurfl->toLog("Applying CatchAll Conclusive Match: LD $tolerance, UA:\n$ua",LOG_INFO);
  50.             $deviceID $this->ldMatch($ua,$tolerance);
  51.             if($deviceID != WurflConstants::$GENERIC$this->match = true;
  52.             return $deviceID;
  53.         }
  54.         $this->wurfl->toLog("Applying ".get_class($this)." Conclusive Match: RIS with threshold $tolerance",LOG_INFO);
  55.         $deviceID $this->risMatch($ua$tolerance);
  56.         if($deviceID != WurflConstants::$GENERIC$this->match = true;
  57.         return $deviceID;
  58.     }
  59.     public function recoveryMatch($ua){
  60.         // At this point, a recovery match is really no match at all.
  61.         $this->match_type = "none";
  62.         $this->wurfl->toLog("Applying CatchAll Recovery Match",LOG_INFO);
  63.         $this->match = false;
  64.         if(SimpleDesktopUserAgentMatcher::isDesktopBrowser($ua)) return WurflConstants::$GENERIC_WEB_BROWSER;
  65.         //Openwave
  66.         if (self::contains($ua,"UP.Browser/7.2")){
  67.             return "opwv_v72_generic";
  68.         }
  69.         if (self::contains($ua,"UP.Browser/7")){
  70.             return "opwv_v7_generic";
  71.         }
  72.         if (self::contains($ua,"UP.Browser/6.2")){
  73.             return "opwv_v62_generic";
  74.         }
  75.         if (self::contains($ua,"UP.Browser/6")){
  76.             return "opwv_v6_generic";
  77.         }
  78.         if (self::contains($ua,"UP.Browser/5")){
  79.             return "upgui_generic";
  80.         }
  81.         if (self::contains($ua,"UP.Browser/4")){
  82.             return "uptext_generic";
  83.         }
  84.         if (self::contains($ua,"UP.Browser/3")){
  85.             return "uptext_generic";
  86.         }
  87.         
  88.         //Series 60
  89.         if (self::contains($ua,"Series60")){
  90.             return "nokia_generic_series60";
  91.         }
  92.         
  93.         // Access/Net Front
  94.         if(self::contains($ua,"NetFront/3.0")|| self::contains($ua,"ACS-NF/3.0")){
  95.             return "generic_netfront_ver3";
  96.         }
  97.         if(self::contains($ua,"NetFront/3.1")|| self::contains($ua,"ACS-NF/3.1")){
  98.             return "generic_netfront_ver3_1";
  99.         }
  100.         if(self::contains($ua,"NetFront/3.2"|| self::contains($ua,"ACS-NF/3.2")){
  101.             return "generic_netfront_ver3_2";
  102.         }
  103.         if(self::contains($ua,"NetFront/3.3"|| self::contains($ua,"ACS-NF/3.3")){
  104.             return "generic_netfront_ver3_3";
  105.         }
  106.         if(self::contains($ua,"NetFront/3.4")){
  107.             return "generic_netfront_ver3_4";
  108.         }
  109.         if(self::contains($ua,"NetFront/3.5")){
  110.             return "generic_netfront_ver3_5";
  111.         }
  112.         
  113.         // Contains Mozilla/, but not at the beginning of the UA
  114.         // ie: MOTORAZR V8/R601_G_80.41.17R Mozilla/4.0 (compatible; MSIE 6.0 Linux; MOTORAZR V88.50) Profile/MIDP-2.0 Configuration/CLDC-1.1 Opera 8.50[zh]
  115.         if(!self::startsWith($ua,"Mozilla/"&& self::contains($ua,"Mozilla/")){
  116.             return WurflConstants::$GENERIC_XHTML;
  117.         }
  118.         
  119.         
  120.         if(self::contains($ua,array("ObigoInternetBrowser/Q03C","AU-MIC/2","AU-MIC-","AU-OBIGO/","Obigo/Q03","Obigo/Q04","ObigoInternetBrowser/2","Teleca Q03B1"))){
  121.             return WurflConstants::$GENERIC_XHTML;
  122.         }
  123.         
  124.         
  125.         // DoCoMo
  126.         if(self::startsWith($ua,"DoCoMo"|| self::startsWith($ua,"KDDI")){
  127.             return "docomo_generic_jap_ver1";
  128.         }
  129.         return WurflConstants::$GENERIC;
  130.     }
  131.     
  132. }

Documentation generated on Sun, 19 Sep 2010 00:15:48 +0000 by phpDocumentor 1.4.3