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=e71505a73c533c8e6a5693dbade5cc7370230597;hb=1759d73b42c56c60843123d35df54184fbacd7af;hpb=208cf8374e858cef5cc6ca2a304145dcf4e37fdd diff --git a/include/classes/useragent.php-class b/include/classes/useragent.php-class index e71505a..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() @@ -239,6 +242,11 @@ class userAgent { $this->version = $regs[1]; $this->bot = false; } + 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('|Opera\/([^\(]+) \(.*; Opera Mini; |', $this->uastring, $regs)) { $this->brand = 'Opera Mini'; $this->version = $regs[1]; @@ -269,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)) { @@ -746,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]; } @@ -759,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'; } @@ -956,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)) { @@ -1093,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() {