commit | author | age
|
47124c
|
1 |
<?php |
T |
2 |
|
|
3 |
/* |
|
4 |
+-----------------------------------------------------------------------+ |
|
5 |
| program/include/rcube_browser.php | |
|
6 |
| | |
|
7 |
| This file is part of the RoundCube Webmail client | |
cbbef3
|
8 |
| Copyright (C) 2007-2009, RoundCube Dev. - Switzerland | |
47124c
|
9 |
| Licensed under the GNU GPL | |
T |
10 |
| | |
|
11 |
| PURPOSE: | |
|
12 |
| Class representing the client browser's properties | |
|
13 |
| | |
|
14 |
+-----------------------------------------------------------------------+ |
|
15 |
| Author: Thomas Bruederli <roundcube@gmail.com> | |
|
16 |
+-----------------------------------------------------------------------+ |
|
17 |
|
638fb8
|
18 |
$Id$ |
47124c
|
19 |
|
T |
20 |
*/ |
|
21 |
|
|
22 |
/** |
|
23 |
* rcube_browser |
|
24 |
* |
|
25 |
* Provide details about the client's browser based on the User-Agent header |
|
26 |
* |
|
27 |
* @package Core |
|
28 |
*/ |
|
29 |
class rcube_browser |
|
30 |
{ |
|
31 |
function __construct() |
|
32 |
{ |
|
33 |
$HTTP_USER_AGENT = $_SERVER['HTTP_USER_AGENT']; |
|
34 |
|
|
35 |
$this->ver = 0; |
|
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'); |
|
40 |
|
0ced2b
|
41 |
$this->opera = stristr($HTTP_USER_AGENT, 'opera'); |
47124c
|
42 |
$this->ns4 = stristr($HTTP_USER_AGENT, 'mozilla/4') && !stristr($HTTP_USER_AGENT, 'msie'); |
T |
43 |
$this->ns = ($this->ns4 || stristr($HTTP_USER_AGENT, 'netscape')); |
0ced2b
|
44 |
$this->ie = stristr($HTTP_USER_AGENT, 'compatible; msie') && !$this->opera; |
47124c
|
45 |
$this->mz = stristr($HTTP_USER_AGENT, 'mozilla/5'); |
c2e697
|
46 |
$this->chrome = stristr($HTTP_USER_AGENT, 'chrome'); |
a3f149
|
47 |
$this->khtml = stristr($HTTP_USER_AGENT, 'khtml'); |
T |
48 |
$this->safari = ($this->khtml || stristr($HTTP_USER_AGENT, 'safari')); |
47124c
|
49 |
|
c2e697
|
50 |
if ($this->ns || $this->chrome) { |
A |
51 |
$test = preg_match('/(mozilla|chrome)\/([0-9.]+)/i', $HTTP_USER_AGENT, $regs); |
|
52 |
$this->ver = $test ? (float)$regs[2] : 0; |
47124c
|
53 |
} |
c2e697
|
54 |
else if ($this->mz) { |
23a2ee
|
55 |
$test = preg_match('/rv:([0-9.]+)/', $HTTP_USER_AGENT, $regs); |
47124c
|
56 |
$this->ver = $test ? (float)$regs[1] : 0; |
T |
57 |
} |
c2e697
|
58 |
else if ($this->ie || $this->opera) { |
A |
59 |
$test = preg_match('/(msie|opera) ([0-9.]+)/i', $HTTP_USER_AGENT, $regs); |
|
60 |
$this->ver = $test ? (float)$regs[2] : 0; |
47124c
|
61 |
} |
T |
62 |
|
23a2ee
|
63 |
if (preg_match('/ ([a-z]{2})-([a-z]{2})/i', $HTTP_USER_AGENT, $regs)) |
47124c
|
64 |
$this->lang = $regs[1]; |
T |
65 |
else |
|
66 |
$this->lang = 'en'; |
|
67 |
|
|
68 |
$this->dom = ($this->mz || $this->safari || ($this->ie && $this->ver>=5) || ($this->opera && $this->ver>=7)); |
|
69 |
$this->pngalpha = $this->mz || $this->safari || ($this->ie && $this->ver>=5.5) || |
|
70 |
($this->ie && $this->ver>=5 && $this->mac) || ($this->opera && $this->ver>=7) ? true : false; |
|
71 |
} |
|
72 |
} |
|
73 |
|