source: subversion/trunk/roundcubemail/program/include/rcube_browser.php @ 1291

Last change on this file since 1291 was 1291, checked in by thomasb, 5 years ago

Changed codebase to PHP5 with autoloader + added some new classes from the devel-vnext branch

File size: 3.0 KB
Line 
1<?php
2
3/*
4 +-----------------------------------------------------------------------+
5 | program/include/rcube_browser.php                                     |
6 |                                                                       |
7 | This file is part of the RoundCube Webmail client                     |
8 | Copyright (C) 2007-2008, RoundCube Dev. - Switzerland                 |
9 | Licensed under the GNU GPL                                            |
10 |                                                                       |
11 | PURPOSE:                                                              |
12 |   Class representing the client browser's properties                  |
13 |                                                                       |
14 +-----------------------------------------------------------------------+
15 | Author: Thomas Bruederli <roundcube@gmail.com>                        |
16 +-----------------------------------------------------------------------+
17
18 $Id: rcube_browser.php 328 2006-08-30 17:41:21Z thomasb $
19
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 */
29class 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
41        $this->ns4 = stristr($HTTP_USER_AGENT, 'mozilla/4') && !stristr($HTTP_USER_AGENT, 'msie');
42        $this->ns  = ($this->ns4 || stristr($HTTP_USER_AGENT, 'netscape'));
43        $this->ie  = stristr($HTTP_USER_AGENT, 'msie');
44        $this->mz  = stristr($HTTP_USER_AGENT, 'mozilla/5');
45        $this->opera = stristr($HTTP_USER_AGENT, 'opera');
46        $this->safari = stristr($HTTP_USER_AGENT, 'safari');
47
48        if ($this->ns) {
49            $test = eregi("mozilla\/([0-9\.]+)", $HTTP_USER_AGENT, $regs);
50            $this->ver = $test ? (float)$regs[1] : 0;
51        }
52        if ($this->mz) {
53            $test = ereg("rv:([0-9\.]+)", $HTTP_USER_AGENT, $regs);
54            $this->ver = $test ? (float)$regs[1] : 0;
55        }
56        if($this->ie) {
57            $test = eregi("msie ([0-9\.]+)", $HTTP_USER_AGENT, $regs);
58            $this->ver = $test ? (float)$regs[1] : 0;
59        }
60        if ($this->opera) {
61            $test = eregi("opera ([0-9\.]+)", $HTTP_USER_AGENT, $regs);
62            $this->ver = $test ? (float)$regs[1] : 0;
63        }
64
65        if (eregi(" ([a-z]{2})-([a-z]{2})", $HTTP_USER_AGENT, $regs))
66            $this->lang =  $regs[1];
67        else
68            $this->lang =  'en';
69
70        $this->dom = ($this->mz || $this->safari || ($this->ie && $this->ver>=5) || ($this->opera && $this->ver>=7));
71        $this->pngalpha = $this->mz || $this->safari || ($this->ie && $this->ver>=5.5) ||
72            ($this->ie && $this->ver>=5 && $this->mac) || ($this->opera && $this->ver>=7) ? true : false;
73    }
74  }
75
Note: See TracBrowser for help on using the repository browser.