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

Source for file Detect.php

Documentation is available at Detect.php

  1. <?php
  2. // {{{ license
  3.  
  4. // +----------------------------------------------------------------------+
  5. // | PHP version 4.2                                                      |
  6. // +----------------------------------------------------------------------+
  7. // | Copyright (c) 1997-2007 The PHP Group                                |
  8. // +----------------------------------------------------------------------+
  9. // | This source file is subject to version 2.0 of the PHP license,       |
  10. // | that is bundled with this package in the file LICENSE, and is        |
  11. // | available at through the world-wide-web at                           |
  12. // | http://www.php.net/license/2_02.txt.                                 |
  13. // | If you did not receive a copy of the PHP license and are unable to   |
  14. // | obtain it through the world-wide-web, please send a note to          |
  15. // | license@php.net so we can mail you a copy immediately.               |
  16. // +----------------------------------------------------------------------+
  17. // | Authors: Dan Allen <dan@mojavelinux.com>                             |
  18. // |          Jason Rust <jrust@php.net>                                  |
  19. // +----------------------------------------------------------------------+
  20.  
  21. // $Id: Detect.php 298049 2010-04-15 18:16:24Z jrust $
  22.  
  23. // }}}
  24. // {{{ constants
  25.  
  26. define('NET_USERAGENT_DETECT_BROWSER',  'browser');
  27. define('NET_USERAGENT_DETECT_OS',       'os');
  28. define('NET_USERAGENT_DETECT_FEATURES', 'features');
  29. define('NET_USERAGENT_DETECT_QUIRKS',   'quirks');
  30. define('NET_USERAGENT_DETECT_ACCEPT',   'accept');
  31. define('NET_USERAGENT_DETECT_ALL',      'all');
  32.  
  33. // }}}
  34. // {{{ class Net_UserAgent_Detect
  35.  
  36. /**
  37.  * The Net_UserAgent_Detect object does a number of tests on an HTTP user
  38.  * agent string.  The results of these tests are available via methods of
  39.  * the object.  Note that all methods in this class can be called
  40.  * statically.  The constructor and singleton methods are only retained
  41.  * for BC.
  42.  *
  43.  * This module is based upon the JavaScript browser detection code
  44.  * available at http://www.mozilla.org/docs/web-developer/sniffer/browser_type.html.
  45.  * This module had many influences from the lib/Browser.php code in
  46.  * version 1.3 of Horde.
  47.  *
  48.  * @author   Jason Rust <jrust@php.net>
  49.  * @author   Dan Allen <dan@mojavelinux.com>
  50.  * @author   Chuck Hagenbuch <chuck@horde.org>
  51.  * @author   Jon Parise <jon@horde.org>
  52.  * @package  Net_UserAgent
  53.  */
  54.  
  55. // }}}
  56.     // {{{ constructor
  57.  
  58.     function Net_UserAgent_Detect($in_userAgent = null, $in_detect = null)
  59.     {
  60.         $this->detect($in_userAgent, $in_detect);
  61.     }
  62.  
  63.     // }}}
  64.     // {{{ singleton
  65.  
  66.     /**
  67.      * To be used in place of the contructor to return only open instance.
  68.      *
  69.      * @access public
  70.      * @return object Net_UserAgent_Detect instance
  71.      */
  72.     function &singleton($in_userAgent = null, $in_detect = null) 
  73.     {
  74.         static $instance;
  75.        
  76.         if (!isset($instance)) { 
  77.             $instance = new Net_UserAgent_Detect($in_userAgent, $in_detect); 
  78.         }
  79.         
  80.         return $instance; 
  81.     }
  82.  
  83.     // }}}
  84.     // {{{ detect()
  85.  
  86.     /**
  87.      * Detect the user agent and prepare flags, features and quirks
  88.      * based on what is found
  89.      *
  90.      * This is the core of the Net_UserAgent_Detect class.  It moves its
  91.      * way through the user agent string setting up the flags based on
  92.      * the vendors and versions of the browsers, determining the OS and
  93.      * setting up the features and quirks owned by each of the relevant
  94.      * clients.  Note that if you are going to be calling methods of
  95.      * this class statically then set all the parameters using th
  96.      * setOption()
  97.      *
  98.      * @param  string $in_userAgent (optional) User agent override.
  99.      * @param  mixed $in_detect (optional) The level of checking to do.
  100.      *
  101.      * @access public
  102.      * @return void 
  103.      */
  104.     function detect($in_userAgent = null, $in_detect = null)
  105.     {
  106.         static $hasRun;
  107.         $options = &Net_UserAgent_Detect::_getStaticProperty('options');
  108.         if (!empty($hasRun) && empty($options['re-evaluate'])) {
  109.             return;
  110.         }
  111.  
  112.         $hasRun = true;
  113.         // {{{ set up static properties
  114.  
  115.         $in_userAgent = isset($options['userAgent']) && is_null($in_userAgent) ? $options['userAgent'] : $in_userAgent;
  116.         $in_detect = isset($options['detectOptions']) && is_null($in_detect) ? $options['detectOptions'] : $in_detect;
  117.  
  118.         // User agent string that is being analyzed
  119.         $userAgent = &Net_UserAgent_Detect::_getStaticProperty('userAgent');
  120.  
  121.         // Array that stores all of the flags for the vendor and version
  122.         // of the different browsers
  123.         $browser = &Net_UserAgent_Detect::_getStaticProperty('browser');
  124.         $browser = array_flip(array('ns', 'ns2', 'ns3', 'ns4', 'ns4up', 'nav', 'ns6', 'belowns6', 'ns6up', 'firefox', 'firefox0.x', 'firefox1.x', 'firefox1.5', 'firefox2.x', 'firefox3.x', 'gecko', 'ie', 'ie3', 'ie4', 'ie4up', 'ie5', 'ie5_5', 'ie5up', 'ie6', 'belowie6', 'ie6up', 'ie7', 'ie7up', 'ie8', 'ie8tr', 'ie8up', 'ie9', 'ie9up', 'opera', 'opera2', 'opera3', 'opera4', 'opera5', 'opera6', 'opera7', 'opera8', 'opera9', 'opera5up', 'opera6up', 'opera7up', 'belowopera8', 'opera8up', 'opera9up', 'aol', 'aol3', 'aol4', 'aol5', 'aol6', 'aol7', 'aol8', 'webtv', 'aoltv', 'tvnavigator', 'hotjava', 'hotjava3', 'hotjava3up', 'konq', 'safari', 'safari_mobile', 'chrome', 'netgem', 'webdav', 'icab'));
  125.         
  126.         // Array that stores all of the flags for the operating systems,
  127.         // and in some cases the versions of those operating systems (windows)
  128.         $os = &Net_UserAgent_Detect::_getStaticProperty('os');
  129.         $os = array_flip(array('win', 'win95', 'win16', 'win31', 'win9x', 'win98', 'wince', 'winme', 'win2k', 'winxp', 'winnt', 'win2003', 'vista', 'win7', 'os2', 'mac', 'mactiger', 'macleopard', 'macsnowleopard', 'mac68k', 'macppc', 'iphone', 'linux', 'unix', 'vms', 'sun', 'sun4', 'sun5', 'suni86', 'irix', 'irix5', 'irix6', 'hpux', 'hpux9', 'hpux10', 'aix', 'aix1', 'aix2', 'aix3', 'aix4', 'sco', 'unixware', 'mpras', 'reliant', 'dec', 'sinix', 'freebsd', 'bsd'));
  130.  
  131.         // Array which stores known issues with the given client that can
  132.         // be used for on the fly tweaking so that the client may recieve
  133.         // the proper handling of this quirk.
  134.         $quirks = &Net_UserAgent_Detect::_getStaticProperty('quirks');
  135.         $quirks = array(
  136.                 'must_cache_forms'         => false,
  137.                 'popups_disabled'          => false,
  138.                 'empty_file_input_value'   => false,
  139.                 'cache_ssl_downloads'      => false,
  140.                 'scrollbar_in_way'         => false,
  141.                 'break_disposition_header' => false,
  142.                 'nested_table_render_bug'  => false);
  143.  
  144.         // Array that stores credentials for each of the browser/os
  145.         // combinations.  These allow quick access to determine if the
  146.         // current client has a feature that is going to be implemented
  147.         // in the script.
  148.         $features = &Net_UserAgent_Detect::_getStaticProperty('features');
  149.         $features = array(
  150.                 'javascript'   => false,
  151.                 'dhtml'        => false,
  152.                 'dom'          => false,
  153.                 'sidebar'      => false,
  154.                 'gecko'        => false,
  155.                 'svg'          => false,
  156.                 'css2'         => false,
  157.                 'ajax'         => false);
  158.  
  159.         // The leading identifier is the very first term in the user
  160.         // agent string, which is used to identify clients which are not
  161.         // Mosaic-based browsers.
  162.         $leadingIdentifier = &Net_UserAgent_Detect::_getStaticProperty('leadingIdentifier');
  163.  
  164.         // The full version of the client as supplied by the very first
  165.         // numbers in the user agent
  166.         $version = &Net_UserAgent_Detect::_getStaticProperty('version');
  167.         $version = 0;
  168.  
  169.         // The major part of the client version, which is the integer
  170.         // value of the version.
  171.         $majorVersion = &Net_UserAgent_Detect::_getStaticProperty('majorVersion');
  172.         $majorVersion = 0;
  173.  
  174.         // The minor part of the client version, which is the decimal
  175.         // parts of the version
  176.         $subVersion = &Net_UserAgent_Detect::_getStaticProperty('subVersion');
  177.         $subVersion = 0;
  178.  
  179.         // }}}
  180.         // detemine what user agent we are using
  181.         if (is_null($in_userAgent)) {
  182.             if (isset($_SERVER['HTTP_USER_AGENT'])) {
  183.                 $userAgent = $_SERVER['HTTP_USER_AGENT'];
  184.             }
  185.             elseif (isset($GLOBALS['HTTP_SERVER_VARS']['HTTP_USER_AGENT'])) {
  186.                 $userAgent = $GLOBALS['HTTP_SERVER_VARS']['HTTP_USER_AGENT'];
  187.             }
  188.             else {
  189.                 $userAgent = '';
  190.             }
  191.         }
  192.         else {
  193.             $userAgent = $in_userAgent;
  194.         }
  195.  
  196.         // get the lowercase version for case-insensitive searching
  197.         $agt = strtolower($userAgent);
  198.  
  199.         // figure out what we need to look for
  200.         $detectOptions = array(NET_USERAGENT_DETECT_BROWSER,
  201.                 NET_USERAGENT_DETECT_OS, NET_USERAGENT_DETECT_FEATURES,
  202.                 NET_USERAGENT_DETECT_QUIRKS, NET_USERAGENT_DETECT_ACCEPT, 
  203.                 NET_USERAGENT_DETECT_ALL);
  204.         $detect = is_null($in_detect) ? NET_USERAGENT_DETECT_ALL : $in_detect;
  205.         settype($detect, 'array');
  206.         foreach($detectOptions as $option) {
  207.             if (in_array($option, $detect)) {
  208.                 $detectFlags[$option] = true; 
  209.             }
  210.             else {
  211.                 $detectFlags[$option] = false;
  212.             }
  213.         }
  214.  
  215.         // initialize the arrays of browsers and operating systems
  216.  
  217.         // Get the type and version of the client
  218.         if (preg_match(";^([[:alnum:]]+)[ /\(]*[[:alpha:]]*([\d]*)(\.[\d\.]*);", $agt, $matches)) {
  219.             list(, $leadingIdentifier, $majorVersion, $subVersion) = $matches;
  220.         }
  221.  
  222.         if (empty($leadingIdentifier)) {
  223.             $leadingIdentifier = 'Unknown';
  224.         }
  225.  
  226.         $version = $majorVersion . $subVersion;
  227.     
  228.         // Browser type
  229.         if ($detectFlags[NET_USERAGENT_DETECT_ALL] || $detectFlags[NET_USERAGENT_DETECT_BROWSER]) {
  230.             $browser['webdav']  = ($agt == 'microsoft data access internet publishing provider dav' || $agt == 'microsoft data access internet publishing provider protocol discovery');
  231.             $browser['konq'] = (strpos($agt, 'konqueror') !== false ||  strpos($agt, 'safari') !== false );
  232.             $browser['safari'] = (strpos($agt, 'safari') !== false);
  233.             $browser['chrome'] = (strpos($agt, 'chrome') !== false);
  234.             $browser['safari_mobile'] = (strpos($agt, 'safari') !== false && strpos($agt, 'mobile') !== false );
  235.             $browser['text']    = strpos($agt, 'links') !== false || strpos($agt, 'lynx') !== false || strpos($agt, 'w3m') !== false;
  236.             $browser['ns']      = strpos($agt, 'mozilla') !== false && !(strpos($agt, 'spoofer') !== false) && !(strpos($agt, 'compatible') !== false) && !(strpos($agt, 'hotjava') !== false) && !(strpos($agt, 'opera') !== false) && !(strpos($agt, 'webtv') !== false) ? 1 : 0;
  237.             $browser['netgem']  = strpos($agt, 'netgem') !== false;
  238.             $browser['icab']    = strpos($agt, 'icab') !== false;
  239.             $browser['ns2']     = $browser['ns'] && $majorVersion == 2;
  240.             $browser['ns3']     = $browser['ns'] && $majorVersion == 3;
  241.             $browser['ns4']     = $browser['ns'] && $majorVersion == 4;
  242.             $browser['ns4up']   = $browser['ns'] && $majorVersion >= 4;
  243.             // determine if this is a Netscape Navigator
  244.             $browser['nav'] = $browser['belowns6'] = $browser['ns'] && $majorVersion < 5;
  245.             $browser['ns6']     = !$browser['konq'] && $browser['ns'] && $majorVersion == 5;
  246.             $browser['ns6up']   = $browser['ns6'] && $majorVersion >= 5;
  247.             $browser['gecko']   = strpos($agt, 'gecko') !== false && !$browser['konq'];
  248.             $browser['firefox'] = $browser['gecko'] && strpos($agt, 'firefox') !== false;
  249.             $browser['firefox0.x'] = $browser['firefox'] && strpos($agt, 'firefox/0.') !== false;
  250.             $browser['firefox1.x'] = $browser['firefox'] && strpos($agt, 'firefox/1.') !== false;
  251.             $browser['firefox1.5'] = $browser['firefox'] && strpos($agt, 'firefox/1.5') !== false;
  252.             $browser['firefox2.x'] = $browser['firefox'] && strpos($agt, 'firefox/2.') !== false;
  253.             $browser['firefox3.x'] = $browser['firefox'] && strpos($agt, 'firefox/3.') !== false;
  254.             $browser['ie']      = strpos($agt, 'msie') !== false && !(strpos($agt, 'opera') !== false);
  255.             $browser['ie3']     = $browser['ie'] && $majorVersion < 4;
  256.             $browser['ie4']     = $browser['ie'] && $majorVersion == 4 && (strpos($agt, 'msie 4') !== false);
  257.             $browser['ie4up']   = $browser['ie'] && !$browser['ie3'];
  258.             $browser['ie5']     = $browser['ie4up'] && (strpos($agt, 'msie 5') !== false);
  259.             $browser['ie5_5']   = $browser['ie4up'] && (strpos($agt, 'msie 5.5') !== false);
  260.             $browser['ie5up']   = $browser['ie4up'] && !$browser['ie3'] && !$browser['ie4'];
  261.             $browser['ie5_5up'] = $browser['ie5up'] && !$browser['ie5'];
  262.             $browser['ie6']     = strpos($agt, 'msie 6') !== false;
  263.             $browser['ie6up']   = $browser['ie5up'] && !$browser['ie5'] && !$browser['ie5_5'];
  264.             $browser['ie7'] = strpos($agt, 'msie 7') && !strpos($agt,'trident/4');
  265.             $browser['ie7up']   = $browser['ie6up'] && (!$browser['ie6'] || $browser['ie7']);
  266.             $browser['ie8tr'] = strpos($agt, 'msie 7') && strpos($agt,'trident/4') !== false;
  267.             $browser['ie8'] = strpos($agt, 'msie 8') !== false;
  268.             $browser['ie8up'] = $browser['ie7up'] && (!$browser['ie7'] || $browser['ie8']);
  269.             $browser['ie9'] = strpos($agt, 'msie 9') !== false;
  270.             $browser['ie9up'] = $browser['ie8up'] && (!$browser['ie8'] || $browser['ie9']);
  271.             $browser['belowie6']= $browser['ie'] && !$browser['ie6up'];
  272.             $browser['opera']   = strpos($agt, 'opera') !== false;
  273.             $browser['opera2']  = strpos($agt, 'opera 2') !== false || strpos($agt, 'opera/2') !== false;
  274.             $browser['opera3']  = strpos($agt, 'opera 3') !== false || strpos($agt, 'opera/3') !== false;
  275.             $browser['opera4']  = strpos($agt, 'opera 4') !== false || strpos($agt, 'opera/4') !== false;
  276.             $browser['opera5']  = strpos($agt, 'opera 5') !== false || strpos($agt, 'opera/5') !== false;
  277.             $browser['opera6']  = strpos($agt, 'opera 6') !== false || strpos($agt, 'opera/6') !== false;
  278.             $browser['opera7']  = strpos($agt, 'opera 7') !== false || strpos($agt, 'opera/7') !== false;
  279.             $browser['opera8']  = strpos($agt, 'opera 8') !== false || strpos($agt, 'opera/8') !== false;
  280.             $browser['opera9']  = strpos($agt, 'opera 9') !== false || strpos($agt, 'opera/9') !== false;
  281.             $browser['opera5up'] = $browser['opera'] && !$browser['opera2'] && !$browser['opera3'] && !$browser['opera4'];
  282.             $browser['opera6up'] = $browser['opera'] && !$browser['opera2'] && !$browser['opera3'] && !$browser['opera4'] && !$browser['opera5'];
  283.             $browser['opera7up'] = $browser['opera'] && !$browser['opera2'] && !$browser['opera3'] && !$browser['opera4'] && !$browser['opera5'] && !$browser['opera6'];
  284.             $browser['opera8up'] = $browser['opera'] && !$browser['opera2'] && !$browser['opera3'] && !$browser['opera4'] && !$browser['opera5'] && !$browser['opera6'] && !$browser['opera7'];
  285.             $browser['opera9up'] = $browser['opera'] && !$browser['opera2'] && !$browser['opera3'] && !$browser['opera4'] && !$browser['opera5'] && !$browser['opera6'] && !$browser['opera7'] && !$browser['opera8'];
  286.             $browser['belowopera8'] = $browser['opera'] && !$browser['opera8up'];
  287.             $browser['aol']   = strpos($agt, 'aol') !== false;
  288.             $browser['aol3']  = $browser['aol'] && $browser['ie3'];
  289.             $browser['aol4']  = $browser['aol'] && $browser['ie4'];
  290.             $browser['aol5']  = strpos($agt, 'aol 5') !== false;
  291.             $browser['aol6']  = strpos($agt, 'aol 6') !== false;
  292.             $browser['aol7']  = strpos($agt, 'aol 7') !== false || strpos($agt, 'aol7') !== false;
  293.             $browser['aol8']  = strpos($agt, 'aol 8') !== false || strpos($agt, 'aol8') !== false;
  294.             $browser['webtv'] = strpos($agt, 'webtv') !== false; 
  295.             $browser['aoltv'] = $browser['tvnavigator'] = strpos($agt, 'navio') !== false || strpos($agt, 'navio_aoltv') !== false; 
  296.             $browser['hotjava'] = strpos($agt, 'hotjava') !== false;
  297.             $browser['hotjava3'] = $browser['hotjava'] && $majorVersion == 3;
  298.             $browser['hotjava3up'] = $browser['hotjava'] && $majorVersion >= 3;
  299.             $browser['iemobile'] = strpos($agt, 'iemobile') !== false || strpos($agt, 'windows ce') !== false && (strpos($agt, 'ppc') !== false || strpos($agt, 'smartphone') !== false);
  300.         }
  301.  
  302.         if ($detectFlags[NET_USERAGENT_DETECT_ALL] || 
  303.             ($detectFlags[NET_USERAGENT_DETECT_BROWSER] && $detectFlags[NET_USERAGENT_DETECT_FEATURES])) {
  304.             // Javascript Check
  305.             if ($browser['ns2'] || $browser['ie3']) {
  306.                 Net_UserAgent_Detect::setFeature('javascript', 1.0);
  307.             }
  308.             elseif ($browser['iemobile']) {
  309.               // no javascript
  310.             }
  311.             elseif ($browser['opera5up']) {
  312.                 Net_UserAgent_Detect::setFeature('javascript', 1.3);
  313.             }
  314.             elseif ($browser['opera'] || $browser['ns3']) {
  315.                 Net_UserAgent_Detect::setFeature('javascript', 1.1);
  316.             }
  317.             elseif (($browser['ns4'] && ($version <= 4.05)) || $browser['ie4']) {
  318.                 Net_UserAgent_Detect::setFeature('javascript', 1.2);
  319.             }
  320.             elseif (($browser['ie5up'] && strpos($agt, 'mac') !== false) || $browser['konq']) {
  321.                 Net_UserAgent_Detect::setFeature('javascript', 1.4);
  322.             }
  323.             // I can't believe IE6 still has javascript 1.3, what a shitty browser
  324.             elseif (($browser['ns4'] && ($version > 4.05)) || $browser['ie5up'] || $browser['hotjava3up']) {
  325.                 Net_UserAgent_Detect::setFeature('javascript', 1.3);
  326.             }
  327.             elseif ($browser['ns6up'] || $browser['gecko'] || $browser['netgem']) {
  328.                 Net_UserAgent_Detect::setFeature('javascript', 1.5);
  329.             }
  330.         }
  331.         
  332.         /** OS Check **/
  333.         if ($detectFlags[NET_USERAGENT_DETECT_ALL] || $detectFlags[NET_USERAGENT_DETECT_OS]) {
  334.             $os['win']   = strpos($agt, 'win') !== false || strpos($agt, '16bit') !== false;
  335.             $os['win95'] = strpos($agt, 'win95') !== false || strpos($agt, 'windows 95') !== false;
  336.             $os['win16'] = strpos($agt, 'win16') !== false || strpos($agt, '16bit') !== false || strpos($agt, 'windows 3.1') !== false || strpos($agt, 'windows 16-bit') !== false;  
  337.             $os['win31'] = strpos($agt, 'windows 3.1') !== false || strpos($agt, 'win16') !== false || strpos($agt, 'windows 16-bit') !== false;
  338.             $os['winme'] = strpos($agt, 'win 9x 4.90') !== false;
  339.             $os['wince'] = strpos($agt, 'windows ce') !== false;
  340.             $os['win2k'] = strpos($agt, 'windows nt 5.0') !== false;
  341.             $os['winxp'] = strpos($agt, 'windows nt 5.1') !== false;
  342.             $os['win2003'] = strpos($agt, 'windows nt 5.2') !== false;
  343.             $os['win98'] = strpos($agt, 'win98') !== false || strpos($agt, 'windows 98') !== false;
  344.             $os['win9x'] = $os['win95'] || $os['win98'];
  345.             $os['winnt'] = (strpos($agt, 'winnt') !== false || strpos($agt, 'windows nt') !== false) && strpos($agt, 'windows nt 5') === false;
  346.             $os['win32'] = $os['win95'] || $os['winnt'] || $os['win98'] || $majorVersion >= 4 && strpos($agt, 'win32') !== false || strpos($agt, '32bit') !== false;
  347.             $os['vista'] = strpos($agt, 'windows nt 6.0') !== false;
  348.             $os['win7'] = strpos($agt, 'windows nt 6.1') !== false; 
  349.             $os['os2']   = strpos($agt, 'os/2') !== false || strpos($agt, 'ibm-webexplorer') !== false;
  350.             $os['mac']   = strpos($agt, 'mac') !== false;
  351.             $os['mactiger'] = $os['mac'] && (strpos($agt, '10.4') !== false || strpos($agt, '10_4') !== false);
  352.             $os['macleopard'] = $os['mac'] && (strpos($agt, '10.5') !== false || strpos($agt, '10_5') !== false);
  353.             $os['macsnowleopard'] = $os['mac'] && (strpos($agt, '10.6') !== false || strpos($agt, '10_6') !== false); 
  354.             $os['mac68k']   = $os['mac'] && (strpos($agt, '68k') !== false || strpos($agt, '68000') !== false);
  355.             $os['macppc']   = $os['mac'] && (strpos($agt, 'ppc') !== false || strpos($agt, 'powerpc') !== false);
  356.             $os['iphone']   = strpos($agt, 'iphone') !== false;
  357.             $os['sun']      = strpos($agt, 'sunos') !== false;
  358.             $os['sun4']     = strpos($agt, 'sunos 4') !== false;
  359.             $os['sun5']     = strpos($agt, 'sunos 5') !== false;
  360.             $os['suni86']   = $os['sun'] && strpos($agt, 'i86') !== false;
  361.             $os['irix']     = strpos($agt, 'irix') !== false;
  362.             $os['irix5']    = strpos($agt, 'irix 5') !== false;
  363.             $os['irix6']    = strpos($agt, 'irix 6') !== false || strpos($agt, 'irix6') !== false;
  364.             $os['hpux']     = strpos($agt, 'hp-ux') !== false;
  365.             $os['hpux9']    = $os['hpux'] && strpos($agt, '09.') !== false;
  366.             $os['hpux10']   = $os['hpux'] && strpos($agt, '10.') !== false;
  367.             $os['aix']      = strpos($agt, 'aix') !== false;
  368.             $os['aix1']     = strpos($agt, 'aix 1') !== false;
  369.             $os['aix2']     = strpos($agt, 'aix 2') !== false;
  370.             $os['aix3']     = strpos($agt, 'aix 3') !== false;
  371.             $os['aix4']     = strpos($agt, 'aix 4') !== false;
  372.             $os['linux']    = strpos($agt, 'inux') !== false;
  373.             $os['sco']      = strpos($agt, 'sco') !== false || strpos($agt, 'unix_sv') !== false;
  374.             $os['unixware'] = strpos($agt, 'unix_system_v') !== false; 
  375.             $os['mpras']    = strpos($agt, 'ncr') !== false; 
  376.             $os['reliant']  = strpos($agt, 'reliant') !== false;
  377.             $os['dec']      = strpos($agt, 'dec') !== false || strpos($agt, 'osf1') !== false || strpos($agt, 'dec_alpha') !== false || strpos($agt, 'alphaserver') !== false || strpos($agt, 'ultrix') !== false || strpos($agt, 'alphastation') !== false;
  378.             $os['sinix']    = strpos($agt, 'sinix') !== false;
  379.             $os['freebsd']  = strpos($agt, 'freebsd') !== false;
  380.             $os['bsd']      = strpos($agt, 'bsd') !== false;
  381.             $os['unix']     = strpos($agt, 'x11') !== false || strpos($agt, 'unix') !== false || $os['sun'] || $os['irix'] || $os['hpux'] || $os['sco'] || $os['unixware'] || $os['mpras'] || $os['reliant'] || $os['dec'] || $os['sinix'] || $os['aix'] || $os['linux'] || $os['bsd'] || $os['freebsd'];
  382.             $os['vms']      = strpos($agt, 'vax') !== false || strpos($agt, 'openvms') !== false;
  383.         }
  384.  
  385.         // Setup the quirks
  386.         if ($detectFlags[NET_USERAGENT_DETECT_ALL] || 
  387.             ($detectFlags[NET_USERAGENT_DETECT_BROWSER] && $detectFlags[NET_USERAGENT_DETECT_QUIRKS])) {
  388.             if ($browser['konq']) {
  389.                 Net_UserAgent_Detect::setQuirk('empty_file_input_value');
  390.             }
  391.  
  392.             if ($browser['ie']) {
  393.                 Net_UserAgent_Detect::setQuirk('cache_ssl_downloads');
  394.             }
  395.  
  396.             if ($browser['ie6']) {
  397.                 Net_UserAgent_Detect::setQuirk('scrollbar_in_way');
  398.             }
  399.  
  400.             if ($browser['ie5']) {
  401.                 Net_UserAgent_Detect::setQuirk('break_disposition_header');
  402.             }
  403.  
  404.             if ($browser['ie7']) {
  405.                 Net_UserAgent_Detect::setQuirk('popups_disabled');
  406.             }
  407.  
  408.             if ($browser['ns6']) {
  409.                 Net_UserAgent_Detect::setQuirk('popups_disabled');
  410.                 Net_UserAgent_Detect::setQuirk('must_cache_forms');
  411.             }
  412.             
  413.             if ($browser['nav'] && $subVersion < .79) {
  414.                 Net_UserAgent_Detect::setQuirk('nested_table_render_bug');
  415.             }
  416.         }
  417.             
  418.         // Set features
  419.         if ($detectFlags[NET_USERAGENT_DETECT_ALL] || 
  420.             ($detectFlags[NET_USERAGENT_DETECT_BROWSER] && $detectFlags[NET_USERAGENT_DETECT_FEATURES])) {
  421.             if ($browser['gecko'] && preg_match(';gecko/([\d]+)\b;i', $agt, $matches)) {
  422.                 Net_UserAgent_Detect::setFeature('gecko', $matches[1]);
  423.             }
  424.  
  425.             if ($browser['gecko'] || ($browser['ie5up'] && !$browser['iemobile']) || $browser['konq'] || $browser['opera8up'] && !$os['wince']) {
  426.                 Net_UserAgent_Detect::setFeature('ajax');
  427.             }
  428.  
  429.             if ($browser['ns6up'] || $browser['opera5up'] || $browser['konq'] || $browser['netgem']) {
  430.                 Net_UserAgent_Detect::setFeature('dom');
  431.             }
  432.  
  433.             if ($browser['ie4up'] || $browser['ns4up'] || $browser['opera5up'] || $browser['konq'] || $browser['netgem']) {
  434.                 Net_UserAgent_Detect::setFeature('dhtml');
  435.             }
  436.  
  437.             if ($browser['firefox1.5'] || $browser['firefox2.x'] || $browser['opera9up']) {
  438.                 Net_UserAgent_Detect::setFeature('svg');
  439.             }
  440.  
  441.             if ($browser['gecko'] || $browser['ns6up'] || $browser['ie5up'] || $browser['konq'] || $browser['opera7up']) {
  442.                 Net_UserAgent_Detect::setFeature('css2');
  443.             }
  444.         }
  445.  
  446.         if ($detectFlags[NET_USERAGENT_DETECT_ALL] || $detectFlags[NET_USERAGENT_DETECT_ACCEPT]) {
  447.             $mimetypes = preg_split(';[\s,]+;', substr(getenv('HTTP_ACCEPT'), 0, strpos(getenv('HTTP_ACCEPT') . ';', ';')), -1, PREG_SPLIT_NO_EMPTY);
  448.             Net_UserAgent_Detect::setAcceptType((array) $mimetypes, 'mimetype');
  449.  
  450.             $languages = preg_split(';[\s,]+;', substr(getenv('HTTP_ACCEPT_LANGUAGE'), 0, strpos(getenv('HTTP_ACCEPT_LANGUAGE') . ';', ';')), -1, PREG_SPLIT_NO_EMPTY);
  451.             if (empty($languages)) {
  452.                 $languages = 'en';
  453.             }
  454.  
  455.             Net_UserAgent_Detect::setAcceptType((array) $languages, 'language');
  456.  
  457.             $encodings = preg_split(';[\s,]+;', substr(getenv('HTTP_ACCEPT_ENCODING'), 0, strpos(getenv('HTTP_ACCEPT_ENCODING') . ';', ';')), -1, PREG_SPLIT_NO_EMPTY);
  458.             Net_UserAgent_Detect::setAcceptType((array) $encodings, 'encoding');
  459.             
  460.             $charsets = preg_split(';[\s,]+;', substr(getenv('HTTP_ACCEPT_CHARSET'), 0, strpos(getenv('HTTP_ACCEPT_CHARSET') . ';', ';')), -1, PREG_SPLIT_NO_EMPTY);
  461.             Net_UserAgent_Detect::setAcceptType((array) $charsets, 'charset');
  462.         }
  463.     }
  464.     
  465.     // }}}
  466.     // {{{ setOption()
  467.  
  468.     /**
  469.      * Sets a class option.  The available settings are:
  470.      * o 'userAgent' => The user agent string to detect (useful for
  471.      * checking a string manually).
  472.      * o 'detectOptions' => The level of checking to do.  A single level
  473.      * or an array of options.  Default is NET_USERAGENT_DETECT_ALL.
  474.      *
  475.      * @param string $in_field The option field (userAgent or detectOptions)
  476.      * @param mixed $in_value The value for the field
  477.      */
  478.     function setOption($in_field, $in_value)
  479.     {
  480.         $options = &Net_UserAgent_Detect::_getStaticProperty('options');
  481.         $options[$in_field] = $in_value;
  482.     }
  483.  
  484.     // }}}
  485.     // {{{ isBrowser()
  486.  
  487.     /**
  488.      * Look up the provide browser flag and return a boolean value
  489.      *
  490.      * Given one of the flags listed in the properties, this function will return
  491.      * the value associated with that flag.
  492.      *
  493.      * @param  string $in_match flag to lookup
  494.      *
  495.      * @access public
  496.      * @return boolean whether or not the browser satisfies this flag
  497.      */
  498.     function isBrowser($in_match)
  499.     {
  500.         Net_UserAgent_Detect::detect();
  501.         $browser = &Net_UserAgent_Detect::_getStaticProperty('browser');
  502.         return isset($browser[strtolower($in_match)]) ? $browser[strtolower($in_match)] : false;
  503.     }
  504.  
  505.     // }}}
  506.     // {{{ getBrowser()
  507.  
  508.     /**
  509.      * Since simply returning the "browser" is somewhat ambiguous since there
  510.      * are different ways to classify the browser, this function works by taking
  511.      * an expect list and returning the string of the first match, so put the important
  512.      * ones first in the array.
  513.      *
  514.      * @param  array $in_expectList the browser flags to search for
  515.      *
  516.      * @access public
  517.      * @return string first flag that matches
  518.      */
  519.     function getBrowser($in_expectList)
  520.     {
  521.         Net_UserAgent_Detect::detect();
  522.         $browser = &Net_UserAgent_Detect::_getStaticProperty('browser');
  523.         foreach((array) $in_expectList as $brwsr) {
  524.             if (!empty($browser[strtolower($brwsr)])) {
  525.                 return $brwsr;
  526.             }
  527.         }
  528.     }
  529.  
  530.     // }}}
  531.     // {{{ getBrowserString()
  532.  
  533.     /**
  534.      * This function returns the vendor string corresponding to the flag.
  535.      *
  536.      * Either use the default matches or pass in an associative array of
  537.      * flags and corresponding vendor strings.  This function will find
  538.      * the highest version flag and return the vendor string corresponding
  539.      * to the appropriate flag.  Be sure to pass in the flags in ascending order
  540.      * if you want a basic matches first, followed by more detailed matches.
  541.      *
  542.      * @param  array $in_vendorStrings (optional) array of flags matched with vendor strings
  543.      *
  544.      * @access public
  545.      * @return string vendor string matches appropriate flag
  546.      */
  547.     function getBrowserString($in_vendorStrings = null)
  548.     {
  549.         if (is_null($in_vendorStrings)) {
  550.             $in_vendorStrings = array (
  551.                     'ie'       => 'Microsoft Internet Explorer',
  552.                     'ie4up'    => 'Microsoft Internet Explorer 4.x',
  553.                     'ie5up'    => 'Microsoft Internet Explorer 5.x',
  554.                     'ie6up'    => 'Microsoft Internet Explorer 6.x',
  555.                     'ie7up'    => 'Microsoft Internet Explorer 7.x',
  556.                     'ie8up'    => 'Microsoft Internet Explorer 8.x',
  557.                     'ie8tr'    => 'Microsoft Internet Explorer 8.x (Compatibility View)', 
  558.                     'ie9up'    => 'Microsoft Internet Explorer 9.x',
  559.                     'opera4'   => 'Opera 4.x',
  560.                     'opera5up' => 'Opera 5.x',
  561.                     'nav'      => 'Netscape Navigator',
  562.                     'ns4'      => 'Netscape 4.x',
  563.                     'ns6up'    => 'Mozilla/Netscape 6.x',
  564.                     'firefox0.x' => 'Firefox 0.x',
  565.                     'firefox1.x' => 'Firefox 1.x',
  566.                     'firefox1.5' => 'Firefox 1.5',
  567.                     'firefox2.x' => 'Firefox 2.x',
  568.                     'firefox3.x' => 'Firefox 3.x',
  569.                     'konq'     => 'Konqueror',
  570.                     'safari'   => 'Safari',
  571.                     'safari_mobile'     => 'Safari Mobile',
  572.                     'chrome'   => 'Google Chrome',
  573.                     'netgem'   => 'Netgem/iPlayer');
  574.         }
  575.  
  576.         Net_UserAgent_Detect::detect();
  577.         $browser = &Net_UserAgent_Detect::_getStaticProperty('browser');
  578.         foreach((array) $in_vendorStrings as $flag => $string) {
  579.             if (!empty($browser[$flag])) {
  580.                 $vendorString = $string;
  581.             }
  582.         }
  583.  
  584.         // if there are no matches just use the user agent leading idendifier (usually Mozilla)
  585.         if (!isset($vendorString)) {
  586.             $leadingIdentifier = &Net_UserAgent_Detect::_getStaticProperty('leadingIdentifier');
  587.             $vendorString = $leadingIdentifier;
  588.         }
  589.         
  590.         return $vendorString;
  591.     }
  592.  
  593.     // }}}
  594.     // {{{ isIE()
  595.  
  596.     /**
  597.      * Determine if the browser is an Internet Explorer browser
  598.      *
  599.      * @access public
  600.      * @return bool whether or not this browser is an ie browser
  601.      */
  602.     function isIE()
  603.     {
  604.         Net_UserAgent_Detect::detect();
  605.         $browser = &Net_UserAgent_Detect::_getStaticProperty('browser');
  606.         return !empty($browser['ie']);
  607.     }
  608.  
  609.     // }}}
  610.     // {{{ isNavigator()
  611.  
  612.     /**
  613.      * Determine if the browser is a Netscape Navigator browser
  614.      *
  615.      * @access public
  616.      * @return bool whether or not this browser is a Netscape Navigator browser
  617.      */
  618.     function isNavigator()
  619.     {
  620.         Net_UserAgent_Detect::detect();
  621.         $browser = &Net_UserAgent_Detect::_getStaticProperty('browser');
  622.         return !empty($browser['nav']);
  623.     }
  624.  
  625.     // }}}
  626.     // {{{ isNetscape()
  627.  
  628.     /**
  629.      * Determine if the browser is a Netscape or Mozilla browser
  630.      *
  631.      * Note that this function is not the same as isNavigator, since the
  632.      * new Mozilla browsers are still sponsered by Netscape, and hence are
  633.      * Netscape products, but not the original Navigators
  634.      *
  635.      * @access public
  636.      * @return bool whether or not this browser is a Netscape product
  637.      */
  638.     function isNetscape()
  639.     {
  640.         Net_UserAgent_Detect::detect();
  641.         $browser = &Net_UserAgent_Detect::_getStaticProperty('browser');
  642.         return !empty($browser['ns4up']);
  643.     }
  644.     
  645.     // }}}
  646.     // {{{ isOS()
  647.  
  648.     /**
  649.      * Look up the provide OS flag and return a boolean value
  650.      *
  651.      * Given one of the flags listed in the properties, this function will return
  652.      * the value associated with that flag for the operating system.
  653.      *
  654.      * @param  string $in_match flag to lookup
  655.      *
  656.      * @access public
  657.      * @return boolean whether or not the OS satisfies this flag
  658.      */
  659.     function isOS($in_match)
  660.     {
  661.         Net_UserAgent_Detect::detect();
  662.         $os = &Net_UserAgent_Detect::_getStaticProperty('os');
  663.         return isset($os[strtolower($in_match)]) ? $os[strtolower($in_match)] : false;
  664.     }
  665.  
  666.     // }}}
  667.     // {{{ getOS()
  668.  
  669.     /**
  670.      * Since simply returning the "os" is somewhat ambiguous since there
  671.      * are different ways to classify the browser, this function works by taking
  672.      * an expect list and returning the string of the first match, so put the important
  673.      * ones first in the array.
  674.      *
  675.      * @access public
  676.      * @return string first flag that matches
  677.      */
  678.     function getOS($in_expectList)
  679.     {
  680.         Net_UserAgent_Detect::detect();
  681.         $os = &Net_UserAgent_Detect::_getStaticProperty('os');
  682.         foreach((array) $in_expectList as $expectOs) {
  683.             if (!empty($os[strtolower($expectOs)])) {
  684.                 return $expectOs;
  685.             }
  686.         }
  687.     }
  688.  
  689.     // }}}
  690.     // {{{ getOSString()
  691.  
  692.     /**
  693.      * This function returns the os string corresponding to the flag.
  694.      *
  695.      * Either use the default matches or pass in an associative array of
  696.      * flags and corresponding os strings.  This function will find
  697.      * the highest version flag and return the os string corresponding
  698.      * to the appropriate flag.  Be sure to pass in the flags in ascending order
  699.      * if you want a basic matches first, followed by more detailed matches.
  700.      *
  701.      * @param  array $in_osStrings (optional) array of flags matched with os strings
  702.      *
  703.      * @access public
  704.      * @return string os string matches appropriate flag
  705.      */
  706.     function getOSString($in_osStrings = null)
  707.     {
  708.         if (is_null($in_osStrings)) {
  709.             $in_osStrings = array(
  710.                    'win'   => 'Microsoft Windows',
  711.                    'wince' => 'Microsoft Windows CE',
  712.                    'win9x' => 'Microsoft Windows 9x',
  713.                    'winme' => 'Microsoft Windows Millenium',
  714.                    'win2k' => 'Microsoft Windows 2000',
  715.                    'winnt' => 'Microsoft Windows NT',
  716.                    'winxp' => 'Microsoft Windows XP',
  717.                    'win2003' => 'Microsoft Windows 2003',
  718.                    'vista' => 'Microsoft Windows Vista',
  719.                    'win7' => 'Microsoft Windows 7', 
  720.                    'mac'   => 'Macintosh',
  721.                    'mactiger' => 'OS X Tiger (10.4)',
  722.                    'macleopard' => 'OS X Leopard (10.5)',
  723.                    'macsnowleopard' => 'OS X Snow Leopard (10.6)',
  724.                    'iphone' => 'iPhone',
  725.                    'os2' => 'OS/2',
  726.                    'unix'  => 'Linux/Unix');
  727.         }
  728.  
  729.         Net_UserAgent_Detect::detect();
  730.         $osString = 'Unknown';
  731.  
  732.         $os = &Net_UserAgent_Detect::_getStaticProperty('os');
  733.         foreach((array) $in_osStrings as $flag => $string) {
  734.             if (!empty($os[$flag])) {
  735.                 $osString = $string;
  736.             }
  737.         }
  738.  
  739.         return $osString;
  740.     }
  741.  
  742.     // }}}
  743.     // {{{ setQuirk()
  744.  
  745.     /**
  746.      * Set a unique behavior for the current browser.
  747.      *
  748.      * Many client browsers do some really funky things, and this
  749.      * mechanism allows the coder to determine if an excepetion must
  750.      * be made with the current client.
  751.      *
  752.      * @param string $in_quirk The quirk to set
  753.      * @param string $in_hasQuirk (optional) Does the browser have the quirk?
  754.      *
  755.      * @access public
  756.      * @return void 
  757.      */
  758.     function setQuirk($in_quirk, $in_hasQuirk = true)
  759.     {
  760.         $quirks = &Net_UserAgent_Detect::_getStaticProperty('quirks');
  761.         $hasQuirk = !empty($in_hasQuirk); 
  762.         $quirks[strtolower($in_quirk)] = $hasQuirk;
  763.     }
  764.  
  765.     // }}}
  766.     // {{{ hasQuirk()
  767.  
  768.     /**
  769.      * Check a unique behavior for the current browser.
  770.      *
  771.      * Many client browsers do some really funky things, and this
  772.      * mechanism allows the coder to determine if an excepetion must
  773.      * be made with the current client.
  774.      *
  775.      * @param string $in_quirk The quirk to detect
  776.      *
  777.      * @access public
  778.      * @return bool whether or not browser has this quirk
  779.      */
  780.     function hasQuirk($in_quirk)
  781.     {
  782.         return (bool) Net_UserAgent_Detect::getQuirk($in_quirk);
  783.     }
  784.     
  785.     // }}}
  786.     // {{{ getQuirk()
  787.  
  788.     /**
  789.      * Get the unique behavior for the current browser.
  790.      *
  791.      * Many client browsers do some really funky things, and this
  792.      * mechanism allows the coder to determine if an excepetion must
  793.      * be made with the current client.
  794.      *
  795.      * @param string $in_quirk The quirk to detect
  796.      *
  797.      * @access public
  798.      * @return string value of the quirk, in this case usually a boolean
  799.      */
  800.     function getQuirk($in_quirk)
  801.     {
  802.         Net_UserAgent_Detect::detect();
  803.         $quirks = &Net_UserAgent_Detect::_getStaticProperty('quirks');
  804.         return isset($quirks[strtolower($in_quirk)]) ? $quirks[strtolower($in_quirk)] : null; 
  805.     }
  806.  
  807.     // }}}
  808.     // {{{ setFeature()
  809.  
  810.     /**
  811.      * Set capabilities for the current browser.
  812.      *
  813.      * Since the capabilities of client browsers vary widly, this interface
  814.      * helps keep track of the core features of a client, such as if the client
  815.      * supports dhtml, dom, javascript, etc.
  816.      *
  817.      * @param string $in_feature The feature to set
  818.      * @param string $in_hasFeature (optional) Does the browser have the feature?
  819.      *
  820.      * @access public
  821.      * @return void 
  822.      */
  823.     function setFeature($in_feature, $in_hasFeature = true)
  824.     {
  825.         $features = &Net_UserAgent_Detect::_getStaticProperty('features');
  826.         $features[strtolower($in_feature)] = $in_hasFeature;
  827.     }
  828.  
  829.     // }}}
  830.     // {{{ hasFeature()
  831.  
  832.     /**
  833.      * Check the capabilities for the current browser.
  834.      *
  835.      * Since the capabilities of client browsers vary widly, this interface
  836.      * helps keep track of the core features of a client, such as if the client
  837.      * supports dhtml, dom, javascript, etc.
  838.      *
  839.      * @param string $in_feature The feature to detect
  840.      *
  841.      * @access public
  842.      * @return bool whether or not the current client has this feature
  843.      */
  844.     function hasFeature($in_feature)
  845.     {
  846.         return (bool) Net_UserAgent_Detect::getFeature($in_feature);
  847.     }
  848.     
  849.     // }}}
  850.     // {{{ getFeature()
  851.  
  852.     /**
  853.      * Get the capabilities for the current browser.
  854.      *
  855.      * Since the capabilities of client browsers vary widly, this interface
  856.      * helps keep track of the core features of a client, such as if the client
  857.      * supports dhtml, dom, javascript, etc.
  858.      *
  859.      * @param string $in_feature The feature to detect
  860.      *
  861.      * @access public
  862.      * @return string value of the feature requested
  863.      */
  864.     function getFeature($in_feature)
  865.     {
  866.         Net_UserAgent_Detect::detect();
  867.         $features = &Net_UserAgent_Detect::_getStaticProperty('features');
  868.         return isset($features[strtolower($in_feature)]) ? $features[strtolower($in_feature)] : null; 
  869.     }
  870.  
  871.     // }}}
  872.     // {{{ getAcceptType()
  873.  
  874.     /**
  875.      * Retrive the accept type for the current browser.
  876.      *
  877.      * To keep track of the mime-types, languages, charsets and encodings
  878.      * that each browser accepts we use associative arrays for each type.
  879.      * This function works like getBrowser() as it takes an expect list
  880.      * and returns the first match.  For instance, to find the language
  881.      * you would pass in your allowed languages and see if any of the
  882.      * languages set in the browser match.
  883.      *
  884.      * @param  string $in_expectList values to check
  885.      * @param  string $in_type type of accept
  886.      *
  887.      * @access public
  888.      * @return string the first matched value
  889.      */
  890.     function getAcceptType($in_expectList, $in_type)
  891.     {
  892.         Net_UserAgent_Detect::detect();
  893.         $type = strtolower($in_type);
  894.  
  895.         if ($type == 'mimetype' || $type == 'language' || $type == 'charset' || $type == 'encoding') {
  896.             $typeArray = &Net_UserAgent_Detect::_getStaticProperty($type);
  897.             foreach((array) $in_expectList as $match) {
  898.                 if (!empty($typeArray[$match])) {
  899.                     return $match;
  900.                 }
  901.             }
  902.         }
  903.  
  904.         return null;
  905.     }
  906.  
  907.     // }}}
  908.     // {{{ setAcceptType()
  909.  
  910.     /**
  911.      * Set the accept types for the current browser.
  912.      *
  913.      * To keep track of the mime-types, languages, charsets and encodings
  914.      * that each browser accepts we use associative arrays for each type.
  915.      * This function takes and array of accepted values for the type and
  916.      * records them for retrieval.
  917.      *
  918.      * @param  array $in_values values of the accept type
  919.      * @param  string $in_type type of accept
  920.      *
  921.      * @access public
  922.      * @return void 
  923.      */
  924.     function setAcceptType($in_values, $in_type)
  925.     {
  926.         $type = strtolower($in_type);
  927.  
  928.         if ($type == 'mimetype' || $type == 'language' || $type == 'charset' || $type == 'encoding') {
  929.             $typeArray = &Net_UserAgent_Detect::_getStaticProperty($type);
  930.             foreach((array) $in_values as $value) {
  931.                 $typeArray[$value] = true;
  932.             }
  933.         }
  934.     }
  935.  
  936.     // }}}
  937.     // {{{ hasAcceptType()
  938.  
  939.     /**
  940.      * Check the accept types for the current browser.
  941.      *
  942.      * To keep track of the mime-types, languages, charsets and encodings
  943.      * that each browser accepts we use associative arrays for each type.
  944.      * This function checks the array for the given type and determines if
  945.      * the browser accepts it.
  946.      *
  947.      * @param  string $in_value values to check
  948.      * @param  string $in_type type of accept
  949.      *
  950.      * @access public
  951.      * @return bool whether or not the value is accept for this type
  952.      */
  953.     function hasAcceptType($in_value, $in_type)
  954.     {
  955.         return (bool) Net_UserAgent_Detect::getAcceptType((array) $in_value, $in_type);
  956.     }
  957.  
  958.     // }}}
  959.     // {{{ getUserAgent()
  960.  
  961.     /**
  962.      * Return the user agent string that is being worked on
  963.      *
  964.      * @access public
  965.      * @return string user agent
  966.      */
  967.     function getUserAgent()
  968.     {
  969.         Net_UserAgent_Detect::detect();
  970.         $userAgent = &Net_UserAgent_Detect::_getStaticProperty('userAgent');
  971.         return $userAgent;
  972.     }
  973.  
  974.     // }}}
  975.     // {{{ _getStaticProperty()
  976.  
  977.     /**
  978.      * Copy of getStaticProperty() from PEAR.php to avoid having to
  979.      * include PEAR.php
  980.      *
  981.      * @access private
  982.      * @param  string $var    The variable to retrieve.
  983.      * @return mixed   A reference to the variable. If not set it will be
  984.      *                  auto initialised to NULL.
  985.      */
  986.     function &_getStaticProperty($var)
  987.     {
  988.         static $properties;
  989.         return $properties[$var];
  990.     }
  991.  
  992.     // }}}
  993. }
  994. ?>

Documentation generated on Mon, 11 Mar 2019 15:37:06 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.