4 +-----------------------------------------------------------------------+
5 | program/include/rcube_browser.php |
7 | This file is part of the RoundCube Webmail client |
8 | Copyright (C) 2007-2009, RoundCube Dev. - Switzerland |
9 | Licensed under the GNU GPL |
12 | Class representing the client browser's properties |
14 +-----------------------------------------------------------------------+
15 | Author: Thomas Bruederli <roundcube@gmail.com> |
16 +-----------------------------------------------------------------------+
18 $Id: rcube_browser.php 328 2006-08-30 17:41:21Z thomasb $
25 * Provide details about the client's browser based on the User-Agent header
31 function __construct()
33 $HTTP_USER_AGENT = $_SERVER['HTTP_USER_AGENT'];
36 $this->win = stristr($HTTP_USER_AGENT, 'win');
37 $this->mac = stristr($HTTP_USER_AGENT, 'mac');
38 $this->linux = stristr($HTTP_USER_AGENT, 'linux');
39 $this->unix = stristr($HTTP_USER_AGENT, 'unix');
41 $this->opera = stristr($HTTP_USER_AGENT, 'opera');
42 $this->ns4 = stristr($HTTP_USER_AGENT, 'mozilla/4') && !stristr($HTTP_USER_AGENT, 'msie');
43 $this->ns = ($this->ns4 || stristr($HTTP_USER_AGENT, 'netscape'));
44 $this->ie = stristr($HTTP_USER_AGENT, 'compatible; msie') && !$this->opera;
45 $this->mz = stristr($HTTP_USER_AGENT, 'mozilla/5');
46 $this->khtml = stristr($HTTP_USER_AGENT, 'khtml');
47 $this->safari = ($this->khtml || stristr($HTTP_USER_AGENT, 'safari'));
50 $test = preg_match('/mozilla\/([0-9.]+)/i', $HTTP_USER_AGENT, $regs);
51 $this->ver = $test ? (float)$regs[1] : 0;
54 $test = preg_match('/rv:([0-9.]+)/', $HTTP_USER_AGENT, $regs);
55 $this->ver = $test ? (float)$regs[1] : 0;
58 $test = preg_match('/msie ([0-9.]+)/i', $HTTP_USER_AGENT, $regs);
59 $this->ver = $test ? (float)$regs[1] : 0;
62 $test = preg_match('/opera ([0-9.]+)/i', $HTTP_USER_AGENT, $regs);
63 $this->ver = $test ? (float)$regs[1] : 0;
66 if (preg_match('/ ([a-z]{2})-([a-z]{2})/i', $HTTP_USER_AGENT, $regs))
67 $this->lang = $regs[1];
71 $this->dom = ($this->mz || $this->safari || ($this->ie && $this->ver>=5) || ($this->opera && $this->ver>=7));
72 $this->pngalpha = $this->mz || $this->safari || ($this->ie && $this->ver>=5.5) ||
73 ($this->ie && $this->ver>=5 && $this->mac) || ($this->opera && $this->ver>=7) ? true : false;