From: Robert Kaiser Date: Thu, 5 Aug 2010 13:26:59 +0000 (+0200) Subject: detect Geckos with removed Windows token, correct IE and Trident version detection X-Git-Url: https://git-public.kairo.at/?a=commitdiff_plain;h=ee2c4e9bc09231337f24097bb7d8ce10e818fb6e;p=php-utility-classes.git detect Geckos with removed Windows token, correct IE and Trident version detection --- diff --git a/include/classes/useragent.php-class b/include/classes/useragent.php-class index d941b79..3414909 100755 --- a/include/classes/useragent.php-class +++ b/include/classes/useragent.php-class @@ -888,6 +888,16 @@ class userAgent { $this->version = '1.0'; $this->bot = false; } + elseif (preg_match('|MSIE 7\.0.+Trident/4.0|', $this->uastring, $regs)) { + $this->brand = 'Microsoft Internet Explorer'; + $this->version = "8.0"; + $this->bot = false; + } + elseif (preg_match('|MSIE 7\.0.+Trident/5.0|', $this->uastring, $regs)) { + $this->brand = 'Microsoft Internet Explorer'; + $this->version = "9.0"; + $this->bot = false; + } elseif (preg_match('|MSIE ([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) { $this->brand = 'Microsoft Internet Explorer'; $this->version = $regs[1]; @@ -1071,6 +1081,11 @@ class userAgent { $this->uadata['lang'] = null; $this->uadata['eng_version'] = null; } + elseif (preg_match('|Mozilla/5.0 \(([^;]+); rv:([^\);]+)\)|', $this->uastring, $regs)) { + $this->uadata['os'] = $regs[1]; + $this->uadata['lang'] = null; + $this->uadata['eng_version'] = $regs[2]; + } elseif (preg_match('|Mozilla/5.0 Galeon/[^\(]+ \(([^;]+); ([^;]+);[^\)]+\)|', $this->uastring, $regs)) { $this->uadata['os'] = $regs[2]; $this->uadata['lang'] = null; @@ -1083,23 +1098,33 @@ class userAgent { } } elseif ($this->hasEngine('trident') || $this->hasEngine('tasman')) { - 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]; + if (preg_match('/Mozilla\/[^\(]+ \(compatible *; MSIE [^;]+[^\)]*; ?((?:Mac|Win)[^;]+); ?(Win64|WOW64)[^\)]*Trident\/([^;\)]+)[^\)]*\)/i', $this->uastring, $regs)) { + $this->uadata['eng_version'] = $regs[3]; + $this->uadata['os'] = $regs[1].' ('.$regs[2].')'; + $this->uadata['lang'] = null; + } + elseif (preg_match('/Mozilla\/[^\(]+ \(compatible *; MSIE [^;]+[^\)]*; ?((?:Mac|Win)[^;]+); ?[^\)]*Trident\/([^;\)]+)[^\)]*\)/i', $this->uastring, $regs)) { + $this->uadata['eng_version'] = $regs[2]; + $this->uadata['os'] = $regs[1]; + $this->uadata['lang'] = null; + } + elseif (preg_match('/Mozilla\/[^\(]+ \(compatible *; MSP?IE ([^;]+)[^\)]*; ?((?:Mac|Win)[^;]+); ?(Win64|WOW64)[^\)]*\)/i', $this->uastring, $regs)) { + $this->uadata['eng_version'] = (strpos($this->uastring,'MSPIE')!==false)?null:"ie".$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['eng_version'] = (strpos($this->uastring,'MSPIE')!==false)?null:"ie".$regs[1]; $this->uadata['os'] = $regs[2]; $this->uadata['lang'] = null; } elseif (preg_match('/Mozilla\/[^\(]+ \(compatible *; MSIE ([^;]+)[^\)]*\)/i', $this->uastring, $regs)) { - $this->uadata['eng_version'] = $regs[1]; + $this->uadata['eng_version'] = "ie".$regs[1]; $this->uadata['os'] = null; $this->uadata['lang'] = null; } elseif (preg_match('/Microsoft Internet Explorer\/[^\s]+ \(((?:Mac|Win)[^;\)]+)\)/i', $this->uastring, $regs)) { - $this->uadata['eng_version'] = $this->getVersion(); + $this->uadata['eng_version'] = "ie".$this->getVersion(); $this->uadata['os'] = $regs[1]; $this->uadata['lang'] = null; } diff --git a/testbed/ua_list_raw.txt b/testbed/ua_list_raw.txt index 7808040..11f3b1b 100755 --- a/testbed/ua_list_raw.txt +++ b/testbed/ua_list_raw.txt @@ -35,7 +35,8 @@ Mozilla/5.0 (X11; U; Linux i686; chrome://navigator/locale/navigator.properties; Mozilla/5.0 (Windows; Windows NT 5.1; en-US; rv:1.9.2a1pre) Gecko/20090402 Firefox/3.6a1pre Mozilla/5.0 (Windows; U; Windows NT 5.1; rv:1.7.5) Gecko/20041217 Firefox/1.0.4 Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9a6pre) Gecko/20070702 Minefield/3.0a6pre -Mozilla/5.0 (Windows; Windows NT 6.1; rv:2.0b4pre) Gecko/20100707 Minefield/4.0b4pre +Mozilla/5.0 (Windows; Windows NT 6.0; rv:2.0b3pre) Gecko/20100707 Minefield/4.0b3pre +Mozilla/5.0 (Windows NT 6.1; rv:2.0b4pre) Gecko/20100806 Minefield/4.0b4pre Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.22pre) Gecko/20090415 BonEcho/2.0.0.22pre (.NET CLR 3.5.30729) 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 @@ -87,6 +88,10 @@ 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 7.0; Windows NT 5.1; Trident/4.0) +Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0; Trident/5.0) +Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0) +Mozilla/4.0 (compatible; MSIE 7.0; Windows Phone OS 7.0; Trident/3.1; IEMobile/7.0; DeviceManufacturer;DeviceModel) 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)