X-Git-Url: https://git-public.kairo.at/?p=php-utility-classes.git;a=blobdiff_plain;f=include%2Fclasses%2Fuseragent.php-class;h=12293d5f1139519fc7baacefd843e55d8a1b7c18;hp=6d67596a1fe0b2ebf59a768dadc1d6ed7a4f3487;hb=1d38ad3ee1a46eccab547c04f66072d99f323f60;hpb=81e72a3e94e70be95cc42d323091643987f8f758 diff --git a/include/classes/useragent.php-class b/include/classes/useragent.php-class index 6d67596..12293d5 100755 --- a/include/classes/useragent.php-class +++ b/include/classes/useragent.php-class @@ -68,7 +68,7 @@ class userAgent { // // function getEngine() // returns a string telling the detected rendering engine, null if we can't detect - // one of gecko|khtml|trident|tasman|nscp|presto|gzilla|gtkhtml|links|unkown + // one of gecko|khtml|trident|tasman|nscp|presto|gzilla|gtkhtml|links|unknown // // function hasEngine($rnd_engine) // returns true if the given rendering engine was detected @@ -83,7 +83,7 @@ class userAgent { // // function getPlatform() // returns a string telling the detected OS platform, null if we can't detect - // one of windows|linux|mac|solaris|unkown + // one of windows|linux|mac|solaris|unknown // // function getLanguage() { // returns a string telling the detected browser UI language, null if we can't detect @@ -217,6 +217,11 @@ class userAgent { $this->version = $regs[1]; $this->bot = false; } + elseif (preg_match('|m([0-9]+)\)|', $this->uastring, $regs) && strstr($this->uastring, "Mozilla/") && strstr($this->uastring, "Gecko/")) { + $this->brand = 'Mozilla'; + $this->version = 'M'.$regs[1]; + $this->bot = false; + } elseif (preg_match('|Opera[ /]([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) { $this->brand = 'Opera'; $this->version = $regs[1]; @@ -449,7 +454,7 @@ class userAgent { foreach ($accLcomp as $lcomp) { if (strlen($lcomp)) { $ldef = explode(';', $lcomp); - $accLang[$ldef[0]] = (float)((strpos($ldef[1],'q=')===0)?substr($ldef[1],2):1); + $accLang[$ldef[0]] = (float)((strpos(@$ldef[1],'q=')===0)?substr($ldef[1],2):1); } } $this->uadata['accept-languages'] = $accLang; @@ -460,9 +465,9 @@ class userAgent { function getUAString() { return $this->uastring; } function getEngine() { - // return gecko|khtml|trident|tasman|nscp|presto|gzilla|gtkhtml|links|unkown + // return gecko|khtml|trident|tasman|nscp|presto|gzilla|gtkhtml|links|unknown if (!isset($this->uadata['engine'])) { - $this->uadata['engine'] = 'unkown'; + $this->uadata['engine'] = 'unknown'; $this->uadata['geckodate'] = null; if (preg_match('|Gecko/([0-9]+)|', $this->uastring, $regs)) { $this->uadata['engine'] = 'gecko'; @@ -526,7 +531,7 @@ class userAgent { if ($this->hasEngine('gecko')) { if (preg_match('|Mozilla/5.0 \(([^;]+); [^;]+; ([^;]+); ([^;]+); rv:([^\);]+)(; [^\)]+)?\)|', $this->uastring, $regs)) { $this->uadata['os'] = $regs[2]; - $this->uadata['lang'] = $regs[3]; + $this->uadata['lang'] = (strpos($regs[3],'chrome://')===false)?$regs[3]:null; $this->uadata['eng_version'] = $regs[4]; } elseif (preg_match('|Mozilla/5.0 \(([^;]+); [^;]+; ([^;]+); rv:([^\);]+)(; [^\)]+)?\)|', $this->uastring, $regs)) { @@ -539,11 +544,21 @@ class userAgent { $this->uadata['lang'] = $regs[3]; $this->uadata['eng_version'] = 'M'.$regs[4]; } + elseif (preg_match('|Mozilla/5.0 \(([^;]+); [^;]+; ([^;]+); m([^\);]+)\)|', $this->uastring, $regs)) { + $this->uadata['os'] = $regs[1]; + $this->uadata['lang'] = $regs[2]; + $this->uadata['eng_version'] = 'M'.$regs[3]; + } elseif (preg_match('|Mozilla/5.0 \(([^;]+); [^;]+; ([^;]+); ([^\);]+)\)|', $this->uastring, $regs)) { $this->uadata['os'] = $regs[2]; $this->uadata['lang'] = $regs[3]; $this->uadata['eng_version'] = null; } + elseif (preg_match('|Mozilla/5.0 \(([^;]+); ([^;]+); rv:([^\);]+)\)|', $this->uastring, $regs)) { + $this->uadata['os'] = $regs[2]; + $this->uadata['lang'] = null; + $this->uadata['eng_version'] = $regs[3]; + } elseif (preg_match('|Mozilla/5.0 \(([^;]+); [^;]+; ([^\);]+)\)|', $this->uastring, $regs)) { $this->uadata['os'] = $regs[2]; $this->uadata['lang'] = null; @@ -595,40 +610,45 @@ class userAgent { } } elseif ($this->hasEngine('presto')) { - if (preg_match('/Opera\/[^\(]+ \(([^;]+)[^\)]+\) +\[([a-z_-]+)\]/i', $this->uastring, $regs)) { + if (preg_match('/Opera\/[^\(]+ \((?:X11; )?([^;]+)[^\)]+\) +\[([a-z_-]+)\]/i', $this->uastring, $regs)) { $this->uadata['eng_version'] = $this->getVersion(); $this->uadata['os'] = $regs[1]; $this->uadata['lang'] = $regs[2]; } - elseif (preg_match('/Mozilla\/[^\(]+ \(compatible; .+; ([^;]+)\) Opera [^ ]+ \[([a-z_-]+)\]/i', $this->uastring, $regs)) { + elseif (preg_match('/Mozilla\/[^\(]+ \(compatible; MSIE [^;]+; (?:X11; )?([^;\)]+)[^\)]*\) Opera [^ ]+ +\[([a-z_-]+)\]/i', $this->uastring, $regs)) { $this->uadata['eng_version'] = $this->getVersion(); $this->uadata['os'] = $regs[1]; $this->uadata['lang'] = $regs[2]; } - elseif (preg_match('/Mozilla\/[^\(]+ \(([^;]+);.+\) Opera [^ ]+ \[([a-z_-]+)\]/i', $this->uastring, $regs)) { + elseif (preg_match('/Mozilla\/[^\(]+ \((?:X11; )?([^;]+);.+\) Opera [^ ]+ \[([a-z_-]+)\]/i', $this->uastring, $regs)) { $this->uadata['eng_version'] = $this->getVersion(); $this->uadata['os'] = $regs[1]; $this->uadata['lang'] = $regs[2]; } // Opera 8 - elseif (preg_match('/Opera\/[^\(]+ \(([^;]+); [^\)]+; ([a-z_-]+)\)/i', $this->uastring, $regs)) { + elseif (preg_match('/Opera\/[^\(]+ \((?:X11; )?([^;]+); [^\)]+; ([a-z_-]+)\)/i', $this->uastring, $regs)) { $this->uadata['eng_version'] = $this->getVersion(); $this->uadata['os'] = $regs[1]; $this->uadata['lang'] = $regs[2]; } - elseif (preg_match('/Mozilla\/[^\(]+ \(compatible; .+; ([^;]+); ([a-z_-]+)\) Opera [^ ]+/i', $this->uastring, $regs)) { + elseif (preg_match('/Mozilla\/[^\(]+ \(compatible; MSIE [^;]+; (?:X11; )?([^;]+); ([a-z_-]+)\) Opera [^ ]+/i', $this->uastring, $regs)) { $this->uadata['eng_version'] = $this->getVersion(); $this->uadata['os'] = $regs[1]; $this->uadata['lang'] = $regs[2]; } - elseif (preg_match('/Mozilla\/[^\(]+ \(([^;]+);.+; ([a-z_-]+)\) Opera [^ ]+/i', $this->uastring, $regs)) { + elseif (preg_match('/Mozilla\/[^\(]+ \((?:X11; )?([^;]+);.+; ([a-z_-]+)\) Opera [^ ]+/i', $this->uastring, $regs)) { $this->uadata['eng_version'] = $this->getVersion(); $this->uadata['os'] = $regs[1]; $this->uadata['lang'] = $regs[2]; } } elseif ($this->hasEngine('nscp')) { - if (preg_match('/Mozilla\/([0-9a-zA-Z\.+]+) (?:\[([a-z_-]+)\][^\(]+)?\(([^;]+);[^\)]+\)/i', $this->uastring, $regs)) { + if (preg_match('/Mozilla\/([0-9a-zA-Z\.+]+) (?:\[([a-z_-]+)\][^\(]+)?\(X11; [^;]+; ([^\)]+)\)/i', $this->uastring, $regs)) { + $this->uadata['eng_version'] = $regs[1]; + $this->uadata['os'] = $regs[3]; + $this->uadata['lang'] = $regs[2]; + } + elseif (preg_match('/Mozilla\/([0-9a-zA-Z\.+]+) (?:\[([a-z_-]+)\][^\(]+)?\(([^;]+);[^\)]+\)/i', $this->uastring, $regs)) { $this->uadata['eng_version'] = $regs[1]; $this->uadata['os'] = $regs[3]; $this->uadata['lang'] = $regs[2]; @@ -670,8 +690,13 @@ class userAgent { 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.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 6.0') { $this->uadata['os'] = 'Windows Vista'; } 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'; } + elseif ($this->uadata['os'] == 'Win32') { $this->uadata['os'] = 'Windows (32bit)'; } + elseif ($this->uadata['os'] == 'Win64') { $this->uadata['os'] = 'Windows (64bit)'; } elseif (preg_match('/Mac ?OS ?X/i',$this->uadata['os'])) { $this->uadata['os'] = 'MacOS X'; } elseif (preg_match('/Mac_P(ower|)PC/i',$this->uadata['os'])) { $this->uadata['os'] = 'MacOS'; } elseif (strpos($this->uadata['os'], 'darwin') !== false) { $this->uadata['os'] = 'MacOS X'; }