From e190ad1e882023b3bea7aa758111bf5e0bba4e94 Mon Sep 17 00:00:00 2001
From: michael
Date: Thu, 10 Jul 2003 13:49:13 +0000
Subject: [PATCH] upgraded to phpSniff 2.1.3
---
phpSniff/CHANGES | 41 ++++++++++++++++++++++++++++++++++++++++-
phpSniff/index.php | 73 +++++++++++++++++++++++++++++++++++++++++++++++++------------------------
phpSniff/phpSniff.class.php | 84 +++++++++++++++++++++++++++++++++++++++++++++++++++---------------------------------
phpSniff/phpSniff.core.php | 119 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-----------------------------------------------------
phpSniff/user_agent.inc | 92 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-----------
5 files changed, 287 insertions(+), 122 deletions(-)
diff --git a/phpSniff/CHANGES b/phpSniff/CHANGES
index 01fa362..49b20d7 100644
--- a/phpSniff/CHANGES
+++ b/phpSniff/CHANGES
@@ -1,4 +1,43 @@
-$Id: CHANGES,v 1.11 2002/09/13 21:40:34 epsilon7 Exp $
+$Id: CHANGES,v 1.23 2003/07/02 23:31:55 epsilon7 Exp $
+
+========================================================================
+Changes for version 2.1.3
+========================================================================
+ * add k-meleon support
+ * add camino support
+ * add mozilla firebird support
+ * add amiga support
+ * fixed issues with netscape and gecko browsers
+
+========================================================================
+Changes for version 2.1.2
+========================================================================
+[2003.02.13]
+rraymond : correctly identifies more browsers (galeon, phoenix, chimera, safari)
+rraymond : fixes netscape/mozilla detection
+
+[2002.09.17]
+rraymond : can now use '+' as alias for 'up' and '-' as alias for 'dn'
+rraymond : cleanup of user_agent.inc file
+rraymond : removed old test cookie code
+rraymond : better mozilla/netscape differentiation
+rraymond : added BrowseX support (short name = BX)
+
+[2002.09.13]
+rraymond : fixes for some bad config settings
+rraymond : Short Names List
+ Internet Explorer => IE
+ Netscape => NS
+ Mozilla => MZ
+ Opera => OP
+ Konqueror => KQ
+ Links => LI
+ Lynx => LX
+ NCSA Mosaic => MO
+ Amaya => AM
+ OmniWeb => OW
+ iCab => IC
+ HotJava => HJ
========================================================================
Changes for version 2.1.1
diff --git a/phpSniff/index.php b/phpSniff/index.php
index 251d6c6..590b310 100644
--- a/phpSniff/index.php
+++ b/phpSniff/index.php
@@ -1,7 +1,7 @@
';
+//print_r($_COOKIE);
+//echo '';
+
// initialize some vars
-if(!isset($UA)) $UA = '';
-if(!isset($cc)) $cc = '';
-if(!isset($dl)) $dl = '';
-if(!isset($am)) $am = '';
+$GET_VARS = isset($_GET) ? $_GET : $HTTP_GET_VARS;
+$POST_VARS = isset($_POST) ? $_GET : $HTTP_POST_VARS;
+if(!isset($GET_VARS['UA'])) $GET_VARS['UA'] = '';
+if(!isset($GET_VARS['cc'])) $GET_VARS['cc'] = '';
+if(!isset($GET_VARS['dl'])) $GET_VARS['dl'] = '';
+if(!isset($GET_VARS['am'])) $GET_VARS['am'] = '';
-$timer = new phpTimer();
+$timer =& new phpTimer();
$timer->start('main');
$timer->start('client1');
-$sniffer_settings = array('check_cookies'=>$cc,
- 'default_language'=>$dl,
- 'allow_masquerading'=>$am);
-$client = new phpSniff($UA,$sniffer_settings);
+$sniffer_settings = array('check_cookies'=>$GET_VARS['cc'],
+ 'default_language'=>$GET_VARS['dl'],
+ 'allow_masquerading'=>$GET_VARS['am']);
+$client =& new phpSniff($GET_VARS['UA'],$sniffer_settings);
$timer->stop('client1');
@@ -93,8 +94,26 @@ function has_quirk ($quirk)
?>
-phpSniff _version; ?> on SourceForge
-
+
+phpSniff _version; ?> on SourceForge
+
+
+
-|
+ |
CURRENT BROWSER INFORMATION
',$client->_version, PHP_VERSION); ?>
|
-
+ |
|
@@ -309,8 +330,12 @@ printf("\n".
_______________________________
');
-print ('Copyleft 2001-2002 PHyX8 Studio
');
+print ('Copyleft 2001-2003 Simian Synapse, LLC.
');
?>
-
+
+
+
\ No newline at end of file
diff --git a/phpSniff/phpSniff.class.php b/phpSniff/phpSniff.class.php
index 0d9f32b..fff4ade 100644
--- a/phpSniff/phpSniff.class.php
+++ b/phpSniff/phpSniff.class.php
@@ -1,6 +1,6 @@
'ie',
- 'msie' => 'ie',
- 'netscape6' => 'ns',
- 'netscape' => 'ns',
- 'mozilla' => 'moz',
- 'opera' => 'op',
- 'konqueror' => 'konq',
- 'icab' => 'icab',
- 'lynx' => 'lynx',
- 'links' => 'links',
- 'ncsa mosaic' => 'mosaic',
- 'amaya' => 'amaya',
- 'omniweb' => 'ow',
- 'hotjava' => 'hj'
+ 'microsoft internet explorer' => 'IE',
+ 'msie' => 'IE',
+ 'netscape6' => 'NS',
+ 'netscape' => 'NS',
+ 'galeon' => 'GA',
+ 'phoenix' => 'PX',
+ 'mozilla firebird' => 'FB',
+ 'firebird' => 'FB',
+ 'chimera' => 'CH',
+ 'camino' => 'CA',
+ 'safari' => 'SF',
+ 'k-meleon' => 'KM',
+ 'mozilla' => 'MZ',
+ 'opera' => 'OP',
+ 'konqueror' => 'KQ',
+ 'icab' => 'IC',
+ 'lynx' => 'LX',
+ 'links' => 'LI',
+ 'ncsa mosaic' => 'MO',
+ 'amaya' => 'AM',
+ 'omniweb' => 'OW',
+ 'hotjava' => 'HJ',
+ 'browsex' => 'BX',
+ 'amigavoyager' => 'AV',
+ 'amiga-aweb' => 'AW',
+ 'ibrowse' => 'IB'
);
var $_javascript_versions = array(
- '1.5' => 'IE5.5UP,NS5UP',
+ '1.5' => 'NS5+,MZ,PX,FB,GA,CH,CA,SF,KQ3+,KM', // browsers that support JavaScript 1.5
'1.4' => '',
- '1.3' => 'NS4.05UP,OP5UP,IE5UP',
- '1.2' => 'NS4UP,IE4UP',
- '1.1' => 'NS3UP,OP,KQ',
- '1.0' => 'NS2UP,IE3UP',
- '0' => 'LN,LX,HJ'
+ '1.3' => 'NS4.05+,OP5+,IE5+',
+ '1.2' => 'NS4+,IE4+',
+ '1.1' => 'NS3+,OP,KQ',
+ '1.0' => 'NS2+,IE3+',
+ '0' => 'LI,LX,HJ'
);
var $_browser_features = array(
@@ -120,28 +138,28 @@ class phpSniff extends phpSniff_core
* browsers listed here will be set to false
**/
'html' => '',
- 'images' => 'LN,LX',
- 'frames' => 'LN,LX',
+ 'images' => 'LI,LX',
+ 'frames' => 'LI,LX',
'tables' => '',
- 'java' => 'OP3,LX,LN,NS1,MO,IE1,IE2',
- 'plugins' => 'IE1,IE2,LX,LN',
+ 'java' => 'OP3,LI,LX,NS1,MO,IE1,IE2',
+ 'plugins' => 'IE1,IE2,LI,LX',
/**
* the following are false by default
* (see phpSniff.core.php $_feature_set array)
* browsers listed here will be set to true
**/
- 'css2' => 'NS5UP,IE5UP',
- 'css1' => 'NS4UP,IE4UP',
- 'iframes' => 'IE3UP,NS5UP',
- 'xml' => 'IE5UP,NS5UP',
- 'dom' => 'IE5UP,NS5UP',
+ 'css2' => 'NS5+,IE5+,MZ,PX,FB,CH,CA,SF,GA,KQ3+,OP7+,KM',
+ 'css1' => 'NS4+,IE4+,MZ,PX,FB,CH,CA,SF,GA,KQ,OP7+,KM',
+ 'iframes' => 'IE3+,NS5+,MZ,PX,FB,CH,CA,SF,GA,KQ,OP7+,KM',
+ 'xml' => 'IE5+,NS5+,MZ,PX,FB,CH,CA,SF,GA,KQ,OP7+,KM',
+ 'dom' => 'IE5+,NS5+,MZ,PX,FB,CH,CA,SF,GA,KQ,OP7+,KM',
'hdml' => '',
'wml' => ''
);
var $_browser_quirks = array(
- 'must_cache_forms' => 'NS',
- 'avoid_popup_windows' => 'IE3,LX,LN',
+ 'must_cache_forms' => 'NS,MZ,FB,PX',
+ 'avoid_popup_windows' => 'IE3,LI,LX',
'cache_ssl_downloads' => 'IE',
'break_disposition_header' => 'IE5.5',
'empty_file_input_value' => 'KQ',
diff --git a/phpSniff/phpSniff.core.php b/phpSniff/phpSniff.core.php
index d8130d1..0236421 100644
--- a/phpSniff/phpSniff.core.php
+++ b/phpSniff/phpSniff.core.php
@@ -1,6 +1,6 @@
_test_cookies();
// rip the user agent to pieces
$this->_get_browser_info();
+ // gecko build
+ $this->_get_gecko();
// look for other languages
$this->_get_languages();
// establish the operating platform
@@ -94,9 +96,7 @@ class phpSniff_core
$this->_get_features();
// point out any quirks
$this->_get_quirks();
- // gecko build
- $this->_get_gecko();
- }
+ }
/**
* property
@@ -202,10 +202,12 @@ class phpSniff_core
{ $majv = $search['maj_ver'] ? $this->_browser_info['maj_ver'] : '';
$minv = $search['min_ver'] ? $this->_browser_info['min_ver'] : '';
$what_we_are = $majv.$minv;
- if($search['direction'] == 'up' && ($what_we_are >= $looking_for))
+ if(($search['direction'] == 'up' || $search['direction'] == '+')
+ && ($what_we_are >= $looking_for))
{ return true;
}
- elseif($search['direction'] == 'dn' && ($what_we_are <= $looking_for))
+ elseif(($search['direction'] == 'dn' || $search['direction'] == '-')
+ && ($what_we_are <= $looking_for))
{ return true;
}
elseif($what_we_are == $looking_for)
@@ -249,6 +251,7 @@ class phpSniff_core
$regex_sco = '/sco|unix_sv/i';
$regex_linux = '/x11|inux/i';
$regex_bsd = '/(free)?(bsd)/i';
+ $regex_amiga = '/amiga[os]?/i';
// look for Windows Box
if(preg_match_all($regex_windows,$this->_browser_info['ua'],$match))
@@ -272,6 +275,23 @@ class phpSniff_core
$this->_set_browser('os',strtolower($v));
$this->_set_browser('platform','win');
}
+ // look for amiga OS
+ elseif(preg_match($regex_amiga,$this->_browser_info['ua'],$match))
+ { $this->_set_browser('platform','amiga');
+ if(stristr($this->_browser_info['ua'],'morphos')) {
+ // checking for MorphOS
+ $this->_set_browser('os','morphos');
+ } elseif(stristr($this->_browser_info['ua'],'mc680x0')) {
+ // checking for MC680x0
+ $this->_set_browser('os','mc680x0');
+ } elseif(stristr($this->_browser_info['ua'],'ppc')) {
+ // checking for PPC
+ $this->_set_browser('os','ppc');
+ } elseif(preg_match('/(AmigaOS [\.1-9]?)/i',$this->_browser_info['ua'],$match)) {
+ // checking for AmigaOS version string
+ $this->_set_browser('os',$match[1]);
+ }
+ }
// look for OS2
elseif( preg_match($regex_os2,$this->_browser_info['ua']))
{ $this->_set_browser('os','os2');
@@ -327,22 +347,22 @@ class phpSniff_core
$this->_set_browser('os','sco');
}
// unixware sets: platform = *nix ; os = unixware
- elseif(stristr('unix_system_v',$this->_browser_info['ua']))
+ elseif(stristr($this->_browser_info['ua'],'unix_system_v'))
{ $this->_set_browser('platform','*nix');
$this->_set_browser('os','unixware');
}
// mpras sets: platform = *nix ; os = mpras
- elseif(stristr('ncr',$this->_browser_info['ua']))
+ elseif(stristr($this->_browser_info['ua'],'ncr'))
{ $this->_set_browser('platform','*nix');
$this->_set_browser('os','mpras');
}
// reliant sets: platform = *nix ; os = reliant
- elseif(stristr('reliantunix',$this->_browser_info['ua']))
+ elseif(stristr($this->_browser_info['ua'],'reliantunix'))
{ $this->_set_browser('platform','*nix');
$this->_set_browser('os','reliant');
}
// sinix sets: platform = *nix ; os = sinix
- elseif(stristr('sinix',$this->_browser_info['ua']))
+ elseif(stristr($this->_browser_info['ua'],'sinix'))
{ $this->_set_browser('platform','*nix');
$this->_set_browser('os','sinix');
}
@@ -400,7 +420,7 @@ class phpSniff_core
{ if(!empty($browsers)) $browsers .= "|";
$browsers .= $k;
}
- $version_string = "[\/\sa-z]*([0-9]+)([\.0-9a-z]+)?";
+ $version_string = "[\/\sa-z(]*([0-9]+)([\.0-9a-z]+)?";
$this->_browser_regex = "/($browsers)$version_string/i";
}
@@ -408,43 +428,22 @@ class phpSniff_core
{ return $this->_browsers[strtolower($long_name)];
}
- /*
- function _test_cookies ()
- { global $ctest,$phpSniff_testCookie;
- if($this->_check_cookies)
- { if ($ctest != 1)
- { SetCookie('phpSniff_testCookie','test',0,'/');
- // See if we were passed anything in the QueryString we might need
- $QS = getenv('QUERY_STRING');
- // fix compatability issues when PHP is
- // running as CGI ~ 6/28/2001 v2.0.2 ~ RR
- $script_path = getenv('PATH_INFO') ? getenv('PATH_INFO') : getenv('SCRIPT_NAME');
- $location = $script_path . ($QS=="" ? "?ctest=1" : "?" . $QS . "&ctest=1");
- header("Location: $location");
- exit;
- }
- // Check for the cookie on page reload
- elseif ($phpSniff_testCookie == "test")
- { $this->_set_browser('cookies',true);
- }
- else
- { $this->_set_browser('cookies',false);
- }
- }
- else $this->_set_browser('cookies',false);
-
- }
- */
// medianes :: new test cookie routine
function _test_cookies()
- { global $phpSniff_session,$phpSniff_stored;
+ { global $HTTP_COOKIE_VARS;
+ $cookies = array();
+ if(isset($_COOKIE)) {
+ $cookies = $_COOKIE;
+ } elseif(isset($HTTP_COOKIE_VARS)) {
+ $cookies = $HTTP_COOKIE_VARS;
+ }
if($this->_check_cookies)
{ $fp = @fopen($this->_temp_file_path.$this->property('ip'),'r');
if(!$fp)
{ $fp = @fopen($this->_temp_file_path.$this->property('ip'),'a');
fclose($fp);
- setcookie('phpSniff_session','ss');
- setcookie('phpSniff_stored','st',time()+3600*24*365);
+ setcookie('phpSniff_session','ss',0,'/');
+ setcookie('phpSniff_stored','st',time()+3600*24*365,'/');
$QS=getenv('QUERY_STRING');
$script_path=getenv('PATH_INFO')?getenv('PATH_INFO'):getenv('SCRIPT_NAME');
if(is_integer($pos=strpos(strrev($script_path),"php.xedni/"))&&!$pos) {
@@ -457,12 +456,12 @@ class phpSniff_core
else
{ unlink($this->_temp_file_path.$this->property('ip'));
fclose($fp);
- // remains for backwards compatability
- $this->_set_browser('cookies',$phpSniff_session=='ss'?'true':'false');
- // new cookie settings
- $this->_set_browser('ss_cookies',$phpSniff_session=='ss'?'true':'false');
- $this->_set_browser('st_cookies',$phpSniff_stored=='st'?'true':'false');
- setcookie('phpSniff_stored','');
+ $this->_set_browser('ss_cookies',isset($cookies['phpSniff_session'])?'true':'false');
+ $this->_set_browser('st_cookies',isset($cookies['phpSniff_stored'])?'true':'false');
+ // delete the old cookies
+ setcookie('phpSniff_session','',0,'/');
+ setcookie('phpSniff_stored','',0,'/');
+
}
}
}
@@ -510,12 +509,26 @@ class phpSniff_core
function _get_gecko ()
{ if(preg_match('/gecko\/([0-9]+)/i',$this->property('ua'),$match))
{ $this->_set_browser('gecko',$match[1]);
- if (preg_match('/rv:([0-9a-z.+]+)/i',$this->property('ua'),$mozv))
- { $this->_set_browser('gecko_ver',$mozv[1]);
- }
- elseif (preg_match('/(m[0-9]+)/i',$this->property('ua'),$mozv))
- { $this->_set_browser('gecko_ver',$mozv[1]);
+ if (preg_match('/rv[: ]?([0-9a-z.+]+)/i',$this->property('ua'),$mozv)) {
+ // mozilla release
+ $this->_set_browser('gecko_ver',$mozv[1]);
+ } elseif (preg_match('/(m[0-9]+)/i',$this->property('ua'),$mozv)) {
+ // mozilla milestone version
+ $this->_set_browser('gecko_ver',$mozv[1]);
}
+ // if this is a mozilla browser, get the rv: information
+ if($this->browser_is($this->_get_short_name('mozilla'))) {
+ if(preg_match('/([0-9]+)([\.0-9]+)([a-z0-9+]?)/i',$mozv[1],$match)) {
+ $this->_set_browser('version',$mozv[1]);
+ $this->_set_browser('maj_ver',$match[1]);
+ $this->_set_browser('min_ver',$match[2]);
+ $this->_set_browser('letter_ver',$match[3]);
+ }
+ }
+ } elseif($this->is('b:'.$this->_get_short_name('mozilla'))) {
+ // this is probably a netscape browser or compatible
+ $this->_set_browser('long_name','netscape');
+ $this->_set_browser('browser',$this->_get_short_name('netscape'));
}
}
diff --git a/phpSniff/user_agent.inc b/phpSniff/user_agent.inc
index 117fc68..2750e29 100644
--- a/phpSniff/user_agent.inc
+++ b/phpSniff/user_agent.inc
@@ -1,5 +1,7 @@
\ No newline at end of file
--
libgit2 0.21.4