From 35fe33f7364329dacf415c950bff01b6de9ef88e Mon Sep 17 00:00:00 2001 From: Christian Schneider Date: Thu, 11 Oct 2007 00:39:30 +0000 Subject: Populated release branch --- it_browser.class | 178 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 178 insertions(+) create mode 100644 it_browser.class (limited to 'it_browser.class') diff --git a/it_browser.class b/it_browser.class new file mode 100644 index 0000000..e67b658 --- /dev/null +++ b/it_browser.class @@ -0,0 +1,178 @@ +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 (preg_match("/\((.+)\)/U", $this->UserAgent, $regs)) + { + $optattr = preg_split("/;\s+/", $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]; + + for ($i=1; $i < count($optattr); $i++) + { + if (preg_match("/^([a-z]{2})(\-[a-z]{2})?$/i", $optattr[$i], $regs)) + $this->Language = $regs[1]; + if (preg_match("/^rv:([0-9\.]+)/", $optattr[$i], $regs)) + $this->Version = floatval($regs[1]); + if (strstr($optattr[$i], "Linux") || $optattr[$i] == "X11") + $this->Platform = "Linux"; + } + } + + /* Find optional "[de]" */ + if (!$this->Language && ereg("\[(.*)\]", $this->UserAgent, $regs)) + $this->Language = $regs[1]; + + /* Check for Safari/KHTML */ + if (preg_match("/(Safari|AppleWebKit)\/([0-9\.]+)/", $this->UserAgent, $regs)) + { + $this->Type = "Safari"; + $this->Version = floatval($regs[2]); + } + + /* Check for Gecko based browser */ + if ($this->Type == "Mozilla" && preg_match("/[^a-z]Gecko[^a-z]/", $this->UserAgent)) + $this->Type = "Gecko"; + else if ($this->Type == "Mozilla" && $this->Version < 5) + $this->Type = "Netscape"; + + + /* And now for the browser capabilities ... */ + if ($this->Type == "MSIE") + { + $this->MSIE = $this->Version; + $this->HTMLVersion = 4.0; + $this->JavaScript = true; + $this->VML = ($this->Version >= 5.5); + $this->XMLHTTP = ($this->Version >= 5); + $this->CSS = $this->Version >= 4.0 ? 2 : 1; + $this->CSSFilter = ($this->Version >= 5.0); + } + else if ($this->Type == "Opera") + { + $this->Opera = $this->Version; + if ($this->Version >= 3.5) + { + $this->HTMLVersion = 4.0; + $this->CSS = 2; + } + else + { + $this->HTMLVersion = 3.2; + $this->CSS = 1; + } + $this->JavaScript = true; + $this->XMLHTTP = ($this->Version >= 8); + } + else if ($this->Type == "Konqueror") + { + $this->HTMLVersion = 4.0; + $this->CSS = 2; + $this->JavaScript = true; + $this->XMLHTTP = ($this->Version >= 3); + } + else if ($this->Type == "Netscape") + { + $this->NS = $this->Version; + $this->HTMLVersion = 4.0; + $this->JavaScript = true; + + if ($this->Version >= 5.0) + $this->CSS = 2; + } + else if ($this->Type == "Gecko") + { + $this->HTMLVersion = 4.0; + $this->CSS = 2; + $this->JavaScript = true; + $this->XMLHTTP = true; + $this->Canvas = ($this->Version >= 1.8); + } + else if ($this->Type == "Safari") + { + $this->HTMLVersion = 4.0; + $this->JavaScript = true; + $this->CSS = 2; + $this->XMLHTTP = true; + $this->Canvas = ($this->Version >= 418); + } + else if ($this->Type == "Lynx") + $this->TextOnly = 1; +} + +} /* End Class it_Browser */ +?> -- cgit v1.2.3