From a5a19fd672bc0b8113d620669b557f17dccd343a Mon Sep 17 00:00:00 2001 From: Christian Schneider Date: Thu, 26 Oct 2006 13:35:12 +0000 Subject: Moved itools to live branch --- browser.class | 126 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 126 insertions(+) create mode 100644 browser.class (limited to 'browser.class') diff --git a/browser.class b/browser.class new file mode 100644 index 0000000..2018247 --- /dev/null +++ b/browser.class @@ -0,0 +1,126 @@ +UserAgent = $_SERVER['HTTP_USER_AGENT']; + /* $this->UserAgent = "Mozilla/4.0 [de] (compatible; MSIE 5.0; Bill Gates 1.0; Windows 95)"; */ + + /* Find "Mozilla/4.0" */ + if (ereg("([^/]*)/([^ ]*)", $this->UserAgent, $regs)) + { + $this->Type = $regs[1]; + $this->Version = (double)$regs[2]; + } + + /* Find optional "(compatible; MSIE 3.0; Win95)" */ + if (ereg("\((.*)\)", $this->UserAgent, $regs)) + { + $optattr = split("; ", $regs[1]); + if ($optattr[0] == "compatible") + { + if (ereg("([^/]*)[/ ]([^/]*)", $optattr[1], $regs)) + { + $this->Type = $regs[1]; + $this->Version = (double)$regs[2]; + } + else $this->Type = $optattr[1]; + $this->Platform = $optattr[count($optattr)-1]; + } + else + $this->Platform = $optattr[0]; + } + + if ($this->Type == "Mozilla") + $this->Type = "Netscape"; + + /* Find optional "[de]" */ + if (ereg("\[(.*)\]", $this->UserAgent, $regs)) + $this->Language = $regs[1]; + + /* And now for the browser capabilities ... */ + if ($this->Type == "MSIE") + { + $this->MSIE = $this->Version; + $this->HTMLVersion = 4.0; + $this->JavaScript = 1; + + if ($this->Version >= 4.0) + $this->CSS = 2; + } + else if ($this->Type == "Opera") + { + $this->Opera = $this->Version; + if ($this->Version >= 3.5) + $this->HTMLVersion = 4.0; + else + $this->HTMLVersion = 3.2; + $this->JavaScript = 1; + } + else if ($this->Type == "Konqueror") + { + $this->HTMLVersion = 4.0; + $this->CSS = 2; + $this->JavaScript = 1; + } + else if ($this->Type == "Netscape") + { + $this->NS = $this->Version; + $this->HTMLVersion = 4.0; + $this->JavaScript = 1; + + if ($this->Version >= 5.0) + $this->CSS = 2; + } + else if ($this->Type == "Lynx") + $this->TextOnly = 1; +} + +} /* End Class it_Browser */ +?> -- cgit v1.2.3