source: github/program/include/rcube_browser.php @ 7fe3811

HEADcourier-fixdev-browser-capabilitiespdorelease-0.8
Last change on this file since 7fe3811 was 7fe3811, checked in by thomascube <thomas@…>, 17 months ago

Changed license to GNU GPLv3+ with exceptions for skins and plugins

  • Property mode set to 100644
File size: 3.4 KB
RevLine 
[47124c22]1<?php
2
3/*
4 +-----------------------------------------------------------------------+
5 | program/include/rcube_browser.php                                     |
6 |                                                                       |
[e019f2d]7 | This file is part of the Roundcube Webmail client                     |
[f5e7b353]8 | Copyright (C) 2007-2009, The Roundcube Dev Team                       |
[7fe3811]9 |                                                                       |
10 | Licensed under the GNU General Public License version 3 or            |
11 | any later version with exceptions for skins & plugins.                |
12 | See the README file for a full license statement.                     |
[47124c22]13 |                                                                       |
14 | PURPOSE:                                                              |
15 |   Class representing the client browser's properties                  |
16 |                                                                       |
17 +-----------------------------------------------------------------------+
18 | Author: Thomas Bruederli <roundcube@gmail.com>                        |
19 +-----------------------------------------------------------------------+
20
[638fb8a]21 $Id$
[47124c22]22
23*/
24
25/**
26 * rcube_browser
27 *
28 * Provide details about the client's browser based on the User-Agent header
29 *
30 * @package Core
31 */
32class rcube_browser
33{
34    function __construct()
35    {
[2aa2b33]36        $HTTP_USER_AGENT = strtolower($_SERVER['HTTP_USER_AGENT']);
[47124c22]37
38        $this->ver = 0;
[6e0fded]39        $this->win = strpos($HTTP_USER_AGENT, 'win') != false;
40        $this->mac = strpos($HTTP_USER_AGENT, 'mac') != false;
41        $this->linux = strpos($HTTP_USER_AGENT, 'linux') != false;
42        $this->unix  = strpos($HTTP_USER_AGENT, 'unix') != false;
[47124c22]43
[6e0fded]44        $this->opera = strpos($HTTP_USER_AGENT, 'opera') !== false;
45        $this->ns4 = strpos($HTTP_USER_AGENT, 'mozilla/4') !== false && strpos($HTTP_USER_AGENT, 'msie') === false;
46        $this->ns  = ($this->ns4 || strpos($HTTP_USER_AGENT, 'netscape') !== false);
47        $this->ie  = !$this->opera && strpos($HTTP_USER_AGENT, 'compatible; msie') !== false;
48        $this->mz  = !$this->ie && strpos($HTTP_USER_AGENT, 'mozilla/5') !== false;
49        $this->chrome = strpos($HTTP_USER_AGENT, 'chrome') !== false;
50        $this->khtml = strpos($HTTP_USER_AGENT, 'khtml') !== false;
51        $this->safari = !$this->chrome && ($this->khtml || strpos($HTTP_USER_AGENT, 'safari') !== false);
[47124c22]52
[c2e697f]53        if ($this->ns || $this->chrome) {
[2aa2b33]54            $test = preg_match('/(mozilla|chrome)\/([0-9.]+)/', $HTTP_USER_AGENT, $regs);
[c2e697f]55            $this->ver = $test ? (float)$regs[2] : 0;
[47124c22]56        }
[c2e697f]57        else if ($this->mz) {
[23a2eec]58            $test = preg_match('/rv:([0-9.]+)/', $HTTP_USER_AGENT, $regs);
[47124c22]59            $this->ver = $test ? (float)$regs[1] : 0;
60        }
[c2e697f]61        else if ($this->ie || $this->opera) {
[2aa2b33]62            $test = preg_match('/(msie|opera) ([0-9.]+)/', $HTTP_USER_AGENT, $regs);
[c2e697f]63            $this->ver = $test ? (float)$regs[2] : 0;
[47124c22]64        }
65
[2aa2b33]66        if (preg_match('/ ([a-z]{2})-([a-z]{2})/', $HTTP_USER_AGENT, $regs))
[47124c22]67            $this->lang =  $regs[1];
68        else
69            $this->lang =  'en';
70
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;
[0501b63]74        $this->imgdata = !$this->ie;
[47124c22]75    }
[b25dfd0]76}
[47124c22]77
Note: See TracBrowser for help on using the repository browser.