0
|
1 <?php
|
|
2
|
|
3 /**
|
|
4 +-----------------------------------------------------------------------+
|
|
5 | This file is part of the Roundcube Webmail client |
|
|
6 | Copyright (C) 2007-2015, The Roundcube Dev Team |
|
|
7 | |
|
|
8 | Licensed under the GNU General Public License version 3 or |
|
|
9 | any later version with exceptions for skins & plugins. |
|
|
10 | See the README file for a full license statement. |
|
|
11 | |
|
|
12 | PURPOSE: |
|
|
13 | Class representing the client browser's properties |
|
|
14 +-----------------------------------------------------------------------+
|
|
15 | Author: Thomas Bruederli <roundcube@gmail.com> |
|
|
16 +-----------------------------------------------------------------------+
|
|
17 */
|
|
18
|
|
19 /**
|
|
20 * Provide details about the client's browser based on the User-Agent header
|
|
21 *
|
|
22 * @package Framework
|
|
23 * @subpackage Utils
|
|
24 */
|
|
25 class rcube_browser
|
|
26 {
|
|
27 function __construct()
|
|
28 {
|
|
29 $HTTP_USER_AGENT = strtolower($_SERVER['HTTP_USER_AGENT']);
|
|
30
|
|
31 $this->ver = 0;
|
|
32 $this->win = strpos($HTTP_USER_AGENT, 'win') != false;
|
|
33 $this->mac = strpos($HTTP_USER_AGENT, 'mac') != false;
|
|
34 $this->linux = strpos($HTTP_USER_AGENT, 'linux') != false;
|
|
35 $this->unix = strpos($HTTP_USER_AGENT, 'unix') != false;
|
|
36
|
|
37 $this->webkit = strpos($HTTP_USER_AGENT, 'applewebkit') !== false;
|
|
38 $this->opera = strpos($HTTP_USER_AGENT, 'opera') !== false || ($this->webkit && strpos($HTTP_USER_AGENT, 'opr/') !== false);
|
|
39 $this->ns = strpos($HTTP_USER_AGENT, 'netscape') !== false;
|
|
40 $this->chrome = !$this->opera && strpos($HTTP_USER_AGENT, 'chrome') !== false;
|
|
41 $this->ie = !$this->opera && (strpos($HTTP_USER_AGENT, 'compatible; msie') !== false || strpos($HTTP_USER_AGENT, 'trident/') !== false);
|
|
42 $this->safari = !$this->opera && !$this->chrome && ($this->webkit || strpos($HTTP_USER_AGENT, 'safari') !== false);
|
|
43 $this->mz = !$this->ie && !$this->safari && !$this->chrome && !$this->ns && !$this->opera && strpos($HTTP_USER_AGENT, 'mozilla') !== false;
|
|
44
|
|
45 if ($this->opera) {
|
|
46 if (preg_match('/(opera|opr)\/([0-9.]+)/', $HTTP_USER_AGENT, $regs)) {
|
|
47 $this->ver = (float) $regs[2];
|
|
48 }
|
|
49 }
|
|
50 else if (preg_match('/(chrome|msie|version|khtml)(\s*|\/)([0-9.]+)/', $HTTP_USER_AGENT, $regs)) {
|
|
51 $this->ver = (float) $regs[3];
|
|
52 }
|
|
53 else if (preg_match('/rv:([0-9.]+)/', $HTTP_USER_AGENT, $regs)) {
|
|
54 $this->ver = (float) $regs[1];
|
|
55 }
|
|
56
|
|
57 if (preg_match('/ ([a-z]{2})-([a-z]{2})/', $HTTP_USER_AGENT, $regs)) {
|
|
58 $this->lang = $regs[1];
|
|
59 }
|
|
60 else {
|
|
61 $this->lang = 'en';
|
|
62 }
|
|
63
|
|
64 $this->dom = $this->mz || $this->safari || ($this->ie && $this->ver>=5) || ($this->opera && $this->ver>=7);
|
|
65 $this->pngalpha = $this->mz || $this->safari || ($this->ie && $this->ver>=5.5) ||
|
|
66 ($this->ie && $this->ver>=5 && $this->mac) || ($this->opera && $this->ver>=7);
|
|
67 $this->imgdata = !$this->ie;
|
|
68 }
|
|
69 }
|