Changeset 28068


Ignore:
Timestamp:
Apr 4, 2014, 6:20:34 AM (6 years ago)
Author:
rvelices
Message:

bug 3058: update mdetect for windows 8 mobile etc ...

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/mdetect.php

    r18967 r28068  
    22
    33/* *******************************************
    4 // Copyright 2010-2012, Anthony Hand
     4// Copyright 2010-2013, Anthony Hand
    55//
    6 // File version date: April 23, 2012
    7 //              Update:
    8 //              - Updated DetectAmazonSilk(): Fixed an issue in the detection logic.
     6// File version 2013.10.27 (October 27, 2013)
     7//      Updates:
     8//      - Made minor update to the InitDeviceScan. Should check Tablet Tier first, then iPhone Tier, then Quick Mobile.
    99//
    10 // File version date: April 22, 2012 - Second update
    11 //              Update: To address additional Kindle issues...
    12 //              - Updated DetectRichCSS(): Excluded e-Ink Kindle devices.
    13 //              - Created DetectAmazonSilk(): Created to detect Kindle Fire devices in Silk mode.
    14 //              - Updated DetectMobileQuick(): Updated to include e-Ink Kindle devices and the Kindle Fire in Silk mode. 
     10// File version 2013.08.01 (August 1, 2013)
     11//      Updates:
     12//      - Updated DetectMobileQuick(). Moved the 'Exclude Tablets' logic to the top of the method to fix a logic bug.
    1513//
    16 // File version date: April 11, 2012
    17 //              Update:
    18 //              - Added a new variable for the new BlackBerry Curve Touch (9380): deviceBBCurveTouch.
    19 //              - Updated DetectBlackBerryTouch() to support the new BlackBerry Curve Touch (9380).
    20 //              - Updated DetectKindle(): Added the missing 'this' class identifier for the DetectAndroid() call.
    21 //
    22 // File version date: January 21, 2012
    23 //              Update:
    24 //              - Added the constructor method per new features in PHP 5.0: __construct().
    25 //              - Moved Windows Phone 7 to the iPhone Tier. WP7.5's IE 9-based browser is good enough now. 
    26 //              - Added a new variable for 2 versions of the new BlackBerry Bold Touch (9900 and 9930): deviceBBBoldTouch.
    27 //              - Updated DetectBlackBerryTouch() to support the 2 versions of the new BlackBerry Bold Touch (9900 and 9930).
    28 //              - Updated DetectKindle() to focus on eInk devices only. The Kindle Fire should be detected as a regular Android device.
    29 //
    30 // File version date: August 22, 2011
    31 //              Update:
    32 //              - Updated DetectAndroidTablet() to fix a bug introduced in the last fix! The true/false returns were mixed up.
    33 //
    34 // File version date: August 16, 2011
    35 //              Update:
    36 //              - Updated DetectAndroidTablet() to exclude Opera Mini, which was falsely reporting as running on a tablet device when on a phone.
     14// File version 2013.07.13 (July 13, 2013)
     15//      Updates:
     16//      - Added support for Tizen: variable and DetectTizen().
     17//      - Added support for Meego: variable and DetectMeego().
     18//      - Added support for Windows Phone 8: variable and DetectWindowsPhone8().
     19//      - Added a generic Windows Phone method: DetectWindowsPhone().
     20//      - Added support for BlackBerry 10 OS: variable and DetectBlackBerry10Phone().
     21//      - Added support for PlayStation Vita handheld: variable and DetectGamingHandheld().
     22//      - Updated DetectTierIphone(). Added Tizen; updated the Windows Phone, BB10, and PS Vita support.
     23//      - Updated DetectWindowsMobile(). Uses generic DetectWindowsPhone() method rather than WP7.
     24//      - Updated DetectSmartphone(). Uses the IsTierIphone variable.
     25//      - Updated DetectSonyMylo() with more efficient code.
     26//      - Removed DetectGarminNuvifone() from DetectTierIphone(). How many are left in market in 2013? It is detected as a RichCSS Tier device.
     27//      - Removed the deviceXoom variable. It was unused.
     28//      - Added detection support for the Obigo mobile browser to DetectMobileQuick().
    3729//
    3830//
     
    8173   var $false = 0;
    8274
    83    //Let's store values for quickly accessing the same info multiple times.
    84    var $isIphone = 0; //Stores whether the device is an iPhone or iPod Touch.
    85    var $isAndroidPhone = 0; //Stores whether the device is a (small-ish) Android phone or media player.
    86    var $isTierTablet = 0; //Stores whether is the Tablet (HTML5-capable, larger screen) tier of devices.
    87    var $isTierIphone = 0; //Stores whether is the iPhone tier of devices.
    88    var $isTierRichCss = 0; //Stores whether the device can probably support Rich CSS, but JavaScript support is not assumed. (e.g., newer BlackBerry, Windows Mobile)
    89    var $isTierGenericMobile = 0; //Stores whether it is another mobile device, which cannot be assumed to support CSS or JS (eg, older BlackBerry, RAZR)
     75   //Let's store values for quickly accessing the same info multiple times. InitCompleted
     76   var $initCompleted = 0; //Stores whether we're currently initializing the most popular functions.
     77   var $isWebkit = 0; //Stores the result of DetectWebkit()
     78   var $isMobilePhone = 0; //Stores the result of DetectMobileQuick()
     79   var $isIphone = 0; //Stores the result of DetectIphone()
     80   var $isAndroid = 0; //Stores the result of DetectAndroid()
     81   var $isAndroidPhone = 0; //Stores the result of DetectAndroidPhone()
     82   var $isTierTablet = 0; //Stores the result of DetectTierTablet()
     83   var $isTierIphone = 0; //Stores the result of DetectTierIphone()
     84   var $isTierRichCss = 0; //Stores the result of DetectTierRichCss()
     85   var $isTierGenericMobile = 0; //Stores the result of DetectTierOtherPhones()
    9086
    9187   //Initialize some initial smartphone string variables.
    9288   var $engineWebKit = 'webkit';
     89
    9390   var $deviceIphone = 'iphone';
    9491   var $deviceIpod = 'ipod';
     
    9895   var $deviceAndroid = 'android';
    9996   var $deviceGoogleTV = 'googletv';
    100    var $deviceXoom = 'xoom'; //Motorola Xoom
    10197   var $deviceHtcFlyer = 'htc_flyer'; //HTC Flyer
    10298   
    103    var $deviceNuvifone = 'nuvifone'; //Garmin Nuvifone
    104 
    105    var $deviceSymbian = 'symbian';
    106    var $deviceS60 = 'series60';
    107    var $deviceS70 = 'series70';
    108    var $deviceS80 = 'series80';
    109    var $deviceS90 = 'series90';
    110    
    11199   var $deviceWinPhone7 = 'windows phone os 7';
     100   var $deviceWinPhone8 = 'windows phone 8';
    112101   var $deviceWinMob = 'windows ce';
    113102   var $deviceWindows = 'windows';
     
    117106   
    118107   var $deviceBB = 'blackberry';   
     108   var $deviceBB10 = 'bb10'; //For the new BB 10 OS
    119109   var $vndRIM = 'vnd.rim'; //Detectable when BB devices emulate IE or Firefox
    120110   var $deviceBBStorm = 'blackberry95';  //Storm 1 and 2
     
    127117   var $deviceBBPlaybook = 'playbook'; //PlayBook tablet
    128118   
     119   var $deviceSymbian = 'symbian';
     120   var $deviceS60 = 'series60';
     121   var $deviceS70 = 'series70';
     122   var $deviceS80 = 'series80';
     123   var $deviceS90 = 'series90';
     124   
    129125   var $devicePalm = 'palm';
    130126   var $deviceWebOS = 'webos'; //For Palm's line of WebOS devices
    131127   var $deviceWebOShp = 'hpwos'; //For HP's line of WebOS devices
    132    
    133128   var $engineBlazer = 'blazer'; //Old Palm browser
    134129   var $engineXiino = 'xiino'; //Another old Palm
    135130   
     131   var $deviceNuvifone = 'nuvifone'; //Garmin Nuvifone
     132   var $deviceBada = 'bada'; //Samsung's Bada OS
     133   var $deviceTizen = 'tizen'; //Tizen OS
     134   var $deviceMeego = 'meego'; //Meego OS
     135
    136136   var $deviceKindle = 'kindle'; //Amazon Kindle, eInk one
    137    var $engineSilk = 'silk'; //Amazon's accelerated Silk browser for Kindle Fire
     137   var $engineSilk = 'silk-accelerated'; //Amazon's accelerated Silk browser for Kindle Fire
    138138   
    139139   //Initialize variables for mobile-specific content.
     
    147147   var $deviceHiptop = 'hiptop';
    148148   var $devicePlaystation = 'playstation';
     149   var $devicePlaystationVita = 'vita';
    149150   var $deviceNintendoDs = 'nitro';
    150151   var $deviceNintendo = 'nintendo';
     
    160161   var $uplink = 'up.link';
    161162   var $engineTelecaQ = 'teleca q'; //a modern feature phone browser
     163   var $engineObigo = 'obigo'; //W 10 is a modern feature phone browser
    162164   
    163165   var $devicePda = 'pda'; //some devices report themselves as PDAs
     
    177179   var $manuSamsung1 = "sec-sgh";
    178180   var $manuSony = "sony";
    179    var $manuHtc = "htc"; //Popular Android and WinMo manufacturer
     181   var $manuHtc = "htc";
    180182
    181183   //In some UserAgents, the only clue is the operator.
     
    192194   function __construct()
    193195   {
    194                 $this->uagent_info();
     196        $this->uagent_info();
    195197   }
    196198
     
    200202   function uagent_info()
    201203   {
    202                 $this->useragent = isset($_SERVER['HTTP_USER_AGENT'])?strtolower($_SERVER['HTTP_USER_AGENT']):'';
    203                 $this->httpaccept = isset($_SERVER['HTTP_ACCEPT'])?strtolower($_SERVER['HTTP_ACCEPT']):'';
    204                
    205                 //Let's initialize some values to save cycles later.
    206                 $this->InitDeviceScan();
     204        $this->useragent = isset($_SERVER['HTTP_USER_AGENT'])?strtolower($_SERVER['HTTP_USER_AGENT']):'';
     205        $this->httpaccept = isset($_SERVER['HTTP_ACCEPT'])?strtolower($_SERVER['HTTP_ACCEPT']):'';
     206               
     207        //Let's initialize some values to save cycles later.
     208        $this->InitDeviceScan();
    207209   }
    208210   
     
    211213   function InitDeviceScan()
    212214   {
    213         global $isIphone, $isAndroidPhone, $isTierTablet, $isTierIphone;
     215        //Save these properties to speed processing
     216        global $isWebkit, $isIphone, $isAndroid, $isAndroidPhone;
     217        $this->isWebkit = $this->DetectWebkit();
     218        $this->isIphone = $this->DetectIphone();
     219        $this->isAndroid = $this->DetectAndroid();
     220        $this->isAndroidPhone = $this->DetectAndroidPhone();
    214221       
    215         //We'll use these 4 variables to speed other processing. They're super common.
    216         $this->isIphone = $this->DetectIphoneOrIpod();
    217         $this->isAndroidPhone = $this->DetectAndroidPhone();
    218         $this->isTierIphone = $this->DetectTierIphone();
    219         $this->isTierTablet = $this->DetectTierTablet();
     222        //These tiers are the most useful for web development
     223        global $isMobilePhone, $isTierTablet, $isTierIphone;
     224        $this->isTierTablet = $this->DetectTierTablet(); //Do first
     225        $this->isTierIphone = $this->DetectTierIphone(); //Do second
     226        $this->isMobilePhone = $this->DetectMobileQuick(); //Do third
    220227       
    221         //Optional: Comment these out if you don't need them.
     228        //Optional: Comment these out if you NEVER use them.
    222229        global $isTierRichCss, $isTierGenericMobile;
    223230        $this->isTierRichCss = $this->DetectTierRichCss();
    224231        $this->isTierGenericMobile = $this->DetectTierOtherPhones();
     232       
     233        $this->initCompleted = $this->true;
    225234   }
    226235
     
    244253   function DetectIphone()
    245254   {
     255      if ($this->initCompleted == $this->true ||
     256          $this->isIphone == $this->true)
     257         return $this->isIphone;
     258     
    246259      if (stripos($this->useragent, $this->deviceIphone) > -1)
    247260      {
     
    284297   {
    285298       //We repeat the searches here because some iPods may report themselves as an iPhone, which would be okay.
    286        if (stripos($this->useragent, $this->deviceIphone) > -1 ||
    287            stripos($this->useragent, $this->deviceIpod) > -1)
     299      if ($this->DetectIphone() == $this->true ||
     300             $this->DetectIpod() == $this->true)
    288301         return $this->true;
    289302      else
     
    308321   function DetectAndroid()
    309322   {
    310       if ((stripos($this->useragent, $this->deviceAndroid) > -1) ||
    311          ($this->DetectGoogleTV() == $this->true))
     323      if ($this->initCompleted == $this->true ||
     324          $this->isAndroid == $this->true)
     325         return $this->isAndroid;
     326
     327      if ((stripos($this->useragent, $this->deviceAndroid) > -1)
     328          || ($this->DetectGoogleTV() == $this->true))
    312329         return $this->true;
    313330      //Special check for the HTC Flyer 7" tablet
     
    325342   function DetectAndroidPhone()
    326343   {
     344      if ($this->initCompleted == $this->true ||
     345          $this->isAndroidPhone == $this->true)
     346         return $this->isAndroidPhone;
     347
    327348      if (($this->DetectAndroid() == $this->true) &&
    328                 (stripos($this->useragent, $this->mobile) > -1))
    329          return $this->true;
     349                (stripos($this->useragent, $this->mobile) > -1))
     350         return $this->true;
     351     
    330352      //Special check for Android phones with Opera Mobile. They should report here.
    331353      if (($this->DetectOperaAndroidPhone() == $this->true))
     
    333355      //Special check for the HTC Flyer 7" tablet. It should report here.
    334356      if ((stripos($this->useragent, $this->deviceHtcFlyer) > -1))
    335          return $this->true;
     357         return $this->true;
     358     
    336359      else
    337360         return $this->false;
     
    367390   {
    368391      if (($this->DetectAndroid() == $this->true) &&
    369                 ($this->DetectWebkit() == $this->true))
     392                ($this->DetectWebkit() == $this->true))
    370393         return $this->true;
    371394      else
     
    387410   function DetectWebkit()
    388411   {
     412      if ($this->initCompleted == $this->true ||
     413          $this->isWebkit == $this->true)
     414         return $this->isWebkit;
     415
    389416      if (stripos($this->useragent, $this->engineWebKit) > -1)
    390417         return $this->true;
     
    395422
    396423   //**************************
    397    // Detects if the current browser is the Nokia S60 Open Source Browser.
    398    function DetectS60OssBrowser()
    399    {
    400       //First, test for WebKit, then make sure it's either Symbian or S60.
    401       if ($this->DetectWebkit() == $this->true)
    402       {
    403         if (stripos($this->useragent, $this->deviceSymbian) > -1 ||
    404             stripos($this->useragent, $this->deviceS60) > -1)
    405         {
    406            return $this->true;
    407         }
    408         else
    409            return $this->false;
    410       }
    411       else
    412          return $this->false;
    413    }
    414    
    415    //**************************
    416    // Detects if the current device is any Symbian OS-based device,
    417    //   including older S60, Series 70, Series 80, Series 90, and UIQ,
    418    //   or other browsers running on these devices.
    419    function DetectSymbianOS()
    420    {
    421        if (stripos($this->useragent, $this->deviceSymbian) > -1 ||
    422            stripos($this->useragent, $this->deviceS60) > -1 ||
    423            stripos($this->useragent, $this->deviceS70) > -1 ||
    424            stripos($this->useragent, $this->deviceS80) > -1 ||
    425            stripos($this->useragent, $this->deviceS90) > -1)
    426          return $this->true;
    427       else
    428          return $this->false;
    429    }
    430 
    431    //**************************
    432    // Detects if the current browser is a
    433    // Windows Phone 7 device.
     424   // Detects if the current browser is EITHER a
     425   // Windows Phone 7.x OR 8 device.
     426   function DetectWindowsPhone()
     427   {
     428      if (($this->DetectWindowsPhone8() == $this->true)
     429                        || ($this->DetectWindowsPhone7() == $this->true))
     430         return $this->true;
     431      else
     432         return $this->false;
     433   }
     434   
     435   //**************************
     436   // Detects a Windows Phone 7.x device (in mobile browsing mode).
    434437   function DetectWindowsPhone7()
    435438   {
     
    439442         return $this->false;
    440443   }
     444   
     445   //**************************
     446   // Detects a Windows Phone 8 device (in mobile browsing mode).
     447   function DetectWindowsPhone8()
     448   {
     449      if (stripos($this->useragent, $this->deviceWinPhone8) > -1)
     450         return $this->true;
     451      else
     452         return $this->false;
     453   }
    441454
    442455   //**************************
    443456   // Detects if the current browser is a Windows Mobile device.
    444    // Excludes Windows Phone 7 devices.
     457   // Excludes Windows Phone 7 and later devices.
    445458   // Focuses on Windows Mobile 6.xx and earlier.
    446459   function DetectWindowsMobile()
    447460   {
    448       if ($this->DetectWindowsPhone7() == $this->true)
    449          return $this->false;
     461      if ($this->DetectWindowsPhone() == $this->true)
     462         return $this->false;
     463     
    450464      //Most devices use 'Windows CE', but some report 'iemobile'
    451465      //  and some older ones report as 'PIE' for Pocket IE.
     
    455469         return $this->true;
    456470      //Test for Windows Mobile PPC but not old Macintosh PowerPC.
    457           if (stripos($this->useragent, $this->devicePpc) > -1
    458                   && !(stripos($this->useragent, $this->deviceMacPpc) > 1))
     471          if (stripos($this->useragent, $this->devicePpc) > -1
     472                  && !(stripos($this->useragent, $this->deviceMacPpc) > 1))
    459473         return $this->true;
    460474      //Test for certain Windwos Mobile-based HTC devices.
     
    471485   //**************************
    472486   // Detects if the current browser is any BlackBerry device.
    473    // Includes the PlayBook.
     487   // Includes BB10 OS, but excludes the PlayBook.
    474488   function DetectBlackBerry()
    475489   {
    476490       if ((stripos($this->useragent, $this->deviceBB) > -1) ||
    477491          (stripos($this->httpaccept, $this->vndRIM) > -1))
     492         return $this->true;
     493      if ($this->DetectBlackBerry10Phone() == $this->true)
     494         return $this->true;       
     495       else
     496         return $this->false;
     497   }
     498   
     499   //**************************
     500   // Detects if the current browser is a BlackBerry 10 OS phone.
     501   // Excludes tablets.
     502   function DetectBlackBerry10Phone()
     503   {
     504       if ((stripos($this->useragent, $this->deviceBB10) > -1) &&
     505          (stripos($this->useragent, $this->mobile) > -1))
    478506         return $this->true;
    479507       else
     
    499527   {
    500528      if (($this->DetectBlackBerry() == $this->true) &&
    501                 ($this->DetectWebkit() == $this->true))
     529                ($this->DetectWebkit() == $this->true))
    502530         return $this->true;
    503531      else
     
    511539   { 
    512540       if ((stripos($this->useragent, $this->deviceBBStorm) > -1) ||
    513                 (stripos($this->useragent, $this->deviceBBTorch) > -1) ||
    514                 (stripos($this->useragent, $this->deviceBBBoldTouch) > -1) ||
    515                 (stripos($this->useragent, $this->deviceBBCurveTouch) > -1))
     541                (stripos($this->useragent, $this->deviceBBTorch) > -1) ||
     542                (stripos($this->useragent, $this->deviceBBBoldTouch) > -1) ||
     543                (stripos($this->useragent, $this->deviceBBCurveTouch) > -1))
    516544         return $this->true;
    517545       else
     
    555583          //Assume that if it's not in the High tier, then it's Low.
    556584          if (($this->DetectBlackBerryHigh() == $this->true) ||
    557                         ($this->DetectBlackBerryWebKit() == $this->true))
     585                        ($this->DetectBlackBerryWebKit() == $this->true))
    558586             return $this->false;
    559587          else
     
    564592   }
    565593
     594
     595   //**************************
     596   // Detects if the current browser is the Nokia S60 Open Source Browser.
     597   function DetectS60OssBrowser()
     598   {
     599      //First, test for WebKit, then make sure it's either Symbian or S60.
     600      if ($this->DetectWebkit() == $this->true)
     601      {
     602        if (stripos($this->useragent, $this->deviceSymbian) > -1 ||
     603            stripos($this->useragent, $this->deviceS60) > -1)
     604        {
     605           return $this->true;
     606        }
     607        else
     608           return $this->false;
     609      }
     610      else
     611         return $this->false;
     612   }
     613   
     614   //**************************
     615   // Detects if the current device is any Symbian OS-based device,
     616   //   including older S60, Series 70, Series 80, Series 90, and UIQ,
     617   //   or other browsers running on these devices.
     618   function DetectSymbianOS()
     619   {
     620       if (stripos($this->useragent, $this->deviceSymbian) > -1 ||
     621           stripos($this->useragent, $this->deviceS60) > -1 ||
     622           stripos($this->useragent, $this->deviceS70) > -1 ||
     623           stripos($this->useragent, $this->deviceS80) > -1 ||
     624           stripos($this->useragent, $this->deviceS90) > -1)
     625         return $this->true;
     626      else
     627         return $this->false;
     628   }
     629
     630
    566631   //**************************
    567632   // Detects if the current browser is on a PalmOS device.
    568633   function DetectPalmOS()
    569634   {
     635                //Make sure it's not WebOS first
     636                if ($this->DetectPalmWebOS() == $this->true)
     637                        return $this->false;
     638
    570639      //Most devices nowadays report as 'Palm', but some older ones reported as Blazer or Xiino.
    571640      if (stripos($this->useragent, $this->devicePalm) > -1 ||
    572641          stripos($this->useragent, $this->engineBlazer) > -1 ||
    573642          stripos($this->useragent, $this->engineXiino) > -1)
    574       {
    575          //Make sure it's not WebOS first
    576          if ($this->DetectPalmWebOS() == $this->true)
    577             return $this->false;
    578          else
    579643            return $this->true;
    580       }
    581644      else
    582645         return $this->false;
     
    600663   {
    601664      if ((stripos($this->useragent, $this->deviceWebOShp) > -1)
    602                         && (stripos($this->useragent, $this->deviceTablet) > -1))
    603          return $this->true;
    604       else
    605          return $this->false;
    606    }
    607 
    608    //**************************
    609    // Detects if the current browser is a
    610    //   Garmin Nuvifone.
    611    function DetectGarminNuvifone()
    612    {
    613       if (stripos($this->useragent, $this->deviceNuvifone) > -1)
    614          return $this->true;
    615       else
    616          return $this->false;
    617    }
    618 
    619 
    620    //**************************
    621    // Check to see whether the device is any device
    622    //   in the 'smartphone' category.
    623    function DetectSmartphone()
    624    {
    625       global $isIphone, $isAndroidPhone, $isTierIphone;
    626 
    627       if (($this->isIphone == $this->true)
    628                         || ($this->isAndroidPhone == $this->true)
    629                         || ($this->isTierIphone == $this->true)
    630                         || ($this->DetectS60OssBrowser() == $this->true)
    631                         || ($this->DetectSymbianOS() == $this->true)
    632                         || ($this->DetectWindowsMobile() == $this->true)
    633                         || ($this->DetectWindowsPhone7() == $this->true)
    634                         || ($this->DetectBlackBerry() == $this->true)
    635                         || ($this->DetectPalmWebOS() == $this->true)
    636                         || ($this->DetectPalmOS() == $this->true)
    637                         || ($this->DetectGarminNuvifone() == $this->true))
    638          return $this->true;
    639       else
    640          return $this->false;
    641    }
    642 
    643 
    644    //**************************
    645    // Detects whether the device is a Brew-powered device.
    646    function DetectBrewDevice()
    647    {
    648        if (stripos($this->useragent, $this->deviceBrew) > -1)
    649          return $this->true;
    650       else
    651          return $this->false;
    652    }
    653 
    654    //**************************
    655    // Detects the Danger Hiptop device.
    656    function DetectDangerHiptop()
    657    {
    658       if (stripos($this->useragent, $this->deviceDanger) > -1 ||
    659           stripos($this->useragent, $this->deviceHiptop) > -1)
    660          return $this->true;
    661       else
    662          return $this->false;
    663    }
     665                        && (stripos($this->useragent, $this->deviceTablet) > -1))
     666         return $this->true;
     667      else
     668         return $this->false;
     669   }
     670
     671
    664672
    665673   //**************************
     
    686694      if ((stripos($this->useragent, $this->engineOpera) > -1) &&
    687695        (stripos($this->useragent, $this->deviceAndroid) > -1) &&
    688                 (stripos($this->useragent, $this->mobi) > -1))
     696                (stripos($this->useragent, $this->mobi) > -1))
    689697         return $this->true;
    690698      else
     
    699707      if ((stripos($this->useragent, $this->engineOpera) > -1) &&
    700708        (stripos($this->useragent, $this->deviceAndroid) > -1) &&
    701                 (stripos($this->useragent, $this->deviceTablet) > -1))
    702          return $this->true;
    703       else
    704          return $this->false;
    705    }
    706 
    707    //**************************
    708    // Detects whether the device supports WAP or WML.
    709    function DetectWapWml()
    710    {
    711        if (stripos($this->httpaccept, $this->vndwap) > -1 ||
    712            stripos($this->httpaccept, $this->wml) > -1)
    713          return $this->true;
    714       else
    715          return $this->false;
    716    }
    717    
     709                (stripos($this->useragent, $this->deviceTablet) > -1))
     710         return $this->true;
     711      else
     712         return $this->false;
     713   }
     714
    718715   //**************************
    719716   // Detects if the current device is an Amazon Kindle (eInk devices only).
     
    729726   
    730727   //**************************
    731    // Detects if the current Amazon device is using the Silk Browser.
     728   // Detects if the current Amazon device has turned on the Silk accelerated browsing feature.
    732729   // Note: Typically used by the the Kindle Fire.
    733730   function DetectAmazonSilk()
     
    738735         return $this->false;
    739736   }
    740    
    741    
     737
     738   //**************************
     739   // Detects if a Garmin Nuvifone device.
     740   function DetectGarminNuvifone()
     741   {
     742      if (stripos($this->useragent, $this->deviceNuvifone) > -1)
     743         return $this->true;
     744      else
     745         return $this->false;
     746   }
     747   
     748   //**************************
     749   // Detects a device running the Bada smartphone OS from Samsung.
     750   function DetectBada()
     751   {
     752      if (stripos($this->useragent, $this->deviceBada) > -1)
     753         return $this->true;
     754      else
     755         return $this->false;
     756   }
     757
     758   //**************************
     759   // Detects a device running the Tizen smartphone OS.
     760   function DetectTizen()
     761   {
     762      if (stripos($this->useragent, $this->deviceTizen) > -1)
     763         return $this->true;
     764      else
     765         return $this->false;
     766   }
     767
     768   //**************************
     769   // Detects a device running the Meego OS.
     770   function DetectMeego()
     771   {
     772      if (stripos($this->useragent, $this->deviceMeego) > -1)
     773         return $this->true;
     774      else
     775         return $this->false;
     776   }
     777   
     778   //**************************
     779   // Detects the Danger Hiptop device.
     780   function DetectDangerHiptop()
     781   {
     782      if (stripos($this->useragent, $this->deviceDanger) > -1 ||
     783          stripos($this->useragent, $this->deviceHiptop) > -1)
     784         return $this->true;
     785      else
     786         return $this->false;
     787   }
     788
     789   //**************************
     790   // Detects if the current browser is a Sony Mylo device.
     791   function DetectSonyMylo()
     792   {
     793      if ((stripos($this->useragent, $this->manuSony) > -1) &&
     794         ((stripos($this->useragent, $this->qtembedded) > -1) ||
     795          (stripos($this->useragent, $this->mylocom2) > -1)))
     796         return $this->true;
     797      else
     798         return $this->false;
     799   }
     800   
     801   //**************************
     802   // Detects if the current device is on one of the Maemo-based Nokia Internet Tablets.
     803   function DetectMaemoTablet()
     804   {
     805      if (stripos($this->useragent, $this->maemo) > -1)
     806         return $this->true;
     807      //For Nokia N810, must be Linux + Tablet, or else it could be something else.
     808      if ((stripos($this->useragent, $this->linux) > -1)
     809                && (stripos($this->useragent, $this->deviceTablet) > -1)
     810                && ($this->DetectWebOSTablet() == $this->false)
     811                && ($this->DetectAndroid() == $this->false))
     812         return $this->true;
     813      else
     814         return $this->false;
     815   }
     816
     817   //**************************
     818   // Detects if the current device is an Archos media player/Internet tablet.
     819   function DetectArchos()
     820   {
     821      if (stripos($this->useragent, $this->deviceArchos) > -1)
     822         return $this->true;
     823      else
     824         return $this->false;
     825   }
     826
     827   //**************************
     828   // Detects if the current device is an Internet-capable game console.
     829   // Includes many handheld consoles.
     830   function DetectGameConsole()
     831   {
     832      if (($this->DetectSonyPlaystation() == $this->true) ||
     833                 ($this->DetectNintendo() == $this->true) ||
     834                 ($this->DetectXbox() == $this->true))
     835         return $this->true;
     836      else
     837         return $this->false;
     838   }
     839   
     840   //**************************
     841   // Detects if the current device is a Sony Playstation.
     842   function DetectSonyPlaystation()
     843   {
     844      if (stripos($this->useragent, $this->devicePlaystation) > -1)
     845         return $this->true;
     846      else
     847         return $this->false;
     848   }
     849
     850   //**************************
     851   // Detects if the current device is a handheld gaming device with
     852   // a touchscreen and modern iPhone-class browser. Includes the Playstation Vita.
     853   function DetectGamingHandheld()
     854   {
     855      if ((stripos($this->useragent, $this->devicePlaystation) > -1) &&
     856         (stripos($this->useragent, $this->devicePlaystationVita) > -1))
     857         return $this->true;
     858      else
     859         return $this->false;
     860   }
     861
     862   //**************************
     863   // Detects if the current device is a Nintendo game device.
     864   function DetectNintendo()
     865   {
     866      if (stripos($this->useragent, $this->deviceNintendo) > -1 ||
     867           stripos($this->useragent, $this->deviceWii) > -1 ||
     868           stripos($this->useragent, $this->deviceNintendoDs) > -1)
     869         return $this->true;
     870      else
     871         return $this->false;
     872   }
     873
     874   //**************************
     875   // Detects if the current device is a Microsoft Xbox.
     876   function DetectXbox()
     877   {
     878      if (stripos($this->useragent, $this->deviceXbox) > -1)
     879         return $this->true;
     880      else
     881         return $this->false;
     882   }
     883
     884   //**************************
     885   // Detects whether the device is a Brew-powered device.
     886   function DetectBrewDevice()
     887   {
     888       if (stripos($this->useragent, $this->deviceBrew) > -1)
     889         return $this->true;
     890      else
     891         return $this->false;
     892   }
     893   
     894   //**************************
     895   // Detects whether the device supports WAP or WML.
     896   function DetectWapWml()
     897   {
     898       if (stripos($this->httpaccept, $this->vndwap) > -1 ||
     899           stripos($this->httpaccept, $this->wml) > -1)
     900         return $this->true;
     901      else
     902         return $this->false;
     903   }
     904   
     905   //**************************
     906   // Detects if the current device supports MIDP, a mobile Java technology.
     907   function DetectMidpCapable()
     908   {
     909       if (stripos($this->useragent, $this->deviceMidp) > -1 ||
     910           stripos($this->httpaccept, $this->deviceMidp) > -1)
     911         return $this->true;
     912      else
     913         return $this->false;
     914   }
     915
     916
     917
     918  //*****************************
     919  // Device Classes
     920  //*****************************
     921   
     922   //**************************
     923   // Check to see whether the device is *any* 'smartphone'.
     924   //   Note: It's better to use DetectTierIphone() for modern touchscreen devices.
     925   function DetectSmartphone()
     926   {
     927      //Exclude duplicates from TierIphone
     928      if (($this->DetectTierIphone() == $this->true)
     929                || ($this->DetectS60OssBrowser() == $this->true)
     930                || ($this->DetectSymbianOS() == $this->true)
     931                || ($this->DetectWindowsMobile() == $this->true)
     932                || ($this->DetectBlackBerry() == $this->true)
     933                || ($this->DetectPalmWebOS() == $this->true))
     934         return $this->true;
     935      else
     936         return $this->false;
     937   }
     938
    742939   //**************************
    743940   // The quick way to detect for a mobile device.
     
    750947         return $this->false;
    751948     
     949      if ($this->initCompleted == $this->true ||
     950          $this->isMobilePhone == $this->true)
     951         return $this->isMobilePhone;
     952
    752953      //Most mobile browsing is done on smartphones
    753954      if ($this->DetectSmartphone() == $this->true)
    754955         return $this->true;
    755956
     957       if (stripos($this->useragent, $this->mobile) > -1)
     958         return $this->true;
     959
    756960      if (($this->DetectWapWml() == $this->true)
    757                         || ($this->DetectBrewDevice() == $this->true)
    758                         || ($this->DetectOperaMobile() == $this->true))
     961                        || ($this->DetectBrewDevice() == $this->true)
     962                        || ($this->DetectOperaMobile() == $this->true))
    759963         return $this->true;
    760964         
    761       if ((stripos($this->useragent, $this->engineNetfront) > -1)
    762                         || (stripos($this->useragent, $this->engineUpBrowser) > -1)
    763                         || (stripos($this->useragent, $this->engineOpenWeb) > -1))
     965      if ((stripos($this->useragent, $this->engineObigo) > -1)
     966                        || (stripos($this->useragent, $this->engineNetfront) > -1)
     967                        || (stripos($this->useragent, $this->engineUpBrowser) > -1)
     968                        || (stripos($this->useragent, $this->engineOpenWeb) > -1))
    764969         return $this->true;
    765970         
    766971      if (($this->DetectDangerHiptop() == $this->true)
    767                         || ($this->DetectMidpCapable() == $this->true)
    768                         || ($this->DetectMaemoTablet() == $this->true)
    769                         || ($this->DetectArchos() == $this->true))
     972                        || ($this->DetectMidpCapable() == $this->true)
     973                        || ($this->DetectMaemoTablet() == $this->true)
     974                        || ($this->DetectArchos() == $this->true))
    770975         return $this->true;
    771976
    772977       if ((stripos($this->useragent, $this->devicePda) > -1) &&
    773                  !(stripos($this->useragent, $this->disUpdate) > -1))
    774          return $this->true;
    775        if (stripos($this->useragent, $this->mobile) > -1)
    776          return $this->true;
    777 
     978                 !(stripos($this->useragent, $this->disUpdate) > -1))
     979         return $this->true;
     980     
    778981      //We also look for Kindle devices
    779982      if ($this->DetectKindle() == $this->true ||
     
    784987         return $this->false;
    785988   }
    786    
    787    //**************************
    788    // Detects if the current device is a Sony Playstation.
    789    function DetectSonyPlaystation()
    790    {
    791       if (stripos($this->useragent, $this->devicePlaystation) > -1)
    792          return $this->true;
    793       else
    794          return $this->false;
    795    }
    796 
    797    //**************************
    798    // Detects if the current device is a Nintendo game device.
    799    function DetectNintendo()
    800    {
    801       if (stripos($this->useragent, $this->deviceNintendo) > -1 ||
    802            stripos($this->useragent, $this->deviceWii) > -1 ||
    803            stripos($this->useragent, $this->deviceNintendoDs) > -1)
    804          return $this->true;
    805       else
    806          return $this->false;
    807    }
    808 
    809    //**************************
    810    // Detects if the current device is a Microsoft Xbox.
    811    function DetectXbox()
    812    {
    813       if (stripos($this->useragent, $this->deviceXbox) > -1)
    814          return $this->true;
    815       else
    816          return $this->false;
    817    }
    818    
    819    //**************************
    820    // Detects if the current device is an Internet-capable game console.
    821    function DetectGameConsole()
    822    {
    823       if ($this->DetectSonyPlaystation() == $this->true)
    824          return $this->true;
    825       else if ($this->DetectNintendo() == $this->true)
    826          return $this->true;
    827       else if ($this->DetectXbox() == $this->true)
    828          return $this->true;
    829       else
    830          return $this->false;
    831    }
    832    
    833    //**************************
    834    // Detects if the current device supports MIDP, a mobile Java technology.
    835    function DetectMidpCapable()
    836    {
    837        if (stripos($this->useragent, $this->deviceMidp) > -1 ||
    838            stripos($this->httpaccept, $this->deviceMidp) > -1)
    839          return $this->true;
    840       else
    841          return $this->false;
    842    }
    843    
    844    //**************************
    845    // Detects if the current device is on one of the Maemo-based Nokia Internet Tablets.
    846    function DetectMaemoTablet()
    847    {
    848       if (stripos($this->useragent, $this->maemo) > -1)
    849          return $this->true;
    850       //For Nokia N810, must be Linux + Tablet, or else it could be something else.
    851       if ((stripos($this->useragent, $this->linux) > -1)
    852                 && (stripos($this->useragent, $this->deviceTablet) > -1)
    853                 && ($this->DetectWebOSTablet() == $this->false)
    854                 && ($this->DetectAndroid() == $this->false))
    855          return $this->true;
    856       else
    857          return $this->false;
    858    }
    859 
    860    //**************************
    861    // Detects if the current device is an Archos media player/Internet tablet.
    862    function DetectArchos()
    863    {
    864       if (stripos($this->useragent, $this->deviceArchos) > -1)
    865          return $this->true;
    866       else
    867          return $this->false;
    868    }
    869 
    870    //**************************
    871    // Detects if the current browser is a Sony Mylo device.
    872    function DetectSonyMylo()
    873    {
    874       if (stripos($this->useragent, $this->manuSony) > -1)
    875       {
    876          if ((stripos($this->useragent, $this->qtembedded) > -1) ||
    877           (stripos($this->useragent, $this->mylocom2) > -1))
    878          {
    879             return $this->true;
    880          }
    881          else
    882             return $this->false;
    883       }
    884       else
    885          return $this->false;
    886    }
    887    
    888989 
    889990   //**************************
     
    9101011       if (stripos($this->useragent, $this->manuericsson) > -1)
    9111012         return $this->true;
    912 
    9131013       if (stripos($this->useragent, $this->manuSamsung1) > -1)
    9141014         return $this->true;
     1015
    9151016       if (stripos($this->useragent, $this->svcDocomo) > -1)
    9161017         return $this->true;
     
    9231024         return $this->false;
    9241025   }
    925 
    9261026
    9271027
     
    9371037   function DetectTierTablet()
    9381038   {
     1039      if ($this->initCompleted == $this->true ||
     1040          $this->isTierTablet == $this->true)
     1041         return $this->isTierTablet;
     1042
    9391043      if (($this->DetectIpad() == $this->true)
    9401044         || ($this->DetectAndroidTablet() == $this->true)
     
    9511055   //   This method detects for devices which can
    9521056   //   display iPhone-optimized web content.
    953    //   Includes iPhone, iPod Touch, Android, Windows Phone 7, WebOS, etc.
     1057   //   Includes iPhone, iPod Touch, Android, Windows Phone 7 and 8, BB10, WebOS, Playstation Vita, etc.
    9541058   function DetectTierIphone()
    9551059   {
    956       if (($this->isIphone == $this->true) ||
    957                         ($this->isAndroidPhone == $this->true))
    958          return $this->true;
    959    
     1060      if ($this->initCompleted == $this->true ||
     1061          $this->isTierIphone == $this->true)
     1062         return $this->isTierIphone;
     1063
     1064      if (($this->DetectIphoneOrIpod() == $this->true)
     1065                        || ($this->DetectAndroidPhone() == $this->true)
     1066                        || ($this->DetectWindowsPhone() == $this->true)
     1067                        || ($this->DetectBlackBerry10Phone() == $this->true)
     1068                        || ($this->DetectPalmWebOS() == $this->true)
     1069                        || ($this->DetectBada() == $this->true)
     1070                        || ($this->DetectTizen() == $this->true)
     1071                        || ($this->DetectGamingHandheld() == $this->true))
     1072         return $this->true;
     1073     
     1074      //Note: BB10 phone is in the previous paragraph
    9601075      if (($this->DetectBlackBerryWebKit() == $this->true) &&
    961                 ($this->DetectBlackBerryTouch() == $this->true))
    962          return $this->true;
    963       if ($this->DetectWindowsPhone7() == $this->true)
    964          return $this->true;
    965       if ($this->DetectPalmWebOS() == $this->true)
    966          return $this->true;
    967       if ($this->DetectGarminNuvifone() == $this->true)
    968          return $this->true;
     1076                ($this->DetectBlackBerryTouch() == $this->true))
     1077         return $this->true;
     1078     
    9691079      else
    9701080         return $this->false;
     
    9791089   function DetectTierRichCss()
    9801090   {
     1091      if ($this->initCompleted == $this->true ||
     1092          $this->isTierRichCss == $this->true)
     1093         return $this->isTierRichCss;
     1094
    9811095      if ($this->DetectMobileQuick() == $this->true)
    9821096      {
     
    10161130   function DetectTierOtherPhones()
    10171131   {
     1132      if ($this->initCompleted == $this->true ||
     1133          $this->isTierGenericMobile == $this->true)
     1134         return $this->isTierGenericMobile;
     1135
    10181136      //Exclude devices in the other 2 categories
    10191137      if (($this->DetectMobileLong() == $this->true)
    1020                 && ($this->DetectTierIphone() == $this->false)
    1021                 && ($this->DetectTierRichCss() == $this->false))
     1138                && ($this->DetectTierIphone() == $this->false)
     1139                && ($this->DetectTierRichCss() == $this->false))
    10221140           return $this->true;
    10231141      else
Note: See TracChangeset for help on using the changeset viewer.