From 4e20871f1a5d8ad690e742dabb6957763983a6c0 Mon Sep 17 00:00:00 2001 From: Thomas BrĂ¼derli Date: Tue, 23 Sep 2008 09:53:41 +0000 Subject: Improve browser detection --- it_browser.class | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/it_browser.class b/it_browser.class index c20b6c3..f46df92 100644 --- a/it_browser.class +++ b/it_browser.class @@ -59,7 +59,7 @@ class it_browser function it_browser() { $this->UserAgent = $_SERVER['HTTP_USER_AGENT']; - /* $this->UserAgent = "Mozilla/4.0 [de] (compatible; MSIE 5.0; Bill Gates 1.0; Windows 95)"; */ + /* $this->UserAgent = "Mozilla/4.0 [de] (compatible; MSIE 5.0; Windows 95; .NET CRL 2.0.154)"; */ /* Find "Mozilla/4.0" */ if (ereg("([^/]*)/([^ ]*)", $this->UserAgent, $regs)) @@ -82,7 +82,7 @@ function it_browser() else $this->Type = $optattr[1]; - $this->Platform = $optattr[count($optattr)-1]; + $this->Platform = !empty($optattr[2]) ? $optattr[2] : $optattr[count($optattr)-1]; } else $this->Platform = $optattr[0]; @@ -115,6 +115,12 @@ function it_browser() else if ($this->Type == "Mozilla" && $this->Version < 5) $this->Type = "Netscape"; + /* Read language from Accept-Language header */ + if (!$this->Language && $_SERVER['HTTP_ACCEPT_LANGUAGE']) + { + $accept_langs = explode(',', $_SERVER['HTTP_ACCEPT_LANGUAGE']); + $this->Language = substr($accept_langs[0], 0, 2); + } /* And now for the browser capabilities ... */ if ($this->Type == "MSIE") -- cgit v1.2.3