Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

rcube_browser.php 3.3KB

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