Mercurial > hg > rc2
annotate program/lib/Roundcube/rcube_browser.php @ 17:dd5ed6ef69c9
Slowly cleaning up more php8 Warnings/deprecations
| author | Charlie Root |
|---|---|
| date | Mon, 06 Oct 2025 12:20:32 -0400 |
| parents | 85a746e95663 |
| children |
| rev | line source |
|---|---|
| 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 | |
|
15
85a746e95663
slowly working through deprecations/warnings from 8.3
Charlie Root
parents:
0
diff
changeset
|
26 { |
|
85a746e95663
slowly working through deprecations/warnings from 8.3
Charlie Root
parents:
0
diff
changeset
|
27 // |
|
85a746e95663
slowly working through deprecations/warnings from 8.3
Charlie Root
parents:
0
diff
changeset
|
28 public $ver; |
|
85a746e95663
slowly working through deprecations/warnings from 8.3
Charlie Root
parents:
0
diff
changeset
|
29 public $win; |
|
85a746e95663
slowly working through deprecations/warnings from 8.3
Charlie Root
parents:
0
diff
changeset
|
30 public $mac; |
|
85a746e95663
slowly working through deprecations/warnings from 8.3
Charlie Root
parents:
0
diff
changeset
|
31 public $linux; |
|
85a746e95663
slowly working through deprecations/warnings from 8.3
Charlie Root
parents:
0
diff
changeset
|
32 public $unix; |
|
85a746e95663
slowly working through deprecations/warnings from 8.3
Charlie Root
parents:
0
diff
changeset
|
33 public $webkit; |
|
85a746e95663
slowly working through deprecations/warnings from 8.3
Charlie Root
parents:
0
diff
changeset
|
34 public $opera; |
|
85a746e95663
slowly working through deprecations/warnings from 8.3
Charlie Root
parents:
0
diff
changeset
|
35 public $ns; |
|
85a746e95663
slowly working through deprecations/warnings from 8.3
Charlie Root
parents:
0
diff
changeset
|
36 public $chrome; |
|
85a746e95663
slowly working through deprecations/warnings from 8.3
Charlie Root
parents:
0
diff
changeset
|
37 public $ie; |
|
85a746e95663
slowly working through deprecations/warnings from 8.3
Charlie Root
parents:
0
diff
changeset
|
38 public $safari; |
|
85a746e95663
slowly working through deprecations/warnings from 8.3
Charlie Root
parents:
0
diff
changeset
|
39 public $mz; |
|
85a746e95663
slowly working through deprecations/warnings from 8.3
Charlie Root
parents:
0
diff
changeset
|
40 public $lang; |
|
85a746e95663
slowly working through deprecations/warnings from 8.3
Charlie Root
parents:
0
diff
changeset
|
41 public $dom; |
|
85a746e95663
slowly working through deprecations/warnings from 8.3
Charlie Root
parents:
0
diff
changeset
|
42 public $pngalpha; |
|
85a746e95663
slowly working through deprecations/warnings from 8.3
Charlie Root
parents:
0
diff
changeset
|
43 public $imgdata; |
|
85a746e95663
slowly working through deprecations/warnings from 8.3
Charlie Root
parents:
0
diff
changeset
|
44 |
| 0 | 45 function __construct() |
| 46 { | |
| 47 $HTTP_USER_AGENT = strtolower($_SERVER['HTTP_USER_AGENT']); | |
| 48 | |
| 49 $this->ver = 0; | |
| 50 $this->win = strpos($HTTP_USER_AGENT, 'win') != false; | |
| 51 $this->mac = strpos($HTTP_USER_AGENT, 'mac') != false; | |
| 52 $this->linux = strpos($HTTP_USER_AGENT, 'linux') != false; | |
| 53 $this->unix = strpos($HTTP_USER_AGENT, 'unix') != false; | |
| 54 | |
| 55 $this->webkit = strpos($HTTP_USER_AGENT, 'applewebkit') !== false; | |
| 56 $this->opera = strpos($HTTP_USER_AGENT, 'opera') !== false || ($this->webkit && strpos($HTTP_USER_AGENT, 'opr/') !== false); | |
| 57 $this->ns = strpos($HTTP_USER_AGENT, 'netscape') !== false; | |
| 58 $this->chrome = !$this->opera && strpos($HTTP_USER_AGENT, 'chrome') !== false; | |
| 59 $this->ie = !$this->opera && (strpos($HTTP_USER_AGENT, 'compatible; msie') !== false || strpos($HTTP_USER_AGENT, 'trident/') !== false); | |
| 60 $this->safari = !$this->opera && !$this->chrome && ($this->webkit || strpos($HTTP_USER_AGENT, 'safari') !== false); | |
| 61 $this->mz = !$this->ie && !$this->safari && !$this->chrome && !$this->ns && !$this->opera && strpos($HTTP_USER_AGENT, 'mozilla') !== false; | |
| 62 | |
| 63 if ($this->opera) { | |
| 64 if (preg_match('/(opera|opr)\/([0-9.]+)/', $HTTP_USER_AGENT, $regs)) { | |
| 65 $this->ver = (float) $regs[2]; | |
| 66 } | |
| 67 } | |
| 68 else if (preg_match('/(chrome|msie|version|khtml)(\s*|\/)([0-9.]+)/', $HTTP_USER_AGENT, $regs)) { | |
| 69 $this->ver = (float) $regs[3]; | |
| 70 } | |
| 71 else if (preg_match('/rv:([0-9.]+)/', $HTTP_USER_AGENT, $regs)) { | |
| 72 $this->ver = (float) $regs[1]; | |
| 73 } | |
| 74 | |
| 75 if (preg_match('/ ([a-z]{2})-([a-z]{2})/', $HTTP_USER_AGENT, $regs)) { | |
| 76 $this->lang = $regs[1]; | |
| 77 } | |
| 78 else { | |
| 79 $this->lang = 'en'; | |
| 80 } | |
| 81 | |
| 82 $this->dom = $this->mz || $this->safari || ($this->ie && $this->ver>=5) || ($this->opera && $this->ver>=7); | |
| 83 $this->pngalpha = $this->mz || $this->safari || ($this->ie && $this->ver>=5.5) || | |
| 84 ($this->ie && $this->ver>=5 && $this->mac) || ($this->opera && $this->ver>=7); | |
| 85 $this->imgdata = !$this->ie; | |
| 86 } | |
| 87 } |
