From 9c17eb15dcf9ffb7a08f50f34789757012d79b9e Mon Sep 17 00:00:00 2001 From: Robert Kaiser Date: Sat, 15 May 2010 16:46:47 +0200 Subject: [PATCH] add some Mozilla codenames and Windows-64bit detection --- include/classes/useragent.php-class | 55 +++++++++++++++++++++++------ testbed/ua_list_raw.txt | 7 +++- testbed/ua_test.php | 3 ++ 3 files changed, 53 insertions(+), 12 deletions(-) diff --git a/include/classes/useragent.php-class b/include/classes/useragent.php-class index 0b2279b..b6f7ab7 100755 --- a/include/classes/useragent.php-class +++ b/include/classes/useragent.php-class @@ -203,37 +203,47 @@ class userAgent { $this->bot = false; } elseif (preg_match('|Iceape/([0-9a-zA-Z\.+]+)|i', $this->uastring, $regs)) { - $this->brand = 'IceApe'; + $this->brand = 'IceApe'; // Debian-rebranded SeaMonkey $this->version = $regs[1]; $this->bot = false; } elseif (preg_match('|Iceweasel/([0-9a-zA-Z\.+]+)|i', $this->uastring, $regs)) { - $this->brand = 'IceWeasel'; + $this->brand = 'IceWeasel'; // Debian-rebranded Firefox + $this->version = $regs[1]; + $this->bot = false; + } + elseif (preg_match('|Icedove/([0-9a-zA-Z\.+]+)|i', $this->uastring, $regs)) { + $this->brand = 'IceDove'; // Debian-rebranded Thunderbird $this->version = $regs[1]; $this->bot = false; } elseif (preg_match('|BonEcho/([0-9a-zA-Z\.+]+)|i', $this->uastring, $regs)) { - $this->brand = 'Bon Echo'; + $this->brand = 'Bon Echo'; // Firefox 2.0 code name $this->version = $regs[1]; $this->bot = false; } elseif (preg_match('|GranParadiso/([0-9a-zA-Z\.+]+)|i', $this->uastring, $regs)) { - $this->brand = 'Gran Paradiso'; + $this->brand = 'Gran Paradiso'; // Firefox 3.0 code name $this->version = $regs[1]; $this->bot = false; } elseif (preg_match('|Shiretoko/([0-9a-zA-Z\.+]+)|i', $this->uastring, $regs)) { - $this->brand = 'Shiretoko'; + $this->brand = 'Shiretoko'; // Firefox 3.5 code name $this->version = $regs[1]; $this->bot = false; } elseif (preg_match('|Namoroka/([0-9a-zA-Z\.+]+)|i', $this->uastring, $regs)) { - $this->brand = 'Namoroka'; + $this->brand = 'Namoroka'; // Firefox 3.6 code name + $this->version = $regs[1]; + $this->bot = false; + } + elseif (preg_match('|Lorentz/([0-9a-zA-Z\.+]+)|i', $this->uastring, $regs)) { + $this->brand = 'Lorentz'; // Firefox 3.6 (with OOPP) code name $this->version = $regs[1]; $this->bot = false; } elseif (preg_match('|Minefield/([0-9a-zA-Z\.+]+)|i', $this->uastring, $regs)) { - $this->brand = 'Minefield'; + $this->brand = 'Minefield'; // Firefox development nightly code name $this->version = $regs[1]; $this->bot = false; } @@ -252,8 +262,13 @@ class userAgent { $this->version = $regs[1]; $this->bot = false; } + elseif (preg_match('|Lanikai/([0-9a-zA-Z\.+]+)|i', $this->uastring, $regs)) { + $this->brand = 'Lanikai'; // Thunderbird 3.1 code name + $this->version = $regs[1]; + $this->bot = false; + } elseif (preg_match('|Shredder/([0-9a-zA-Z\.+]+)|i', $this->uastring, $regs)) { - $this->brand = 'Shredder'; + $this->brand = 'Shredder'; // Thunderbird development nightly code name $this->version = $regs[1]; $this->bot = false; } @@ -268,7 +283,7 @@ class userAgent { $this->bot = false; } elseif (preg_match('|Fennec/([0-9a-zA-Z\.+]+)|i', $this->uastring, $regs)) { - $this->brand = 'Fennec'; + $this->brand = 'Fennec'; // Firefox mobile code name $this->version = $regs[1]; $this->bot = false; } @@ -1011,7 +1026,12 @@ class userAgent { $this->uadata['os'] = null; if (!$this->bot) { if ($this->hasEngine('gecko')) { - if (preg_match('|Mozilla/5.0 \(([^;]+); [^;]+; ([^;]+); ([^;]+); rv:([^\);]+)(; [^\)]+)?\)|', $this->uastring, $regs)) { + if (preg_match('|Mozilla/5.0 \(([^;]+); [^;]+; ([^;]+); ([^;]+); ([^;]+); rv:([^\);]+)(; [^\)]+)?\)|', $this->uastring, $regs)) { + $this->uadata['os'] = $regs[2].' ('.$regs[3].')'; + $this->uadata['lang'] = (strpos($regs[4],'chrome://')===false)?$regs[4]:null; + $this->uadata['eng_version'] = $regs[5]; + } + elseif (preg_match('|Mozilla/5.0 \(([^;]+); [^;]+; ([^;]+); ([^;]+); rv:([^\);]+)(; [^\)]+)?\)|', $this->uastring, $regs)) { $this->uadata['os'] = $regs[2]; $this->uadata['lang'] = (strpos($regs[3],'chrome://')===false)?$regs[3]:null; $this->uadata['eng_version'] = $regs[4]; @@ -1058,7 +1078,12 @@ class userAgent { } } elseif ($this->hasEngine('trident') || $this->hasEngine('tasman')) { - if (preg_match('/Mozilla\/[^\(]+ \(compatible *; MSP?IE ([^;]+)[^\)]*; ?((?:Mac|Win)[^;]+)[^\)]*\)/i', $this->uastring, $regs)) { + if (preg_match('/Mozilla\/[^\(]+ \(compatible *; MSP?IE ([^;]+)[^\)]*; ?((?:Mac|Win)[^;]+); ?(Win64|WOW64)[^\)]*\)/i', $this->uastring, $regs)) { + $this->uadata['eng_version'] = (strpos($this->uastring,'MSPIE')!==false)?null:$regs[1]; + $this->uadata['os'] = $regs[2].' ('.$regs[3].')'; + $this->uadata['lang'] = null; + } + elseif (preg_match('/Mozilla\/[^\(]+ \(compatible *; MSP?IE ([^;]+)[^\)]*; ?((?:Mac|Win)[^;]+)[^\)]*\)/i', $this->uastring, $regs)) { $this->uadata['eng_version'] = (strpos($this->uastring,'MSPIE')!==false)?null:$regs[1]; $this->uadata['os'] = $regs[2]; $this->uadata['lang'] = null; @@ -1240,10 +1265,18 @@ class userAgent { elseif ($this->uadata['os'] == 'WinNT4.0') { $this->uadata['os'] = 'Windows NT 4.0'; } elseif ($this->uadata['os'] == 'Windows NT 5.0') { $this->uadata['os'] = 'Windows 2000'; } elseif ($this->uadata['os'] == 'Windows NT 5.1') { $this->uadata['os'] = 'Windows XP'; } + elseif ($this->uadata['os'] == 'Windows NT 5.1 (Win64)') { $this->uadata['os'] = 'Windows XP (64bit)'; } + elseif ($this->uadata['os'] == 'Windows NT 5.1 (WOW64)') { $this->uadata['os'] = 'Windows XP (64bit)'; } elseif ($this->uadata['os'] == 'Windows NT 5.2') { $this->uadata['os'] = 'Windows 2003'; } elseif ($this->uadata['os'] == 'Windows NT 5.2 x64') { $this->uadata['os'] = 'Windows 2003 (64bit)'; } + elseif ($this->uadata['os'] == 'Windows NT 5.2 (Win64)') { $this->uadata['os'] = 'Windows 2003 (64bit)'; } + elseif ($this->uadata['os'] == 'Windows NT 5.2 (WOW64)') { $this->uadata['os'] = 'Windows 2003 (64bit)'; } elseif ($this->uadata['os'] == 'Windows NT 6.0') { $this->uadata['os'] = 'Windows Vista'; } + elseif ($this->uadata['os'] == 'Windows NT 6.0 (Win64)') { $this->uadata['os'] = 'Windows Vista (64bit)'; } + elseif ($this->uadata['os'] == 'Windows NT 6.0 (WOW64)') { $this->uadata['os'] = 'Windows Vista (64bit)'; } elseif ($this->uadata['os'] == 'Windows NT 6.1') { $this->uadata['os'] = 'Windows 7'; } + elseif ($this->uadata['os'] == 'Windows NT 6.1 (Win64)') { $this->uadata['os'] = 'Windows 7 (64bit)'; } + elseif ($this->uadata['os'] == 'Windows NT 6.1 (WOW64)') { $this->uadata['os'] = 'Windows 7 (64bit)'; } elseif ($this->uadata['os'] == 'Win95') { $this->uadata['os'] = 'Windows 95'; } elseif ($this->uadata['os'] == 'Win98') { $this->uadata['os'] = 'Windows 98'; } elseif ($this->uadata['os'] == 'WinNT') { $this->uadata['os'] = 'Windows NT'; } diff --git a/testbed/ua_list_raw.txt b/testbed/ua_list_raw.txt index 342b4c1..6208262 100755 --- a/testbed/ua_list_raw.txt +++ b/testbed/ua_list_raw.txt @@ -39,9 +39,12 @@ Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.22pre) Gecko/20090415 B Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.15pre) Gecko/2009090911 GranParadiso/3.0.15pre (.NET CLR 3.5.30729) Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.1.4pre) Gecko/20090923 Shiretoko/3.5.4pre Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.6; en-US; rv:1.9.2a2pre) Gecko/20090917 Namoroka/3.6a2pre +Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2.3pre) Gecko/20100403 Lorentz/3.6.3plugin2pre (.NET CLR 4.0.20506) Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9a9pre) Gecko/2007110108 prism/0.8 Mozilla/5.0 (Windows; U; Windows NT 6.1; de; rv:1.9.1.4pre) Gecko/20090928 Lightning/1.0pre Shredder/3.0pre +Mozilla/5.0 (Windows; U; Windows NT 6.1; WOW64; en-US; rv:1.9.3a5pre) Gecko/20100514 Lanikai/3.1b1 Mozilla/5.0 (Windows; U; Windows NT 5.1; de; rv:1.8.1.19) Gecko/20081209 Thunderbird/2.0.0.19 Mnenhy/0.7.5.0 +Mozilla/5.0 (Windows; U; Windows NT 5.1; es-ES; rv:1.9.1.7) Gecko/20100111 Icedove/3.0.1 ThunderBrowse/3.2.8.1 Mozilla/5.0 (X11; U; Linux i686; de-AT; rv:1.8b2) Gecko/20050324 SeaMonkey/1.0a Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9a6pre) Gecko/20070628 Firefox/2.0.0.4 SeaMonkey/2.0a1pre PrivatelyFakedUA/0.0 Mozilla/5.0 (Macintosh; U; PPC Mac OS X; en-US; rv:1.0.1) Gecko/20021109 Chimera/0.6+ @@ -80,6 +83,8 @@ Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; IE5.x/Winxx/EZN/xx; .NET CLR Mozilla/4.0 (compatible ; MSIE 6.0; Windows NT 5.1) Mozilla/4.0 (compatible; MSIE 5.5; Windows 98; Win 9x 4.90; T312461) Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; YPC 3.0.1; .NET CLR 1.1.4322; .NET CLR 2.0.50727) +Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.0; Win64; x64; .NET CLR 2.0.50727; SLCC1; Media Center PC 5.0; .NET CLR 3.0.04506) +Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; MDDC) Mozilla/4.0 (compatible; MSIE 4.01; Windows CE; Smartphone; 176x220) Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; Hotbar 4.5.1.0; MSN 6.1; MSNbMSFT; MSNmen-au; MSNc00; v5m) Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322; MSN 9.0;MSN 9.1; MSNbVZ02; MSNmen-us; MSNcOTH; MPLUS) @@ -396,7 +401,7 @@ Mozilla/4.0 (compatible; B-l-i-t-z-B-O-T) LargeSmall Crawler (LargeSmall; http://onespot.com; info@onespot.com) B l i t z B O T @ t r i c u s . n e t (Mozilla compatible) sitecheck.internetseer.com (For more info see: ">http://sitecheck.internetseer.com) -http://www.almaden.ibm.com/cs/crawler   [c01] +http://www.almaden.ibm.com/cs/crawler   [c01] ia_archiver ia_archiver (+http://www.alexa.com/site/help/webmasters; crawler@alexa.com) Nutch diff --git a/testbed/ua_test.php b/testbed/ua_test.php index 4bcbd05..97309b3 100644 --- a/testbed/ua_test.php +++ b/testbed/ua_test.php @@ -5,6 +5,9 @@ include("inchandler.inc"); $wrapper->pgtop("KaiRo's Browser-Test"); +// set default time zone - right now, always the one the server is in! +date_default_timezone_set('Europe/Vienna'); + $httpvars = $util->getHTTPvars(); if (strlen($httpvars["ua"])) { $ua = new userAgent($httpvars["ua"]); -- 2.35.3