This week only. Pastebin PRO Accounts Christmas Special! Don't miss out!Want more features on Pastebin? Sign Up, it's FREE!
Guest

CloCkWeRX

By: a guest on Oct 14th, 2008  |  syntax: None  |  size: 32.54 KB  |  views: 176  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. Index: Detect.php
  2. ===================================================================
  3. RCS file: /repository/pear/Net_UserAgent/Detect.php,v
  4. retrieving revision 1.27
  5. diff -u -r1.27 Detect.php
  6. --- Detect.php  12 Oct 2008 00:33:10 -0000      1.27
  7. +++ Detect.php  14 Oct 2008 09:24:17 -0000
  8.  -1,37 +1,38 @@
  9.  <?php
  10. -// {{{ license
  11. -
  12. -// +----------------------------------------------------------------------+
  13. -// | PHP version 4.2                                                      |
  14. -// +----------------------------------------------------------------------+
  15. -// | Copyright (c) 1997-2007 The PHP Group                                |
  16. -// +----------------------------------------------------------------------+
  17. -// | This source file is subject to version 2.0 of the PHP license,       |
  18. -// | that is bundled with this package in the file LICENSE, and is        |
  19. -// | available at through the world-wide-web at                           |
  20. -// | http://www.php.net/license/2_02.txt.                                 |
  21. -// | If you did not receive a copy of the PHP license and are unable to   |
  22. -// | obtain it through the world-wide-web, please send a note to          |
  23. -// | license@php.net so we can mail you a copy immediately.               |
  24. -// +----------------------------------------------------------------------+
  25. -// | Authors: Dan Allen <dan@mojavelinux.com>                             |
  26. -// |          Jason Rust <jrust@php.net>                                  |
  27. -// +----------------------------------------------------------------------+
  28. -
  29. -// $Id: Detect.php,v 1.27 2008/10/12 00:33:10 jrust Exp $
  30. +/**
  31. + * Net_UserAgent_Detect.php
  32. + *
  33. + * PHP version 4.2
  34. + *
  35. + * Copyright (c) 1997-2003 The PHP Group                                
  36. + *
  37. + * This source file is subject to version 2.0 of the PHP license,      
  38. + * that is bundled with this package in the file LICENSE, and is        
  39. + * available at through the world-wide-web at                          
  40. + * http://www.php.net/license/2_02.txt.                                
  41. + * If you did not receive a copy of the PHP license and are unable to  
  42. + * obtain it through the world-wide-web, please send a note to          
  43. + * license@php.net so we can mail you a copy immediately.    
  44. + *
  45. + * @category Net
  46. + * @package  Net_UserAgent
  47. + * @author   Dan Allen <dan@mojavelinux.com>
  48. + * @author   Jason Rust <jrust@php.net>
  49. + * @license  http://www.php.net/license/2_02.txt PHP 2.0 Licence
  50. + * @version  CVS: $Id: AllTests.php,v 1.6 2008/09/18 17:31:48 till Exp $
  51. + * @link     http://pear.php.net/package/Net_UserAgent_Detect
  52. + */
  53.  
  54. -// }}}
  55.  // {{{ constants
  56.  
  57. -define('NET_USERAGENT_DETECT_BROWSER',  'browser');
  58. -define('NET_USERAGENT_DETECT_OS',       'os');
  59. +define('NET_USERAGENT_DETECT_BROWSER', 'browser');
  60. +define('NET_USERAGENT_DETECT_OS', 'os');
  61.  define('NET_USERAGENT_DETECT_FEATURES', 'features');
  62. -define('NET_USERAGENT_DETECT_QUIRKS',   'quirks');
  63. -define('NET_USERAGENT_DETECT_ACCEPT',   'accept');
  64. -define('NET_USERAGENT_DETECT_ALL',      'all');
  65. +define('NET_USERAGENT_DETECT_QUIRKS', 'quirks');
  66. +define('NET_USERAGENT_DETECT_ACCEPT', 'accept');
  67. +define('NET_USERAGENT_DETECT_ALL', 'all');
  68.  
  69.  // }}}
  70. -// {{{ class Net_UserAgent_Detect
  71.  
  72.  /**
  73.   * The Net_UserAgent_Detect object does a number of tests on an HTTP user
  74.  -45,17 +46,25 @@
  75.   * This module had many influences from the lib/Browser.php code in
  76.   * version 1.3 of Horde.
  77.   *
  78. + * @category Net
  79. + * @package  Net_UserAgent
  80.   * @author   Jason Rust <jrust@php.net>
  81.   * @author   Dan Allen <dan@mojavelinux.com>
  82.   * @author   Chuck Hagenbuch <chuck@horde.org>
  83.   * @author   Jon Parise <jon@horde.org>
  84. - * @package  Net_UserAgent
  85. + * @license  http://www.php.net/license/2_02.txt PHP 2.0 Licence
  86. + * @link     http://pear.php.net/package/Net_UserAgent_Detect
  87.   */
  88. -
  89. -// }}}
  90. -class Net_UserAgent_Detect {
  91. +class Net_UserAgent_Detect
  92. +{
  93.      // {{{ constructor
  94.  
  95. +    /**
  96. +     * Class constructor
  97. +     *
  98. +     * @param string $in_userAgent (optional) User agent override.  
  99. +     * @param mixed  $in_detect    (optional) The level of checking to do.
  100. +     */
  101.      function Net_UserAgent_Detect($in_userAgent = null, $in_detect = null)
  102.      {
  103.          $this->detect($in_userAgent, $in_detect);
  104.  -67,6 +76,9 @@
  105.      /**
  106.       * To be used in place of the contructor to return only open instance.
  107.       *
  108. +     * @param string $in_userAgent (optional) User agent override.  
  109. +     * @param mixed  $in_detect    (optional) The level of checking to do.
  110. +     *
  111.       * @access public
  112.       * @return object Net_UserAgent_Detect instance
  113.       */
  114.  -96,8 +108,8 @@
  115.       * this class statically then set all the parameters using th
  116.       * setOption()
  117.       *
  118. -     * @param  string $in_userAgent (optional) User agent override.  
  119. -     * @param  mixed $in_detect (optional) The level of checking to do.
  120. +     * @param string $in_userAgent (optional) User agent override.  
  121. +     * @param mixed  $in_detect    (optional) The level of checking to do.
  122.       *
  123.       * @access public
  124.       * @return void
  125.  -113,8 +125,13 @@
  126.          $hasRun = true;
  127.          // {{{ set up static properties
  128.  
  129. -        $in_userAgent = isset($options['userAgent']) && is_null($in_userAgent) ? $options['userAgent'] : $in_userAgent;
  130. -        $in_detect = isset($options['detectOptions']) && is_null($in_detect) ? $options['detectOptions'] : $in_detect;
  131. +        if (isset($options['userAgent']) && is_null($in_userAgent)) {
  132. +            $in_userAgent = $options['userAgent'];
  133. +        }
  134. +
  135. +        if (isset($options['detectOptions']) && is_null($in_detect)) {
  136. +            $in_detect = $options['detectOptions'];
  137. +        }
  138.  
  139.          // User agent string that is being analyzed
  140.          $userAgent = &Net_UserAgent_Detect::_getStaticProperty('userAgent');
  141.  -182,15 +199,12 @@
  142.          if (is_null($in_userAgent)) {
  143.              if (isset($_SERVER['HTTP_USER_AGENT'])) {
  144.                  $userAgent = $_SERVER['HTTP_USER_AGENT'];
  145. -            }
  146. -            elseif (isset($GLOBALS['HTTP_SERVER_VARS']['HTTP_USER_AGENT'])) {
  147. +            } elseif (isset($GLOBALS['HTTP_SERVER_VARS']['HTTP_USER_AGENT'])) {
  148.                  $userAgent = $GLOBALS['HTTP_SERVER_VARS']['HTTP_USER_AGENT'];
  149. -            }
  150. -            else {
  151. +            } else {
  152.                  $userAgent = '';
  153.              }
  154. -        }
  155. -        else {
  156. +        } else {
  157.              $userAgent = $in_userAgent;
  158.          }
  159.  
  160.  -202,15 +216,12 @@
  161.                  NET_USERAGENT_DETECT_OS, NET_USERAGENT_DETECT_FEATURES,
  162.                  NET_USERAGENT_DETECT_QUIRKS, NET_USERAGENT_DETECT_ACCEPT,
  163.                  NET_USERAGENT_DETECT_ALL);
  164. +
  165.          $detect = is_null($in_detect) ? NET_USERAGENT_DETECT_ALL : $in_detect;
  166. +
  167.          settype($detect, 'array');
  168. -        foreach($detectOptions as $option) {
  169. -            if (in_array($option, $detect)) {
  170. -                $detectFlags[$option] = true;
  171. -            }
  172. -            else {
  173. -                $detectFlags[$option] = false;
  174. -            }
  175. +        foreach ($detectOptions as $option) {
  176. +            $detectFlags[$option] = in_array($option, $detect);
  177.          }
  178.  
  179.          // initialize the arrays of browsers and operating systems
  180.  -228,30 +239,37 @@
  181.      
  182.          // Browser type
  183.          if ($detectFlags[NET_USERAGENT_DETECT_ALL] || $detectFlags[NET_USERAGENT_DETECT_BROWSER]) {
  184. -            $browser['webdav']  = ($agt == 'microsoft data access internet publishing provider dav' || $agt == 'microsoft data access internet publishing provider protocol discovery');
  185. -            $browser['konq'] = (strpos($agt, 'konqueror') !== false ||  strpos($agt, 'safari') !== false );
  186. +            $browser['webdav'] = ($agt == 'microsoft data access internet publishing provider dav' || $agt == 'microsoft data access internet publishing provider protocol discovery');
  187. +            $browser['konq']   = (strpos($agt, 'konqueror') !== false ||  strpos($agt, 'safari') !== false );
  188.              $browser['safari'] = (strpos($agt, 'safari') !== false);
  189.              $browser['chrome'] = (strpos($agt, 'chrome') !== false);
  190. +
  191.              $browser['safari_mobile'] = (strpos($agt, 'safari') !== false && strpos($agt, 'mobile') !== false );
  192. -            $browser['text']    = strpos($agt, 'links') !== false || strpos($agt, 'lynx') !== false || strpos($agt, 'w3m') !== false;
  193. -            $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;
  194. -            $browser['netgem']  = strpos($agt, 'netgem') !== false;
  195. -            $browser['icab']    = strpos($agt, 'icab') !== false;
  196. -            $browser['ns2']     = $browser['ns'] && $majorVersion == 2;
  197. -            $browser['ns3']     = $browser['ns'] && $majorVersion == 3;
  198. -            $browser['ns4']     = $browser['ns'] && $majorVersion == 4;
  199. -            $browser['ns4up']   = $browser['ns'] && $majorVersion >= 4;
  200. +
  201. +            $browser['text']   = strpos($agt, 'links') !== false || strpos($agt, 'lynx') !== false || strpos($agt, 'w3m') !== false;
  202. +            $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;
  203. +            $browser['netgem'] = strpos($agt, 'netgem') !== false;
  204. +            $browser['icab']   = strpos($agt, 'icab') !== false;
  205. +            $browser['ns2']    = $browser['ns'] && $majorVersion == 2;
  206. +            $browser['ns3']    = $browser['ns'] && $majorVersion == 3;
  207. +            $browser['ns4']    = $browser['ns'] && $majorVersion == 4;
  208. +            $browser['ns4up']  = $browser['ns'] && $majorVersion >= 4;
  209. +
  210.              // determine if this is a Netscape Navigator
  211. -            $browser['nav'] = $browser['belowns6'] = $browser['ns'] && $majorVersion < 5;
  212. -            $browser['ns6']     = !$browser['konq'] && $browser['ns'] && $majorVersion == 5;
  213. -            $browser['ns6up']   = $browser['ns6'] && $majorVersion >= 5;
  214. -            $browser['gecko']   = strpos($agt, 'gecko') !== false && !$browser['konq'];
  215. -            $browser['firefox'] = $browser['gecko'] && strpos($agt, 'firefox') !== false;
  216. +            $browser['belowns6'] = $browser['ns'] && $majorVersion < 5;
  217. +
  218. +            $browser['nav']   = $browser['belowns6'];
  219. +            $browser['ns6']   = !$browser['konq'] && $browser['ns'] && $majorVersion == 5;
  220. +            $browser['ns6up'] = $browser['ns6'] && $majorVersion >= 5;
  221. +
  222. +            $browser['gecko']      = strpos($agt, 'gecko') !== false && !$browser['konq'];
  223. +            $browser['firefox']    = $browser['gecko'] && strpos($agt, 'firefox') !== false;
  224.              $browser['firefox0.x'] = $browser['firefox'] && strpos($agt, 'firefox/0.') !== false;
  225.              $browser['firefox1.x'] = $browser['firefox'] && strpos($agt, 'firefox/1.') !== false;
  226.              $browser['firefox1.5'] = $browser['firefox'] && strpos($agt, 'firefox/1.5') !== false;
  227.              $browser['firefox2.x'] = $browser['firefox'] && strpos($agt, 'firefox/2.') !== false;
  228.              $browser['firefox3.x'] = $browser['firefox'] && strpos($agt, 'firefox/3.') !== false;
  229. +
  230.              $browser['ie']      = strpos($agt, 'msie') !== false && !(strpos($agt, 'opera') !== false);
  231.              $browser['ie3']     = $browser['ie'] && $majorVersion < 4;
  232.              $browser['ie4']     = $browser['ie'] && $majorVersion == 4 && (strpos($agt, 'msie 4') !== false);
  233.  -264,22 +282,26 @@
  234.              $browser['ie6up']   = $browser['ie5up'] && !$browser['ie5'] && !$browser['ie5_5'];
  235.              $browser['ie7']     = strpos($agt, 'msie 7') !== false;
  236.              $browser['ie7up']   = $browser['ie6up'] && !$browser['ie6'];
  237. -            $browser['belowie6']= $browser['ie'] && !$browser['ie6up'];
  238. -            $browser['opera']   = strpos($agt, 'opera') !== false;
  239. -            $browser['opera2']  = strpos($agt, 'opera 2') !== false || strpos($agt, 'opera/2') !== false;
  240. -            $browser['opera3']  = strpos($agt, 'opera 3') !== false || strpos($agt, 'opera/3') !== false;
  241. -            $browser['opera4']  = strpos($agt, 'opera 4') !== false || strpos($agt, 'opera/4') !== false;
  242. -            $browser['opera5']  = strpos($agt, 'opera 5') !== false || strpos($agt, 'opera/5') !== false;
  243. -            $browser['opera6']  = strpos($agt, 'opera 6') !== false || strpos($agt, 'opera/6') !== false;
  244. -            $browser['opera7']  = strpos($agt, 'opera 7') !== false || strpos($agt, 'opera/7') !== false;
  245. -            $browser['opera8']  = strpos($agt, 'opera 8') !== false || strpos($agt, 'opera/8') !== false;
  246. -            $browser['opera9']  = strpos($agt, 'opera 9') !== false || strpos($agt, 'opera/9') !== false;
  247. +
  248. +            $browser['belowie6'] = $browser['ie'] && !$browser['ie6up'];
  249. +
  250. +            $browser['opera']    = strpos($agt, 'opera') !== false;
  251. +            $browser['opera2']   = strpos($agt, 'opera 2') !== false || strpos($agt, 'opera/2') !== false;
  252. +            $browser['opera3']   = strpos($agt, 'opera 3') !== false || strpos($agt, 'opera/3') !== false;
  253. +            $browser['opera4']   = strpos($agt, 'opera 4') !== false || strpos($agt, 'opera/4') !== false;
  254. +            $browser['opera5']   = strpos($agt, 'opera 5') !== false || strpos($agt, 'opera/5') !== false;
  255. +            $browser['opera6']   = strpos($agt, 'opera 6') !== false || strpos($agt, 'opera/6') !== false;
  256. +            $browser['opera7']   = strpos($agt, 'opera 7') !== false || strpos($agt, 'opera/7') !== false;
  257. +            $browser['opera8']   = strpos($agt, 'opera 8') !== false || strpos($agt, 'opera/8') !== false;
  258. +            $browser['opera9']   = strpos($agt, 'opera 9') !== false || strpos($agt, 'opera/9') !== false;
  259.              $browser['opera5up'] = $browser['opera'] && !$browser['opera2'] && !$browser['opera3'] && !$browser['opera4'];
  260.              $browser['opera6up'] = $browser['opera'] && !$browser['opera2'] && !$browser['opera3'] && !$browser['opera4'] && !$browser['opera5'];
  261.              $browser['opera7up'] = $browser['opera'] && !$browser['opera2'] && !$browser['opera3'] && !$browser['opera4'] && !$browser['opera5'] && !$browser['opera6'];
  262.              $browser['opera8up'] = $browser['opera'] && !$browser['opera2'] && !$browser['opera3'] && !$browser['opera4'] && !$browser['opera5'] && !$browser['opera6'] && !$browser['opera7'];
  263.              $browser['opera9up'] = $browser['opera'] && !$browser['opera2'] && !$browser['opera3'] && !$browser['opera4'] && !$browser['opera5'] && !$browser['opera6'] && !$browser['opera7'] && !$browser['opera8'];
  264. +
  265.              $browser['belowopera8'] = $browser['opera'] && !$browser['opera8up'];
  266. +
  267.              $browser['aol']   = strpos($agt, 'aol') !== false;
  268.              $browser['aol3']  = $browser['aol'] && $browser['ie3'];
  269.              $browser['aol4']  = $browser['aol'] && $browser['ie4'];
  270.  -289,10 +311,11 @@
  271.              $browser['aol8']  = strpos($agt, 'aol 8') !== false || strpos($agt, 'aol8') !== false;
  272.              $browser['webtv'] = strpos($agt, 'webtv') !== false;
  273.              $browser['aoltv'] = $browser['tvnavigator'] = strpos($agt, 'navio') !== false || strpos($agt, 'navio_aoltv') !== false;
  274. -            $browser['hotjava'] = strpos($agt, 'hotjava') !== false;
  275. -            $browser['hotjava3'] = $browser['hotjava'] && $majorVersion == 3;
  276. +
  277. +            $browser['hotjava']    = strpos($agt, 'hotjava') !== false;
  278. +            $browser['hotjava3']   = $browser['hotjava'] && $majorVersion == 3;
  279.              $browser['hotjava3up'] = $browser['hotjava'] && $majorVersion >= 3;
  280. -            $browser['iemobile'] = strpos($agt, 'iemobile') !== false || strpos($agt, 'windows ce') !== false && (strpos($agt, 'ppc') !== false || strpos($agt, 'smartphone') !== false);
  281. +            $browser['iemobile']   = strpos($agt, 'iemobile') !== false || strpos($agt, 'windows ce') !== false && (strpos($agt, 'ppc') !== false || strpos($agt, 'smartphone') !== false);
  282.          }
  283.  
  284.          if ($detectFlags[NET_USERAGENT_DETECT_ALL] ||
  285.  -300,48 +323,41 @@
  286.              // Javascript Check
  287.              if ($browser['ns2'] || $browser['ie3']) {
  288.                  Net_UserAgent_Detect::setFeature('javascript', 1.0);
  289. -            }
  290. -            elseif ($browser['iemobile']) {
  291. -              // no javascript
  292. -            }
  293. -            elseif ($browser['opera5up']) {
  294. +            } elseif ($browser['iemobile']) {
  295. +                // no javascript
  296. +            } elseif ($browser['opera5up']) {
  297.                  Net_UserAgent_Detect::setFeature('javascript', 1.3);
  298. -            }
  299. -            elseif ($browser['opera'] || $browser['ns3']) {
  300. +            } elseif ($browser['opera'] || $browser['ns3']) {
  301.                  Net_UserAgent_Detect::setFeature('javascript', 1.1);
  302. -            }
  303. -            elseif (($browser['ns4'] && ($version <= 4.05)) || $browser['ie4']) {
  304. +            } elseif (($browser['ns4'] && ($version <= 4.05)) || $browser['ie4']) {
  305.                  Net_UserAgent_Detect::setFeature('javascript', 1.2);
  306. -            }
  307. -            elseif (($browser['ie5up'] && strpos($agt, 'mac') !== false) || $browser['konq']) {
  308. +            } elseif (($browser['ie5up'] && strpos($agt, 'mac') !== false) || $browser['konq']) {
  309.                  Net_UserAgent_Detect::setFeature('javascript', 1.4);
  310. -            }
  311. -            // I can't believe IE6 still has javascript 1.3, what a shitty browser
  312. -            elseif (($browser['ns4'] && ($version > 4.05)) || $browser['ie5up'] || $browser['hotjava3up']) {
  313. +            } elseif (($browser['ns4'] && ($version > 4.05)) || $browser['ie5up'] || $browser['hotjava3up']) {
  314. +                // I can't believe IE6 still has javascript 1.3, what a shitty browser
  315.                  Net_UserAgent_Detect::setFeature('javascript', 1.3);
  316. -            }
  317. -            elseif ($browser['ns6up'] || $browser['gecko'] || $browser['netgem']) {
  318. +            } elseif ($browser['ns6up'] || $browser['gecko'] || $browser['netgem']) {
  319.                  Net_UserAgent_Detect::setFeature('javascript', 1.5);
  320.              }
  321.          }
  322.          
  323.          /** OS Check **/
  324.          if ($detectFlags[NET_USERAGENT_DETECT_ALL] || $detectFlags[NET_USERAGENT_DETECT_OS]) {
  325. -            $os['win']   = strpos($agt, 'win') !== false || strpos($agt, '16bit') !== false;
  326. -            $os['win95'] = strpos($agt, 'win95') !== false || strpos($agt, 'windows 95') !== false;
  327. -            $os['win16'] = strpos($agt, 'win16') !== false || strpos($agt, '16bit') !== false || strpos($agt, 'windows 3.1') !== false || strpos($agt, 'windows 16-bit') !== false;  
  328. -            $os['win31'] = strpos($agt, 'windows 3.1') !== false || strpos($agt, 'win16') !== false || strpos($agt, 'windows 16-bit') !== false;
  329. -            $os['winme'] = strpos($agt, 'win 9x 4.90') !== false;
  330. -            $os['wince'] = strpos($agt, 'windows ce') !== false;
  331. -            $os['win2k'] = strpos($agt, 'windows nt 5.0') !== false;
  332. -            $os['winxp'] = strpos($agt, 'windows nt 5.1') !== false;
  333. -            $os['win2003'] = strpos($agt, 'windows nt 5.2') !== false;
  334. -            $os['win98'] = strpos($agt, 'win98') !== false || strpos($agt, 'windows 98') !== false;
  335. -            $os['win9x'] = $os['win95'] || $os['win98'];
  336. -            $os['winnt'] = (strpos($agt, 'winnt') !== false || strpos($agt, 'windows nt') !== false) && strpos($agt, 'windows nt 5') === false;
  337. -            $os['win32'] = $os['win95'] || $os['winnt'] || $os['win98'] || $majorVersion >= 4 && strpos($agt, 'win32') !== false || strpos($agt, '32bit') !== false;
  338. -            $os['os2']   = strpos($agt, 'os/2') !== false || strpos($agt, 'ibm-webexplorer') !== false;
  339. -            $os['mac']   = strpos($agt, 'mac') !== false;
  340. +            $os['win']      = strpos($agt, 'win') !== false || strpos($agt, '16bit') !== false;
  341. +            $os['win95']    = strpos($agt, 'win95') !== false || strpos($agt, 'windows 95') !== false;
  342. +            $os['win16']    = strpos($agt, 'win16') !== false || strpos($agt, '16bit') !== false || strpos($agt, 'windows 3.1') !== false || strpos($agt, 'windows 16-bit') !== false;  
  343. +            $os['win31']    = strpos($agt, 'windows 3.1') !== false || strpos($agt, 'win16') !== false || strpos($agt, 'windows 16-bit') !== false;
  344. +            $os['winme']    = strpos($agt, 'win 9x 4.90') !== false;
  345. +            $os['wince']    = strpos($agt, 'windows ce') !== false;
  346. +            $os['win2k']    = strpos($agt, 'windows nt 5.0') !== false;
  347. +            $os['winxp']    = strpos($agt, 'windows nt 5.1') !== false;
  348. +            $os['win2003']  = strpos($agt, 'windows nt 5.2') !== false;
  349. +            $os['win98']    = strpos($agt, 'win98') !== false || strpos($agt, 'windows 98') !== false;
  350. +            $os['win9x']    = $os['win95'] || $os['win98'];
  351. +            $os['winnt']    = (strpos($agt, 'winnt') !== false || strpos($agt, 'windows nt') !== false) && strpos($agt, 'windows nt 5') === false;
  352. +            $os['win32']    = $os['win95'] || $os['winnt'] || $os['win98'] || $majorVersion >= 4 && strpos($agt, 'win32') !== false || strpos($agt, '32bit') !== false;
  353. +            $os['os2']      = strpos($agt, 'os/2') !== false || strpos($agt, 'ibm-webexplorer') !== false;
  354. +            $os['mac']      = strpos($agt, 'mac') !== false;
  355.              $os['mac68k']   = $os['mac'] && (strpos($agt, '68k') !== false || strpos($agt, '68000') !== false);
  356.              $os['macppc']   = $os['mac'] && (strpos($agt, 'ppc') !== false || strpos($agt, 'powerpc') !== false);
  357.              $os['sun']      = strpos($agt, 'sunos') !== false;
  358.  -464,11 +480,14 @@
  359.       * or an array of options.  Default is NET_USERAGENT_DETECT_ALL.
  360.       *
  361.       * @param string $in_field The option field (userAgent or detectOptions)
  362. -     * @param mixed $in_value The value for the field
  363. +     * @param mixed  $in_value The value for the field
  364. +     *
  365. +     * @return void
  366.       */
  367.      function setOption($in_field, $in_value)
  368.      {
  369.          $options = &Net_UserAgent_Detect::_getStaticProperty('options');
  370. +
  371.          $options[$in_field] = $in_value;
  372.      }
  373.  
  374.  -481,7 +500,7 @@
  375.       * Given one of the flags listed in the properties, this function will return
  376.       * the value associated with that flag.
  377.       *
  378. -     * @param  string $in_match flag to lookup
  379. +     * @param string $in_match flag to lookup
  380.       *
  381.       * @access public
  382.       * @return boolean whether or not the browser satisfies this flag
  383.  -490,7 +509,12 @@
  384.      {
  385.          Net_UserAgent_Detect::detect();
  386.          $browser = &Net_UserAgent_Detect::_getStaticProperty('browser');
  387. -        return isset($browser[strtolower($in_match)]) ? $browser[strtolower($in_match)] : false;
  388. +
  389. +        if (isset($browser[strtolower($in_match)])) {
  390. +            return $browser[strtolower($in_match)];
  391. +        }
  392. +
  393. +        return false;
  394.      }
  395.  
  396.      // }}}
  397.  -502,7 +526,7 @@
  398.       * an expect list and returning the string of the first match, so put the important
  399.       * ones first in the array.
  400.       *
  401. -     * @param  array $in_expectList the browser flags to search for
  402. +     * @param array $in_expectList the browser flags to search for
  403.       *
  404.       * @access public
  405.       * @return string first flag that matches
  406.  -511,7 +535,7 @@
  407.      {
  408.          Net_UserAgent_Detect::detect();
  409.          $browser = &Net_UserAgent_Detect::_getStaticProperty('browser');
  410. -        foreach((array) $in_expectList as $brwsr) {
  411. +        foreach ((array) $in_expectList as $brwsr) {
  412.              if (!empty($browser[strtolower($brwsr)])) {
  413.                  return $brwsr;
  414.              }
  415.  -530,7 +554,7 @@
  416.       * to the appropriate flag.  Be sure to pass in the flags in ascending order
  417.       * if you want a basic matches first, followed by more detailed matches.
  418.       *
  419. -     * @param  array $in_vendorStrings (optional) array of flags matched with vendor strings
  420. +     * @param array $in_vendorStrings (optional) array of flags matched with vendor strings
  421.       *
  422.       * @access public
  423.       * @return string vendor string matches appropriate flag
  424.  -563,7 +587,7 @@
  425.  
  426.          Net_UserAgent_Detect::detect();
  427.          $browser = &Net_UserAgent_Detect::_getStaticProperty('browser');
  428. -        foreach((array) $in_vendorStrings as $flag => $string) {
  429. +        foreach ((array) $in_vendorStrings as $flag => $string) {
  430.              if (!empty($browser[$flag])) {
  431.                  $vendorString = $string;
  432.              }
  433.  -572,7 +596,7 @@
  434.          // if there are no matches just use the user agent leading idendifier (usually Mozilla)
  435.          if (!isset($vendorString)) {
  436.              $leadingIdentifier = &Net_UserAgent_Detect::_getStaticProperty('leadingIdentifier');
  437. -            $vendorString = $leadingIdentifier;
  438. +            $vendorString      = $leadingIdentifier;
  439.          }
  440.          
  441.          return $vendorString;
  442.  -639,7 +663,7 @@
  443.       * Given one of the flags listed in the properties, this function will return
  444.       * the value associated with that flag for the operating system.
  445.       *
  446. -     * @param  string $in_match flag to lookup
  447. +     * @param string $in_match flag to lookup
  448.       *
  449.       * @access public
  450.       * @return boolean whether or not the OS satisfies this flag
  451.  -648,7 +672,12 @@
  452.      {
  453.          Net_UserAgent_Detect::detect();
  454.          $os = &Net_UserAgent_Detect::_getStaticProperty('os');
  455. -        return isset($os[strtolower($in_match)]) ? $os[strtolower($in_match)] : false;
  456. +
  457. +        if (isset($os[strtolower($in_match)])) {
  458. +            return $os[strtolower($in_match)];
  459. +        }
  460. +
  461. +        return false;
  462.      }
  463.  
  464.      // }}}
  465.  -657,8 +686,10 @@
  466.      /**
  467.       * Since simply returning the "os" is somewhat ambiguous since there
  468.       * are different ways to classify the browser, this function works by taking
  469. -     * an expect list and returning the string of the first match, so put the important
  470. -     * ones first in the array.
  471. +     * an expect list and returning the string of the first match, so put the
  472. +     * important ones first in the array.
  473. +     *
  474. +     * @param string[] $in_expectList Expected matches.
  475.       *
  476.       * @access public
  477.       * @return string first flag that matches
  478.  -667,7 +698,7 @@
  479.      {
  480.          Net_UserAgent_Detect::detect();
  481.          $os = &Net_UserAgent_Detect::_getStaticProperty('os');
  482. -        foreach((array) $in_expectList as $expectOs) {
  483. +        foreach ((array) $in_expectList as $expectOs) {
  484.              if (!empty($os[strtolower($expectOs)])) {
  485.                  return $expectOs;
  486.              }
  487.  -686,7 +717,7 @@
  488.       * to the appropriate flag.  Be sure to pass in the flags in ascending order
  489.       * if you want a basic matches first, followed by more detailed matches.
  490.       *
  491. -     * @param  array $in_osStrings (optional) array of flags matched with os strings
  492. +     * @param array $in_osStrings (optional) array of flags matched with os strings
  493.       *
  494.       * @access public
  495.       * @return string os string matches appropriate flag
  496.  -711,7 +742,7 @@
  497.          $osString = 'Unknown';
  498.  
  499.          $os = &Net_UserAgent_Detect::_getStaticProperty('os');
  500. -        foreach((array) $in_osStrings as $flag => $string) {
  501. +        foreach ((array) $in_osStrings as $flag => $string) {
  502.              if (!empty($os[$flag])) {
  503.                  $osString = $string;
  504.              }
  505.  -730,7 +761,7 @@
  506.       * mechanism allows the coder to determine if an excepetion must
  507.       * be made with the current client.
  508.       *
  509. -     * @param string $in_quirk The quirk to set
  510. +     * @param string $in_quirk    The quirk to set
  511.       * @param string $in_hasQuirk (optional) Does the browser have the quirk?
  512.       *
  513.       * @access public
  514.  -738,8 +769,9 @@
  515.       */
  516.      function setQuirk($in_quirk, $in_hasQuirk = true)
  517.      {
  518. -        $quirks = &Net_UserAgent_Detect::_getStaticProperty('quirks');
  519. +        $quirks   = &Net_UserAgent_Detect::_getStaticProperty('quirks');
  520.          $hasQuirk = !empty($in_hasQuirk);
  521. +
  522.          $quirks[strtolower($in_quirk)] = $hasQuirk;
  523.      }
  524.  
  525.  -782,7 +814,12 @@
  526.      {
  527.          Net_UserAgent_Detect::detect();
  528.          $quirks = &Net_UserAgent_Detect::_getStaticProperty('quirks');
  529. -        return isset($quirks[strtolower($in_quirk)]) ? $quirks[strtolower($in_quirk)] : null;
  530. +
  531. +        if (isset($quirks[strtolower($in_quirk)])) {
  532. +            return $quirks[strtolower($in_quirk)];
  533. +        }
  534. +
  535. +        return null;
  536.      }
  537.  
  538.      // }}}
  539.  -795,7 +832,7 @@
  540.       * helps keep track of the core features of a client, such as if the client
  541.       * supports dhtml, dom, javascript, etc.
  542.       *
  543. -     * @param string $in_feature The feature to set
  544. +     * @param string $in_feature    The feature to set
  545.       * @param string $in_hasFeature (optional) Does the browser have the feature?
  546.       *
  547.       * @access public
  548.  -804,6 +841,7 @@
  549.      function setFeature($in_feature, $in_hasFeature = true)
  550.      {
  551.          $features = &Net_UserAgent_Detect::_getStaticProperty('features');
  552. +
  553.          $features[strtolower($in_feature)] = $in_hasFeature;
  554.      }
  555.  
  556.  -846,7 +884,11 @@
  557.      {
  558.          Net_UserAgent_Detect::detect();
  559.          $features = &Net_UserAgent_Detect::_getStaticProperty('features');
  560. -        return isset($features[strtolower($in_feature)]) ? $features[strtolower($in_feature)] : null;
  561. +
  562. +        if (isset($features[strtolower($in_feature)])) {
  563. +            return $features[strtolower($in_feature)];
  564. +        }
  565. +        return null;
  566.      }
  567.  
  568.      // }}}
  569.  -862,8 +904,8 @@
  570.       * you would pass in your allowed languages and see if any of the
  571.       * languages set in the browser match.
  572.       *
  573. -     * @param  string $in_expectList values to check
  574. -     * @param  string $in_type type of accept
  575. +     * @param string $in_expectList values to check
  576. +     * @param string $in_type       type of accept
  577.       *
  578.       * @access public
  579.       * @return string the first matched value
  580.  -873,9 +915,10 @@
  581.          Net_UserAgent_Detect::detect();
  582.          $type = strtolower($in_type);
  583.  
  584. -        if ($type == 'mimetype' || $type == 'language' || $type == 'charset' || $type == 'encoding') {
  585. +        if ($type == 'mimetype' || $type == 'language'
  586. +            || $type == 'charset' || $type == 'encoding') {
  587.              $typeArray = &Net_UserAgent_Detect::_getStaticProperty($type);
  588. -            foreach((array) $in_expectList as $match) {
  589. +            foreach ((array) $in_expectList as $match) {
  590.                  if (!empty($typeArray[$match])) {
  591.                      return $match;
  592.                  }
  593.  -896,8 +939,8 @@
  594.       * This function takes and array of accepted values for the type and
  595.       * records them for retrieval.
  596.       *
  597. -     * @param  array $in_values values of the accept type
  598. -     * @param  string $in_type type of accept
  599. +     * @param array  $in_values values of the accept type
  600. +     * @param string $in_type   type of accept
  601.       *
  602.       * @access public
  603.       * @return void
  604.  -906,9 +949,10 @@
  605.      {
  606.          $type = strtolower($in_type);
  607.  
  608. -        if ($type == 'mimetype' || $type == 'language' || $type == 'charset' || $type == 'encoding') {
  609. +        if ($type == 'mimetype' || $type == 'language'
  610. +            || $type == 'charset' || $type == 'encoding') {
  611.              $typeArray = &Net_UserAgent_Detect::_getStaticProperty($type);
  612. -            foreach((array) $in_values as $value) {
  613. +            foreach ((array) $in_values as $value) {
  614.                  $typeArray[$value] = true;
  615.              }
  616.          }
  617.  -925,15 +969,16 @@
  618.       * This function checks the array for the given type and determines if
  619.       * the browser accepts it.
  620.       *
  621. -     * @param  string $in_value values to check
  622. -     * @param  string $in_type type of accept
  623. +     * @param string $in_value values to check
  624. +     * @param string $in_type  type of accept
  625.       *
  626.       * @access public
  627.       * @return bool whether or not the value is accept for this type
  628.       */
  629.      function hasAcceptType($in_value, $in_type)
  630.      {
  631. -        return (bool) Net_UserAgent_Detect::getAcceptType((array) $in_value, $in_type);
  632. +        return (bool) Net_UserAgent_Detect::getAcceptType((array) $in_value,
  633. +                                                          $in_type);
  634.      }
  635.  
  636.      // }}}
  637.  -959,8 +1004,9 @@
  638.       * Copy of getStaticProperty() from PEAR.php to avoid having to
  639.       * include PEAR.php
  640.       *
  641. +     * @param string $var The variable to retrieve.
  642. +     *
  643.       * @access private
  644. -     * @param  string $var    The variable to retrieve.
  645.       * @return mixed   A reference to the variable. If not set it will be
  646.       *                 auto initialised to NULL.
  647.       */
clone this paste RAW Paste Data