Commit e190ad1e882023b3bea7aa758111bf5e0bba4e94
1 parent
2b4ceb7e
upgraded to phpSniff 2.1.3
git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@2354 c91229c3-7414-0410-bfa2-8a42b809f60b
Showing
5 changed files
with
287 additions
and
122 deletions
phpSniff/CHANGES
| 1 | -$Id: CHANGES,v 1.11 2002/09/13 21:40:34 epsilon7 Exp $ | |
| 1 | +$Id: CHANGES,v 1.23 2003/07/02 23:31:55 epsilon7 Exp $ | |
| 2 | + | |
| 3 | +======================================================================== | |
| 4 | +Changes for version 2.1.3 | |
| 5 | +======================================================================== | |
| 6 | + * add k-meleon support | |
| 7 | + * add camino support | |
| 8 | + * add mozilla firebird support | |
| 9 | + * add amiga support | |
| 10 | + * fixed issues with netscape and gecko browsers | |
| 11 | + | |
| 12 | +======================================================================== | |
| 13 | +Changes for version 2.1.2 | |
| 14 | +======================================================================== | |
| 15 | +[2003.02.13] | |
| 16 | +rraymond : correctly identifies more browsers (galeon, phoenix, chimera, safari) | |
| 17 | +rraymond : fixes netscape/mozilla detection | |
| 18 | + | |
| 19 | +[2002.09.17] | |
| 20 | +rraymond : can now use '+' as alias for 'up' and '-' as alias for 'dn' | |
| 21 | +rraymond : cleanup of user_agent.inc file | |
| 22 | +rraymond : removed old test cookie code | |
| 23 | +rraymond : better mozilla/netscape differentiation | |
| 24 | +rraymond : added BrowseX support (short name = BX) | |
| 25 | + | |
| 26 | +[2002.09.13] | |
| 27 | +rraymond : fixes for some bad config settings | |
| 28 | +rraymond : Short Names List | |
| 29 | + Internet Explorer => IE | |
| 30 | + Netscape => NS | |
| 31 | + Mozilla => MZ | |
| 32 | + Opera => OP | |
| 33 | + Konqueror => KQ | |
| 34 | + Links => LI | |
| 35 | + Lynx => LX | |
| 36 | + NCSA Mosaic => MO | |
| 37 | + Amaya => AM | |
| 38 | + OmniWeb => OW | |
| 39 | + iCab => IC | |
| 40 | + HotJava => HJ | |
| 2 | 41 | |
| 3 | 42 | ======================================================================== |
| 4 | 43 | Changes for version 2.1.1 | ... | ... |
phpSniff/index.php
| 1 | 1 | <?php |
| 2 | 2 | error_reporting(E_ALL); |
| 3 | 3 | /******************************************************************************* |
| 4 | - $Id: index.php,v 1.10 2002/09/13 21:40:34 epsilon7 Exp $ | |
| 4 | + $Id: index.php,v 1.17 2003/07/02 23:28:35 epsilon7 Exp $ | |
| 5 | 5 | |
| 6 | 6 | phpSniff: HTTP_USER_AGENT Client Sniffer for PHP |
| 7 | 7 | Copyright (C) 2001 Roger Raymond ~ epsilon7@users.sourceforge.net |
| ... | ... | @@ -21,27 +21,28 @@ error_reporting(E_ALL); |
| 21 | 21 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 22 | 22 | *******************************************************************************/ |
| 23 | 23 | |
| 24 | -// email me the user agent strings | |
| 25 | -// i only do this so i can see what people are using | |
| 26 | -// so that i can continually update the code | |
| 27 | -//mail('roger@asphyxia.com','[phpsniff-user-agent] '.$_SERVER['HTTP_USER_AGENT'],$_SERVER['HTTP_USER_AGENT'],"From: epsilon7\r\n"); | |
| 28 | - | |
| 29 | 24 | require_once('phpSniff.class.php'); |
| 30 | 25 | require_once('phpTimer.class.php'); |
| 31 | 26 | |
| 27 | +//echo '<pre>'; | |
| 28 | +//print_r($_COOKIE); | |
| 29 | +//echo '</pre>'; | |
| 30 | + | |
| 32 | 31 | // initialize some vars |
| 33 | -if(!isset($UA)) $UA = ''; | |
| 34 | -if(!isset($cc)) $cc = ''; | |
| 35 | -if(!isset($dl)) $dl = ''; | |
| 36 | -if(!isset($am)) $am = ''; | |
| 32 | +$GET_VARS = isset($_GET) ? $_GET : $HTTP_GET_VARS; | |
| 33 | +$POST_VARS = isset($_POST) ? $_GET : $HTTP_POST_VARS; | |
| 34 | +if(!isset($GET_VARS['UA'])) $GET_VARS['UA'] = ''; | |
| 35 | +if(!isset($GET_VARS['cc'])) $GET_VARS['cc'] = ''; | |
| 36 | +if(!isset($GET_VARS['dl'])) $GET_VARS['dl'] = ''; | |
| 37 | +if(!isset($GET_VARS['am'])) $GET_VARS['am'] = ''; | |
| 37 | 38 | |
| 38 | -$timer = new phpTimer(); | |
| 39 | +$timer =& new phpTimer(); | |
| 39 | 40 | $timer->start('main'); |
| 40 | 41 | $timer->start('client1'); |
| 41 | -$sniffer_settings = array('check_cookies'=>$cc, | |
| 42 | - 'default_language'=>$dl, | |
| 43 | - 'allow_masquerading'=>$am); | |
| 44 | -$client = new phpSniff($UA,$sniffer_settings); | |
| 42 | +$sniffer_settings = array('check_cookies'=>$GET_VARS['cc'], | |
| 43 | + 'default_language'=>$GET_VARS['dl'], | |
| 44 | + 'allow_masquerading'=>$GET_VARS['am']); | |
| 45 | +$client =& new phpSniff($GET_VARS['UA'],$sniffer_settings); | |
| 45 | 46 | |
| 46 | 47 | $timer->stop('client1'); |
| 47 | 48 | |
| ... | ... | @@ -93,8 +94,26 @@ function has_quirk ($quirk) |
| 93 | 94 | |
| 94 | 95 | ?> |
| 95 | 96 | <html> |
| 96 | -<head><title>phpSniff <?php print $client->_version; ?> on SourceForge</title></head> | |
| 97 | -<body> | |
| 97 | +<head> | |
| 98 | +<title>phpSniff <?php print $client->_version; ?> on SourceForge</title> | |
| 99 | +<style type="text/css"> | |
| 100 | +INPUT, SELECT { | |
| 101 | + background-color: #c8c8c8; | |
| 102 | + font-family: monospace; | |
| 103 | + font-size: 10px; | |
| 104 | +} | |
| 105 | +BODY { | |
| 106 | + background-color: #ffffff; | |
| 107 | + font-family: sans-serif; | |
| 108 | + font-size: 10px; | |
| 109 | +} | |
| 110 | +TD { | |
| 111 | + font-family: sans-serif; | |
| 112 | + font-size: 10px; | |
| 113 | +} | |
| 114 | +</style> | |
| 115 | +</head> | |
| 116 | +<body marginwidth="0" marginheight="0" topmargin="0" leftmargin="0"> | |
| 98 | 117 | <?php |
| 99 | 118 | // fix for cgi versions of php ~ 6/28/2001 ~ RR |
| 100 | 119 | $script_path = getenv('PATH_INFO') ? getenv('PATH_INFO') : getenv('SCRIPT_NAME'); |
| ... | ... | @@ -109,13 +128,13 @@ $script_path = getenv('PATH_INFO') ? getenv('PATH_INFO') : getenv('SCRIPT_NAME') |
| 109 | 128 | </p> |
| 110 | 129 | <table border="0" cellpadding="3" cellspacing="0" bgcolor="<?php print $c3_bg; ?>" width="100%"> |
| 111 | 130 | <tr> |
| 112 | -<td align="left" valign="top"> | |
| 131 | +<td align="left" valign="top" width="100%"> | |
| 113 | 132 | <font color="#ffffff"><b>CURRENT BROWSER INFORMATION</b></font><br> |
| 114 | 133 | <font color="#ffffff" size="-1"> |
| 115 | 134 | <?php printf('phpSniff version : %s - php version : %s</font>',$client->_version, PHP_VERSION); ?> |
| 116 | 135 | </font> |
| 117 | 136 | </td> |
| 118 | -<td align="right" valign="top"> | |
| 137 | +<td align="right" valign="top" width="100%"> | |
| 119 | 138 | <font color="#ffffff"> |
| 120 | 139 | <select name="UA"> |
| 121 | 140 | <?php |
| ... | ... | @@ -273,8 +292,10 @@ $script_path = getenv('PATH_INFO') ? getenv('PATH_INFO') : getenv('SCRIPT_NAME') |
| 273 | 292 | </tr> |
| 274 | 293 | <?php |
| 275 | 294 | browser_is('aol'); |
| 276 | - browser_is('ie6up'); | |
| 277 | - browser_is('ns4up'); | |
| 295 | + browser_is('ie6+'); | |
| 296 | + browser_is('mz1.3+'); | |
| 297 | + browser_is('ns7+'); | |
| 298 | + browser_is('op6+'); | |
| 278 | 299 | ?> |
| 279 | 300 | <!-- language_is search --> |
| 280 | 301 | <tr> |
| ... | ... | @@ -290,7 +311,7 @@ $script_path = getenv('PATH_INFO') ? getenv('PATH_INFO') : getenv('SCRIPT_NAME') |
| 290 | 311 | <td bgcolor="<?php print $c3_bg; ?>" colspan="2" nowrap><font color="#ffcc00">$client->is(<i>search</i>)</font></td> |
| 291 | 312 | </tr> |
| 292 | 313 | <?php |
| 293 | - is('b:ns4up'); | |
| 314 | + is('b:ns7-'); | |
| 294 | 315 | is('l:en-us'); |
| 295 | 316 | ?> |
| 296 | 317 | </table> |
| ... | ... | @@ -309,8 +330,12 @@ printf("<pre>\n". |
| 309 | 330 | </p> |
| 310 | 331 | <?php |
| 311 | 332 | print ('<p align="left"><font size="-2">_______________________________<br>'); |
| 312 | -print ('Copyleft 2001-2002 PHyX8 Studio<br></font></p>'); | |
| 333 | +print ('Copyleft 2001-2003 Simian Synapse, LLC.<br></font></p>'); | |
| 313 | 334 | ?> |
| 314 | -<!A href="http://sourceforge.net"> <!IMG src="http://sourceforge.net/sflogo.php?group_id=26044" width="88" height="31" border="0" alt="SourceForge Logo"></A> | |
| 335 | +<p align="center"> | |
| 336 | +<A href="http://sourceforge.net"><IMG | |
| 337 | +src="http://sourceforge.net/sflogo.php?group_id=26044" | |
| 338 | +width="88" height="31" border="0" alt="SourceForge Logo"></A> | |
| 339 | +</p> | |
| 315 | 340 | </body> |
| 316 | 341 | </html> |
| 317 | 342 | \ No newline at end of file | ... | ... |
phpSniff/phpSniff.class.php
| 1 | 1 | <?php |
| 2 | 2 | /******************************************************************************* |
| 3 | - $Id: phpSniff.class.php,v 1.11 2002/09/13 21:40:34 epsilon7 Exp $ | |
| 3 | + $Id: phpSniff.class.php,v 1.21 2003/07/02 23:28:35 epsilon7 Exp $ | |
| 4 | 4 | |
| 5 | 5 | phpSniff: HTTP_USER_AGENT Client Sniffer for PHP |
| 6 | 6 | Copyright (C) 2001 Roger Raymond ~ epsilon7@users.sourceforge.net |
| ... | ... | @@ -21,8 +21,14 @@ |
| 21 | 21 | *******************************************************************************/ |
| 22 | 22 | require_once('phpSniff.core.php'); |
| 23 | 23 | |
| 24 | +//=============================================================== | |
| 25 | +// the following defines are used to create the short | |
| 26 | +// browser name used throughout the script. | |
| 27 | +// change these to suit your needs | |
| 28 | +//=============================================================== | |
| 29 | + | |
| 24 | 30 | class phpSniff extends phpSniff_core |
| 25 | -{ var $_version = '2.1.1'; | |
| 31 | +{ var $_version = '2.1.3'; | |
| 26 | 32 | /** |
| 27 | 33 | * Configuration |
| 28 | 34 | * |
| ... | ... | @@ -87,30 +93,42 @@ class phpSniff extends phpSniff_core |
| 87 | 93 | var $_php_version = ''; |
| 88 | 94 | |
| 89 | 95 | var $_browsers = array( |
| 90 | - 'microsoft internet explorer' => 'ie', | |
| 91 | - 'msie' => 'ie', | |
| 92 | - 'netscape6' => 'ns', | |
| 93 | - 'netscape' => 'ns', | |
| 94 | - 'mozilla' => 'moz', | |
| 95 | - 'opera' => 'op', | |
| 96 | - 'konqueror' => 'konq', | |
| 97 | - 'icab' => 'icab', | |
| 98 | - 'lynx' => 'lynx', | |
| 99 | - 'links' => 'links', | |
| 100 | - 'ncsa mosaic' => 'mosaic', | |
| 101 | - 'amaya' => 'amaya', | |
| 102 | - 'omniweb' => 'ow', | |
| 103 | - 'hotjava' => 'hj' | |
| 96 | + 'microsoft internet explorer' => 'IE', | |
| 97 | + 'msie' => 'IE', | |
| 98 | + 'netscape6' => 'NS', | |
| 99 | + 'netscape' => 'NS', | |
| 100 | + 'galeon' => 'GA', | |
| 101 | + 'phoenix' => 'PX', | |
| 102 | + 'mozilla firebird' => 'FB', | |
| 103 | + 'firebird' => 'FB', | |
| 104 | + 'chimera' => 'CH', | |
| 105 | + 'camino' => 'CA', | |
| 106 | + 'safari' => 'SF', | |
| 107 | + 'k-meleon' => 'KM', | |
| 108 | + 'mozilla' => 'MZ', | |
| 109 | + 'opera' => 'OP', | |
| 110 | + 'konqueror' => 'KQ', | |
| 111 | + 'icab' => 'IC', | |
| 112 | + 'lynx' => 'LX', | |
| 113 | + 'links' => 'LI', | |
| 114 | + 'ncsa mosaic' => 'MO', | |
| 115 | + 'amaya' => 'AM', | |
| 116 | + 'omniweb' => 'OW', | |
| 117 | + 'hotjava' => 'HJ', | |
| 118 | + 'browsex' => 'BX', | |
| 119 | + 'amigavoyager' => 'AV', | |
| 120 | + 'amiga-aweb' => 'AW', | |
| 121 | + 'ibrowse' => 'IB' | |
| 104 | 122 | ); |
| 105 | 123 | |
| 106 | 124 | var $_javascript_versions = array( |
| 107 | - '1.5' => 'IE5.5UP,NS5UP', | |
| 125 | + '1.5' => 'NS5+,MZ,PX,FB,GA,CH,CA,SF,KQ3+,KM', // browsers that support JavaScript 1.5 | |
| 108 | 126 | '1.4' => '', |
| 109 | - '1.3' => 'NS4.05UP,OP5UP,IE5UP', | |
| 110 | - '1.2' => 'NS4UP,IE4UP', | |
| 111 | - '1.1' => 'NS3UP,OP,KQ', | |
| 112 | - '1.0' => 'NS2UP,IE3UP', | |
| 113 | - '0' => 'LN,LX,HJ' | |
| 127 | + '1.3' => 'NS4.05+,OP5+,IE5+', | |
| 128 | + '1.2' => 'NS4+,IE4+', | |
| 129 | + '1.1' => 'NS3+,OP,KQ', | |
| 130 | + '1.0' => 'NS2+,IE3+', | |
| 131 | + '0' => 'LI,LX,HJ' | |
| 114 | 132 | ); |
| 115 | 133 | |
| 116 | 134 | var $_browser_features = array( |
| ... | ... | @@ -120,28 +138,28 @@ class phpSniff extends phpSniff_core |
| 120 | 138 | * browsers listed here will be set to false |
| 121 | 139 | **/ |
| 122 | 140 | 'html' => '', |
| 123 | - 'images' => 'LN,LX', | |
| 124 | - 'frames' => 'LN,LX', | |
| 141 | + 'images' => 'LI,LX', | |
| 142 | + 'frames' => 'LI,LX', | |
| 125 | 143 | 'tables' => '', |
| 126 | - 'java' => 'OP3,LX,LN,NS1,MO,IE1,IE2', | |
| 127 | - 'plugins' => 'IE1,IE2,LX,LN', | |
| 144 | + 'java' => 'OP3,LI,LX,NS1,MO,IE1,IE2', | |
| 145 | + 'plugins' => 'IE1,IE2,LI,LX', | |
| 128 | 146 | /** |
| 129 | 147 | * the following are false by default |
| 130 | 148 | * (see phpSniff.core.php $_feature_set array) |
| 131 | 149 | * browsers listed here will be set to true |
| 132 | 150 | **/ |
| 133 | - 'css2' => 'NS5UP,IE5UP', | |
| 134 | - 'css1' => 'NS4UP,IE4UP', | |
| 135 | - 'iframes' => 'IE3UP,NS5UP', | |
| 136 | - 'xml' => 'IE5UP,NS5UP', | |
| 137 | - 'dom' => 'IE5UP,NS5UP', | |
| 151 | + 'css2' => 'NS5+,IE5+,MZ,PX,FB,CH,CA,SF,GA,KQ3+,OP7+,KM', | |
| 152 | + 'css1' => 'NS4+,IE4+,MZ,PX,FB,CH,CA,SF,GA,KQ,OP7+,KM', | |
| 153 | + 'iframes' => 'IE3+,NS5+,MZ,PX,FB,CH,CA,SF,GA,KQ,OP7+,KM', | |
| 154 | + 'xml' => 'IE5+,NS5+,MZ,PX,FB,CH,CA,SF,GA,KQ,OP7+,KM', | |
| 155 | + 'dom' => 'IE5+,NS5+,MZ,PX,FB,CH,CA,SF,GA,KQ,OP7+,KM', | |
| 138 | 156 | 'hdml' => '', |
| 139 | 157 | 'wml' => '' |
| 140 | 158 | ); |
| 141 | 159 | |
| 142 | 160 | var $_browser_quirks = array( |
| 143 | - 'must_cache_forms' => 'NS', | |
| 144 | - 'avoid_popup_windows' => 'IE3,LX,LN', | |
| 161 | + 'must_cache_forms' => 'NS,MZ,FB,PX', | |
| 162 | + 'avoid_popup_windows' => 'IE3,LI,LX', | |
| 145 | 163 | 'cache_ssl_downloads' => 'IE', |
| 146 | 164 | 'break_disposition_header' => 'IE5.5', |
| 147 | 165 | 'empty_file_input_value' => 'KQ', | ... | ... |
phpSniff/phpSniff.core.php
| 1 | 1 | <?php |
| 2 | 2 | /******************************************************************************* |
| 3 | - $Id: phpSniff.core.php,v 1.8 2002/09/13 21:49:43 epsilon7 Exp $ | |
| 3 | + $Id: phpSniff.core.php,v 1.16 2003/07/02 23:30:29 epsilon7 Exp $ | |
| 4 | 4 | |
| 5 | 5 | phpSniff: HTTP_USER_AGENT Client Sniffer for PHP |
| 6 | 6 | Copyright (C) 2001 Roger Raymond ~ epsilon7@users.sourceforge.net |
| ... | ... | @@ -68,7 +68,7 @@ class phpSniff_core |
| 68 | 68 | ); |
| 69 | 69 | |
| 70 | 70 | var $_get_languages_ran_once = false; |
| 71 | - var $_browser_search_regex = '([a-z]+)([0-9]*)([0-9.]*)(up|dn)?'; | |
| 71 | + var $_browser_search_regex = '([a-z]+)([0-9]*)([0-9.]*)(up|dn|\+|\-)?'; | |
| 72 | 72 | var $_language_search_regex = '([a-z-]{2,})'; |
| 73 | 73 | |
| 74 | 74 | /** |
| ... | ... | @@ -84,6 +84,8 @@ class phpSniff_core |
| 84 | 84 | $this->_test_cookies(); |
| 85 | 85 | // rip the user agent to pieces |
| 86 | 86 | $this->_get_browser_info(); |
| 87 | + // gecko build | |
| 88 | + $this->_get_gecko(); | |
| 87 | 89 | // look for other languages |
| 88 | 90 | $this->_get_languages(); |
| 89 | 91 | // establish the operating platform |
| ... | ... | @@ -94,9 +96,7 @@ class phpSniff_core |
| 94 | 96 | $this->_get_features(); |
| 95 | 97 | // point out any quirks |
| 96 | 98 | $this->_get_quirks(); |
| 97 | - // gecko build | |
| 98 | - $this->_get_gecko(); | |
| 99 | - } | |
| 99 | + } | |
| 100 | 100 | |
| 101 | 101 | /** |
| 102 | 102 | * property |
| ... | ... | @@ -202,10 +202,12 @@ class phpSniff_core |
| 202 | 202 | { $majv = $search['maj_ver'] ? $this->_browser_info['maj_ver'] : ''; |
| 203 | 203 | $minv = $search['min_ver'] ? $this->_browser_info['min_ver'] : ''; |
| 204 | 204 | $what_we_are = $majv.$minv; |
| 205 | - if($search['direction'] == 'up' && ($what_we_are >= $looking_for)) | |
| 205 | + if(($search['direction'] == 'up' || $search['direction'] == '+') | |
| 206 | + && ($what_we_are >= $looking_for)) | |
| 206 | 207 | { return true; |
| 207 | 208 | } |
| 208 | - elseif($search['direction'] == 'dn' && ($what_we_are <= $looking_for)) | |
| 209 | + elseif(($search['direction'] == 'dn' || $search['direction'] == '-') | |
| 210 | + && ($what_we_are <= $looking_for)) | |
| 209 | 211 | { return true; |
| 210 | 212 | } |
| 211 | 213 | elseif($what_we_are == $looking_for) |
| ... | ... | @@ -249,6 +251,7 @@ class phpSniff_core |
| 249 | 251 | $regex_sco = '/sco|unix_sv/i'; |
| 250 | 252 | $regex_linux = '/x11|inux/i'; |
| 251 | 253 | $regex_bsd = '/(free)?(bsd)/i'; |
| 254 | + $regex_amiga = '/amiga[os]?/i'; | |
| 252 | 255 | |
| 253 | 256 | // look for Windows Box |
| 254 | 257 | if(preg_match_all($regex_windows,$this->_browser_info['ua'],$match)) |
| ... | ... | @@ -272,6 +275,23 @@ class phpSniff_core |
| 272 | 275 | $this->_set_browser('os',strtolower($v)); |
| 273 | 276 | $this->_set_browser('platform','win'); |
| 274 | 277 | } |
| 278 | + // look for amiga OS | |
| 279 | + elseif(preg_match($regex_amiga,$this->_browser_info['ua'],$match)) | |
| 280 | + { $this->_set_browser('platform','amiga'); | |
| 281 | + if(stristr($this->_browser_info['ua'],'morphos')) { | |
| 282 | + // checking for MorphOS | |
| 283 | + $this->_set_browser('os','morphos'); | |
| 284 | + } elseif(stristr($this->_browser_info['ua'],'mc680x0')) { | |
| 285 | + // checking for MC680x0 | |
| 286 | + $this->_set_browser('os','mc680x0'); | |
| 287 | + } elseif(stristr($this->_browser_info['ua'],'ppc')) { | |
| 288 | + // checking for PPC | |
| 289 | + $this->_set_browser('os','ppc'); | |
| 290 | + } elseif(preg_match('/(AmigaOS [\.1-9]?)/i',$this->_browser_info['ua'],$match)) { | |
| 291 | + // checking for AmigaOS version string | |
| 292 | + $this->_set_browser('os',$match[1]); | |
| 293 | + } | |
| 294 | + } | |
| 275 | 295 | // look for OS2 |
| 276 | 296 | elseif( preg_match($regex_os2,$this->_browser_info['ua'])) |
| 277 | 297 | { $this->_set_browser('os','os2'); |
| ... | ... | @@ -327,22 +347,22 @@ class phpSniff_core |
| 327 | 347 | $this->_set_browser('os','sco'); |
| 328 | 348 | } |
| 329 | 349 | // unixware sets: platform = *nix ; os = unixware |
| 330 | - elseif(stristr('unix_system_v',$this->_browser_info['ua'])) | |
| 350 | + elseif(stristr($this->_browser_info['ua'],'unix_system_v')) | |
| 331 | 351 | { $this->_set_browser('platform','*nix'); |
| 332 | 352 | $this->_set_browser('os','unixware'); |
| 333 | 353 | } |
| 334 | 354 | // mpras sets: platform = *nix ; os = mpras |
| 335 | - elseif(stristr('ncr',$this->_browser_info['ua'])) | |
| 355 | + elseif(stristr($this->_browser_info['ua'],'ncr')) | |
| 336 | 356 | { $this->_set_browser('platform','*nix'); |
| 337 | 357 | $this->_set_browser('os','mpras'); |
| 338 | 358 | } |
| 339 | 359 | // reliant sets: platform = *nix ; os = reliant |
| 340 | - elseif(stristr('reliantunix',$this->_browser_info['ua'])) | |
| 360 | + elseif(stristr($this->_browser_info['ua'],'reliantunix')) | |
| 341 | 361 | { $this->_set_browser('platform','*nix'); |
| 342 | 362 | $this->_set_browser('os','reliant'); |
| 343 | 363 | } |
| 344 | 364 | // sinix sets: platform = *nix ; os = sinix |
| 345 | - elseif(stristr('sinix',$this->_browser_info['ua'])) | |
| 365 | + elseif(stristr($this->_browser_info['ua'],'sinix')) | |
| 346 | 366 | { $this->_set_browser('platform','*nix'); |
| 347 | 367 | $this->_set_browser('os','sinix'); |
| 348 | 368 | } |
| ... | ... | @@ -400,7 +420,7 @@ class phpSniff_core |
| 400 | 420 | { if(!empty($browsers)) $browsers .= "|"; |
| 401 | 421 | $browsers .= $k; |
| 402 | 422 | } |
| 403 | - $version_string = "[\/\sa-z]*([0-9]+)([\.0-9a-z]+)?"; | |
| 423 | + $version_string = "[\/\sa-z(]*([0-9]+)([\.0-9a-z]+)?"; | |
| 404 | 424 | $this->_browser_regex = "/($browsers)$version_string/i"; |
| 405 | 425 | } |
| 406 | 426 | |
| ... | ... | @@ -408,43 +428,22 @@ class phpSniff_core |
| 408 | 428 | { return $this->_browsers[strtolower($long_name)]; |
| 409 | 429 | } |
| 410 | 430 | |
| 411 | - /* | |
| 412 | - function _test_cookies () | |
| 413 | - { global $ctest,$phpSniff_testCookie; | |
| 414 | - if($this->_check_cookies) | |
| 415 | - { if ($ctest != 1) | |
| 416 | - { SetCookie('phpSniff_testCookie','test',0,'/'); | |
| 417 | - // See if we were passed anything in the QueryString we might need | |
| 418 | - $QS = getenv('QUERY_STRING'); | |
| 419 | - // fix compatability issues when PHP is | |
| 420 | - // running as CGI ~ 6/28/2001 v2.0.2 ~ RR | |
| 421 | - $script_path = getenv('PATH_INFO') ? getenv('PATH_INFO') : getenv('SCRIPT_NAME'); | |
| 422 | - $location = $script_path . ($QS=="" ? "?ctest=1" : "?" . $QS . "&ctest=1"); | |
| 423 | - header("Location: $location"); | |
| 424 | - exit; | |
| 425 | - } | |
| 426 | - // Check for the cookie on page reload | |
| 427 | - elseif ($phpSniff_testCookie == "test") | |
| 428 | - { $this->_set_browser('cookies',true); | |
| 429 | - } | |
| 430 | - else | |
| 431 | - { $this->_set_browser('cookies',false); | |
| 432 | - } | |
| 433 | - } | |
| 434 | - else $this->_set_browser('cookies',false); | |
| 435 | - | |
| 436 | - } | |
| 437 | - */ | |
| 438 | 431 | // medianes :: new test cookie routine |
| 439 | 432 | function _test_cookies() |
| 440 | - { global $phpSniff_session,$phpSniff_stored; | |
| 433 | + { global $HTTP_COOKIE_VARS; | |
| 434 | + $cookies = array(); | |
| 435 | + if(isset($_COOKIE)) { | |
| 436 | + $cookies = $_COOKIE; | |
| 437 | + } elseif(isset($HTTP_COOKIE_VARS)) { | |
| 438 | + $cookies = $HTTP_COOKIE_VARS; | |
| 439 | + } | |
| 441 | 440 | if($this->_check_cookies) |
| 442 | 441 | { $fp = @fopen($this->_temp_file_path.$this->property('ip'),'r'); |
| 443 | 442 | if(!$fp) |
| 444 | 443 | { $fp = @fopen($this->_temp_file_path.$this->property('ip'),'a'); |
| 445 | 444 | fclose($fp); |
| 446 | - setcookie('phpSniff_session','ss'); | |
| 447 | - setcookie('phpSniff_stored','st',time()+3600*24*365); | |
| 445 | + setcookie('phpSniff_session','ss',0,'/'); | |
| 446 | + setcookie('phpSniff_stored','st',time()+3600*24*365,'/'); | |
| 448 | 447 | $QS=getenv('QUERY_STRING'); |
| 449 | 448 | $script_path=getenv('PATH_INFO')?getenv('PATH_INFO'):getenv('SCRIPT_NAME'); |
| 450 | 449 | if(is_integer($pos=strpos(strrev($script_path),"php.xedni/"))&&!$pos) { |
| ... | ... | @@ -457,12 +456,12 @@ class phpSniff_core |
| 457 | 456 | else |
| 458 | 457 | { unlink($this->_temp_file_path.$this->property('ip')); |
| 459 | 458 | fclose($fp); |
| 460 | - // remains for backwards compatability | |
| 461 | - $this->_set_browser('cookies',$phpSniff_session=='ss'?'true':'false'); | |
| 462 | - // new cookie settings | |
| 463 | - $this->_set_browser('ss_cookies',$phpSniff_session=='ss'?'true':'false'); | |
| 464 | - $this->_set_browser('st_cookies',$phpSniff_stored=='st'?'true':'false'); | |
| 465 | - setcookie('phpSniff_stored',''); | |
| 459 | + $this->_set_browser('ss_cookies',isset($cookies['phpSniff_session'])?'true':'false'); | |
| 460 | + $this->_set_browser('st_cookies',isset($cookies['phpSniff_stored'])?'true':'false'); | |
| 461 | + // delete the old cookies | |
| 462 | + setcookie('phpSniff_session','',0,'/'); | |
| 463 | + setcookie('phpSniff_stored','',0,'/'); | |
| 464 | + | |
| 466 | 465 | } |
| 467 | 466 | } |
| 468 | 467 | } |
| ... | ... | @@ -510,12 +509,26 @@ class phpSniff_core |
| 510 | 509 | function _get_gecko () |
| 511 | 510 | { if(preg_match('/gecko\/([0-9]+)/i',$this->property('ua'),$match)) |
| 512 | 511 | { $this->_set_browser('gecko',$match[1]); |
| 513 | - if (preg_match('/rv:([0-9a-z.+]+)/i',$this->property('ua'),$mozv)) | |
| 514 | - { $this->_set_browser('gecko_ver',$mozv[1]); | |
| 515 | - } | |
| 516 | - elseif (preg_match('/(m[0-9]+)/i',$this->property('ua'),$mozv)) | |
| 517 | - { $this->_set_browser('gecko_ver',$mozv[1]); | |
| 512 | + if (preg_match('/rv[: ]?([0-9a-z.+]+)/i',$this->property('ua'),$mozv)) { | |
| 513 | + // mozilla release | |
| 514 | + $this->_set_browser('gecko_ver',$mozv[1]); | |
| 515 | + } elseif (preg_match('/(m[0-9]+)/i',$this->property('ua'),$mozv)) { | |
| 516 | + // mozilla milestone version | |
| 517 | + $this->_set_browser('gecko_ver',$mozv[1]); | |
| 518 | 518 | } |
| 519 | + // if this is a mozilla browser, get the rv: information | |
| 520 | + if($this->browser_is($this->_get_short_name('mozilla'))) { | |
| 521 | + if(preg_match('/([0-9]+)([\.0-9]+)([a-z0-9+]?)/i',$mozv[1],$match)) { | |
| 522 | + $this->_set_browser('version',$mozv[1]); | |
| 523 | + $this->_set_browser('maj_ver',$match[1]); | |
| 524 | + $this->_set_browser('min_ver',$match[2]); | |
| 525 | + $this->_set_browser('letter_ver',$match[3]); | |
| 526 | + } | |
| 527 | + } | |
| 528 | + } elseif($this->is('b:'.$this->_get_short_name('mozilla'))) { | |
| 529 | + // this is probably a netscape browser or compatible | |
| 530 | + $this->_set_browser('long_name','netscape'); | |
| 531 | + $this->_set_browser('browser',$this->_get_short_name('netscape')); | |
| 519 | 532 | } |
| 520 | 533 | } |
| 521 | 534 | ... | ... |
phpSniff/user_agent.inc
| 1 | 1 | <?php |
| 2 | 2 | /******************************************************************************* |
| 3 | + $Id: user_agent.inc,v 1.15 2003/07/02 23:28:35 epsilon7 Exp $ | |
| 4 | + | |
| 3 | 5 | user_agent.inc: an array containing browser HTTP_USER_AGENT values for testing |
| 4 | 6 | Copyright (C) 2001 Roger Raymond ~ epsilon7@users.sourceforge.net |
| 5 | 7 | |
| ... | ... | @@ -18,24 +20,92 @@ |
| 18 | 20 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 19 | 21 | *******************************************************************************/ |
| 20 | 22 | $user_agent = array( |
| 21 | -'mozilla/5.0 (macintosh; u; darwin power macintosh; rv:0.9.9+) gecko/20020223', | |
| 22 | -'Mozilla/3.0 (compatible; Opera/3.0; Windows 95/NT4)', | |
| 23 | -'Mozilla/4.0 (compatible; MSIE 5.0; Windows 2000) Opera 5.11 [en]', | |
| 23 | +'', | |
| 24 | +'===[ Gecko Based ]============================================================', | |
| 25 | +'Mozilla/5.0 Galeon/1.2.5 (X11; Linux i686; U;) Gecko/0', | |
| 26 | +'Mozilla/5.0 (Macintosh; U; PPC Mac OS X Mach-O; en-US; rv:1.0.1) Gecko/20021220 Chimera/0.6+', | |
| 27 | +'Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.3a) Gecko/20021207 Phoenix/0.5', | |
| 28 | +'mozilla/5.0 (macintosh; u; ppc mac os x mach-o; en-us; rv:1.0.1) gecko/20030306 camino/0.7', | |
| 29 | +'mozilla/5.0 (x11; u; linux i686; en-us; rv:1.4b) gecko/20030527 firebird/0.6', | |
| 30 | +'', | |
| 31 | +'===[ Microsoft Internet Explorer ]============================================', | |
| 32 | +'Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)', | |
| 33 | +'Mozilla/4.0 (compatible; MSIE 5.22; Mac_PowerPC)', | |
| 34 | +'Mozilla/4.0 (compatible; MSIE 5.16, Mac_PowerPC)', | |
| 24 | 35 | 'Mozilla/4.0 (compatible; MSIE 4.01; Windows 98)', |
| 25 | 36 | 'Mozilla/4.0 (compatible; MSIE 6.0b; Windows NT 5.0)', |
| 37 | +'mozilla/4.0 (compatible; msie 6.0; windows nt 5.1; q312461)', | |
| 38 | +'mozilla/4.0 (compatible; msie 5.5; windows 98; win 9x 4.90)', | |
| 39 | +'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)', | |
| 40 | +'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; Q312461)', | |
| 41 | +'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; MyIE2; HotBar 4.1.8.0; .NET CLR 1.0.3705)', | |
| 42 | +'', | |
| 43 | +'===[ Netscape ]===============================================================', | |
| 44 | +'mozilla/4.51 [ru] (Win98; u)', | |
| 45 | +'Mozilla/5.0 (Macintosh; U; PPC Mac OS X; en-US; rv:1.0.1) Gecko/20020823 Netscape/7.0', | |
| 46 | +'Mozilla/4.78 [en] (Win98; U)', | |
| 26 | 47 | 'Mozilla/4.5 [en] (Win95; U)', |
| 27 | 48 | 'Mozilla/4.5 (Macintosh; U; PPC)', |
| 28 | -'Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:0.9+) Gecko/20010509', | |
| 29 | 49 | 'Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; m18) Gecko/20010131 Netscape6/6.01', |
| 50 | +'Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; m18) Gecko/20010131 Netscape/7.00', | |
| 51 | +'Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.0.1) Gecko/20020823 Netscape/7.0', | |
| 52 | +'', | |
| 53 | +'===[ Mozilla ]================================================================', | |
| 54 | +'Mozilla/5.0 (X11; U; Linux i686; en-US; rv:0.9.6+)', | |
| 55 | +'mozilla/5.0 (x11; u; linux i686; en-us; rv:1.0.0) gecko/20020623 debian/1.0.0-0.woody.1', | |
| 56 | +'Mozilla/5.0 (Macintosh; U; PPC Mac OS X; en-US; rv:1.2.1) Gecko/20021130', | |
| 57 | +'Mozilla/5.0 (Windows; U; Win98; en-US; rv:1.2.1) Gecko/20021130', | |
| 58 | +'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.2.1) Gecko/20021130', | |
| 59 | +'Mozilla/5.0 (X11; U; Linux i686; de-AT; rv:1.1) Gecko/20020826', | |
| 60 | +'Mozilla/5.0 (Macintosh; U; PPC Mac OS X; en-US; rv:1.0.0) Gecko/20020529', | |
| 61 | +'Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:0.9+) Gecko/20010509', | |
| 62 | +'mozilla/5.0 (macintosh; u; darwin power macintosh; rv:0.9.9+) gecko/20020223', | |
| 63 | +'Mozilla/5.0 (X11; Linux i686; en-US; rv:1.0rc5; OBJR) gecko/20020223', | |
| 64 | +'', | |
| 65 | +'===[ Opera ]==================================================================', | |
| 66 | +'Opera/6.05 (Windows XP; U) [en]', | |
| 30 | 67 | 'Opera/5.11 (Windows 2000; U) [en]', |
| 31 | -'NCSA Mosaic/2.6b1 (X11;UNIX_SV 4.2MP R4000) libwww/2.12 modified', | |
| 32 | -'Lynx/2.7 libwww-FM/2.14', | |
| 33 | -'amaya/V4.3.2 libwww/5.3.1', | |
| 34 | -'Mozilla/4.0 (compatible; MSIE 5.5; Mac_PowerPC; OmniWeb/4.0)', | |
| 68 | +'Mozilla/5.0 (Windows XP; U) Opera 6.05 [en]', | |
| 69 | +'Mozilla/3.0 (compatible; Opera/3.0; Windows 95/NT4)', | |
| 70 | +'Mozilla/4.0 (compatible; MSIE 5.0; Windows XP) Opera 6.05 [en]', | |
| 71 | +'Mozilla/4.0 (compatible; MSIE 5.0; Windows 2000) Opera 5.11 [en]', | |
| 35 | 72 | 'mozilla/4.0 (compatible; msie 5.0; linux 2.4.16 i686) opera 5.0 [en]', |
| 73 | +'', | |
| 74 | +'===[ Konqueror ]==============================================================', | |
| 75 | +'Mozilla/5.0 (compatible; Konqueror/3.1-13; Linux)', | |
| 76 | +'Mozilla/5.0 (compatible; Konqueror/3.0.0-10; Linux)', | |
| 36 | 77 | 'mozilla/5.0 (compatible; konqueror/2.2.1; linux)', |
| 37 | -'mozilla/4.0 (compatible; msie 6.0; windows nt 5.1; q312461)', | |
| 38 | -'mozilla/4.0 (compatible; msie 5.5; windows 98; win 9x 4.90)', | |
| 39 | -'Mozilla/5.0 (Macintosh; U; PPC Mac OS X; en-US; rv:1.0.0) Gecko/20020529' | |
| 78 | +'Mozilla/5.0 (compatible; Konqueror/3; Linux)', | |
| 79 | +'', | |
| 80 | +'===[ Safari ]=================================================================', | |
| 81 | +'Mozilla/5.0 (Macintosh; U; PPC Mac OS X; en-us) AppleWebKit/48 (like Gecko) Safari/48', | |
| 82 | +'Mozilla/5.0 (Macintosh; U; PPC Mac OS X; en-us) AppleWebKit/51 (like Gecko) Safari/51 ', | |
| 83 | +'', | |
| 84 | +'===[ Text Based ]=============================================================', | |
| 85 | +'Lynx/2.7 libwww-FM/2.14', | |
| 86 | +'Lynx/2.8.4rel.1 libwww-FM/2.14 SSL-MM/1.4.1 OpenSSL/0.9.6g', | |
| 87 | +'Links (2.1pre3; Linux 2.4.20 i686; 80x24)', | |
| 88 | +'', | |
| 89 | +'===[ Amiga ]=============================+++++================================', | |
| 90 | +'Mozilla/5.0 (AmigaOS MorphOS; en-US; rv 1.0) Gecko/20020616', | |
| 91 | +'Mozilla/3.01 (compatible; AmigaVoyager/2.95; AmigaOS/MC680x0)', | |
| 92 | +'Mozilla/6.0; (Spoofed by Amiga-AWeb/3.4APL)', | |
| 93 | +'IBrowse/1.12 (AmigaOS 3.1)', | |
| 94 | +'IBrowse/2.2 (AmigaOS 3.1)', | |
| 95 | +'IBrowse/2.3 (AmigaOS 3.5)', | |
| 96 | +'IBrowse/2.3 (AmigaOS 3.9)', | |
| 97 | +'IBrowse/2.2 (AmigaOS V45)', | |
| 98 | +'AmigaVoyager/3.2 (AmigaOS/MC680x0)', | |
| 99 | +'AmigaVoyager/3.3.122 (AmigaOS/MC680x0)', | |
| 100 | +'AmigaVoyager/3.3.122 (AmigaOS/PPC)', | |
| 101 | +'Amiga-AWeb/3.3', | |
| 102 | +'Amiga-AWeb/3.4', | |
| 103 | +'Amiga-AWeb/3.4APL', | |
| 104 | +'', | |
| 105 | +'===[ Other ]==================================================================', | |
| 106 | +'Mozilla/4.0 (compatible; MSIE 5.5; Mac_PowerPC; OmniWeb/4.0)', | |
| 107 | +'NCSA Mosaic/2.6b1 (X11;UNIX_SV 4.2MP R4000) libwww/2.12 modified', | |
| 108 | +'amaya/V4.3.2 libwww/5.3.1', | |
| 109 | +'mozilla/4.61 [en] (x11; u; ) - browsex (2.0.0 windows)' | |
| 40 | 110 | ); |
| 41 | 111 | ?> |
| 42 | 112 | \ No newline at end of file | ... | ... |