X-Git-Url: https://git-public.kairo.at/?p=php-utility-classes.git;a=blobdiff_plain;f=include%2Fclasses%2Fuseragent.php-class;h=be512f46c98dce52b7cf04f754d001747919a63a;hp=9a28094682a406b42f56d74eb369eb99cec62c04;hb=1759d73b42c56c60843123d35df54184fbacd7af;hpb=588763e6abf20ff0134126764ce05f54f35961d8 diff --git a/include/classes/useragent.php-class b/include/classes/useragent.php-class index 9a28094..be512f4 100755 --- a/include/classes/useragent.php-class +++ b/include/classes/useragent.php-class @@ -16,7 +16,7 @@ * * The Initial Developer of the Original Code is * KaiRo - Robert Kaiser. - * Portions created by the Initial Developer are Copyright (C) 2003 + * Portions created by the Initial Developer are Copyright (C) 2003-2007 * the Initial Developer. All Rights Reserved. * * Contributor(s): Robert Kaiser @@ -97,6 +97,9 @@ class userAgent { // public function getGeckoDate() // returns the Gecko date for Gecko-based browsers, null for others // + // public function getGeckoTime() + // returns the Gecko build date/time as a unix epoch time number for Gecko-based browsers, null for others + // // *** functions for compat to older versions of this class *** // // public function isns() @@ -164,6 +167,11 @@ class userAgent { $this->version = $regs[1]; $this->bot = false; } + elseif (preg_match('|Navigator/([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) { + $this->brand = 'Netscape'; + $this->version = $regs[1]; + $this->bot = false; + } elseif (preg_match('|Chimera/([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) { $this->brand = 'Chimera'; $this->version = $regs[1]; @@ -189,11 +197,6 @@ class userAgent { $this->version = $regs[1]; $this->bot = false; } - elseif (preg_match('|Firefox/([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) { - $this->brand = 'Firefox'; - $this->version = $regs[1]; - $this->bot = false; - } elseif (preg_match('|SeaMonkey/([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) { $this->brand = 'SeaMonkey'; $this->version = $regs[1]; @@ -209,6 +212,16 @@ class userAgent { $this->version = $regs[1]; $this->bot = false; } + elseif (preg_match('|Minefield/([0-9a-zA-Z\.+]+)|i', $this->uastring, $regs)) { + $this->brand = 'Minefield'; + $this->version = $regs[1]; + $this->bot = false; + } + elseif (preg_match('|Minimo/([0-9a-zA-Z\.+]+)|i', $this->uastring, $regs)) { + $this->brand = 'Minimo'; + $this->version = $regs[1]; + $this->bot = false; + } elseif (preg_match('|Galeon/([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) { $this->brand = 'Galeon'; $this->version = $regs[1]; @@ -229,18 +242,11 @@ class userAgent { $this->version = $regs[1]; $this->bot = false; } - elseif (preg_match('|rv:([0-9a-zA-Z\.+]+)|', $this->uastring, $regs) && - strstr($this->uastring, "Mozilla/") && strstr($this->uastring, "Gecko/")) { - $this->brand = 'Mozilla'; + elseif (preg_match('|Tablet browser ([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) { + $this->brand = 'microB'; $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\/([^\(]+) \(.*; Opera Mini; |', $this->uastring, $regs)) { $this->brand = 'Opera Mini'; $this->version = $regs[1]; @@ -271,6 +277,11 @@ class userAgent { $this->version = $regs[1]; $this->bot = false; } + elseif (preg_match('|Chrome/([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) { + $this->brand = 'Chrome'; + $this->version = $regs[1]; + $this->bot = false; + } elseif (preg_match('|Safari/([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) { $this->brand = 'Safari'; if (preg_match('|Version/([0-9a-zA-Z\.+]+)|', $this->uastring, $vregs)) { @@ -286,6 +297,23 @@ class userAgent { $this->version = $regs[1]; $this->bot = false; } + elseif (preg_match('|Firefox/([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) { + $this->brand = 'Firefox'; + $this->version = $regs[1]; + $this->bot = false; + } + elseif (preg_match('|rv:([0-9a-zA-Z\.+]+)|', $this->uastring, $regs) && + strstr($this->uastring, "Mozilla/") && strstr($this->uastring, "Gecko/")) { + $this->brand = 'Mozilla'; + $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('|MSFrontPage/([0-9a-zA-Z\.+]+)|', $this->uastring, $regs)) { $this->brand = 'Microsoft FrontPage'; $this->version = $regs[1]; @@ -731,7 +759,7 @@ class userAgent { if (!isset($this->uadata['engine'])) { $this->uadata['engine'] = 'unknown'; $this->uadata['geckodate'] = null; - if (preg_match('|Gecko/([0-9]+)|', $this->uastring, $regs)) { + if (preg_match('|Gecko/([0-9]+)|', $this->uastring, $regs) && (strpos($this->brand, 'Opera') === false)) { $this->uadata['engine'] = 'gecko'; $this->uadata['geckodate'] = $regs[1]; } @@ -744,7 +772,7 @@ class userAgent { } } elseif ((strpos($this->brand, 'Konqueror') !== false) || (strpos($this->brand, 'Safari') !== false) || - (strpos($this->brand, 'Shiira') !== false) || + (strpos($this->brand, 'Shiira') !== false) || (strpos($this->brand, 'Chrome') !== false) || (strpos($this->brand, 'AppleWebKit') !== false) || (strpos($this->brand, 'OmniWeb') !== false)) { $this->uadata['engine'] = 'khtml'; } @@ -941,6 +969,12 @@ class userAgent { $this->uadata['os'] = $regs[1]; $this->uadata['lang'] = $regs[2]; } + // Opera 9 Firefox-spoofing + elseif (preg_match('/Mozilla\/[^\(]+ \((?:X11; )?([^;]+);.+; ([a-z_-]+); rv:([^\);]+)\) Gecko\/\d+ Firefox\/[0-9a-zA-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_-]+)\][^\(]+)?\(X11; [^;]+; ([^\)]+)\)/i', $this->uastring, $regs)) { @@ -1078,6 +1112,24 @@ class userAgent { return $this->uadata['geckodate']; } + public function getGeckoTime() { + if (!isset($this->uadata['geckotime'])) { + $this->uadata['geckotime'] = null; + if (!is_null($this->getGeckoDate())) { + $use_time = (strlen($this->getGeckoDate()) > 8); + $gd_str = substr($this->getGeckoDate(),0,4).'-'.substr($this->getGeckoDate(),4,2).'-'.substr($this->getGeckoDate(),6,2); + if ($use_time) { + $gd_str .= substr($this->getGeckoDate(),8,2).':00'; + $old_tz = date_default_timezone_get(); + date_default_timezone_set("America/Los_Angeles"); + } + $this->uadata['geckotime'] = strtotime($gd_str); + if ($use_time) { date_default_timezone_set($old_tz); } + } + } + return $this->uadata['geckotime']; + } + public function isBot() { return $this->bot; } public function isns() {