Ignore:
Timestamp:
Sep 8, 2010 5:40:39 AM (3 years ago)
Author:
alec
Message:
  • Small performance improvements
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/roundcubemail/program/include/rcube_browser.php

    r3942 r3946  
    3131    function __construct() 
    3232    { 
    33         $HTTP_USER_AGENT = $_SERVER['HTTP_USER_AGENT']; 
     33        $HTTP_USER_AGENT = strtolower($_SERVER['HTTP_USER_AGENT']); 
    3434 
    3535        $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'); 
     36        $this->win = strstr($HTTP_USER_AGENT, 'win'); 
     37        $this->mac = strstr($HTTP_USER_AGENT, 'mac'); 
     38        $this->linux = strstr($HTTP_USER_AGENT, 'linux'); 
     39        $this->unix  = strstr($HTTP_USER_AGENT, 'unix'); 
    4040 
    41         $this->opera = stristr($HTTP_USER_AGENT, 'opera'); 
    42         $this->ns4 = stristr($HTTP_USER_AGENT, 'mozilla/4') && !stristr($HTTP_USER_AGENT, 'msie'); 
    43         $this->ns  = ($this->ns4 || stristr($HTTP_USER_AGENT, 'netscape')); 
    44         $this->ie  = stristr($HTTP_USER_AGENT, 'compatible; msie') && !$this->opera; 
    45         $this->mz  = stristr($HTTP_USER_AGENT, 'mozilla/5'); 
    46         $this->chrome = stristr($HTTP_USER_AGENT, 'chrome'); 
    47         $this->khtml = stristr($HTTP_USER_AGENT, 'khtml'); 
    48         $this->safari = !$this->chrome && ($this->khtml || stristr($HTTP_USER_AGENT, 'safari')); 
     41        $this->opera = strstr($HTTP_USER_AGENT, 'opera'); 
     42        $this->ns4 = strstr($HTTP_USER_AGENT, 'mozilla/4') && !strstr($HTTP_USER_AGENT, 'msie'); 
     43        $this->ns  = ($this->ns4 || strstr($HTTP_USER_AGENT, 'netscape')); 
     44        $this->ie  = !$this->opera && strstr($HTTP_USER_AGENT, 'compatible; msie'); 
     45        $this->mz  = strstr($HTTP_USER_AGENT, 'mozilla/5'); 
     46        $this->chrome = strstr($HTTP_USER_AGENT, 'chrome'); 
     47        $this->khtml = strstr($HTTP_USER_AGENT, 'khtml'); 
     48        $this->safari = !$this->chrome && ($this->khtml || strstr($HTTP_USER_AGENT, 'safari')); 
    4949 
    5050        if ($this->ns || $this->chrome) { 
    51             $test = preg_match('/(mozilla|chrome)\/([0-9.]+)/i', $HTTP_USER_AGENT, $regs); 
     51            $test = preg_match('/(mozilla|chrome)\/([0-9.]+)/', $HTTP_USER_AGENT, $regs); 
    5252            $this->ver = $test ? (float)$regs[2] : 0; 
    5353        } 
     
    5757        } 
    5858        else if ($this->ie || $this->opera) { 
    59             $test = preg_match('/(msie|opera) ([0-9.]+)/i', $HTTP_USER_AGENT, $regs); 
     59            $test = preg_match('/(msie|opera) ([0-9.]+)/', $HTTP_USER_AGENT, $regs); 
    6060            $this->ver = $test ? (float)$regs[2] : 0; 
    6161        } 
    6262 
    63         if (preg_match('/ ([a-z]{2})-([a-z]{2})/i', $HTTP_USER_AGENT, $regs)) 
     63        if (preg_match('/ ([a-z]{2})-([a-z]{2})/', $HTTP_USER_AGENT, $regs)) 
    6464            $this->lang =  $regs[1]; 
    6565        else 
Note: See TracChangeset for help on using the changeset viewer.