Changeset 5024

Show
Ignore:
Timestamp:
03/11/07 01:19:16 (1 year ago)
Author:
ryan
Message:

vars.php cleanups and speedups from rob1n. fixes #3956

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/wp-includes/vars.php

    r4995 r5024  
    1414 
    1515// Simple browser detection 
    16 // We should probably be doing true/false instead of 1/0 here ~ Mark 
    17 $is_lynx = 0; $is_gecko = 0; $is_winIE = 0; $is_macIE = 0; $is_opera = 0; $is_NS4 = 0; 
     16$is_lynx = $is_gecko = $is_winIE = $is_macIE = $is_opera = $is_NS4 = false; 
    1817 
    19 if ( preg_match('/Lynx/', $_SERVER['HTTP_USER_AGENT']) ) 
    20     $is_lynx = 1; 
    21 elseif ( preg_match('/Gecko/', $_SERVER['HTTP_USER_AGENT']) ) 
    22     $is_gecko = 1; 
    23 elseif ( preg_match('/MSIE/', $_SERVER['HTTP_USER_AGENT']) && preg_match('/Win/', $_SERVER['HTTP_USER_AGENT']) ) 
    24     $is_winIE = 1; 
    25 elseif ( preg_match('/MSIE/', $_SERVER['HTTP_USER_AGENT']) && preg_match('/Mac/', $_SERVER['HTTP_USER_AGENT']) ) 
    26     $is_macIE = 1; 
    27 elseif ( preg_match('/Opera/', $_SERVER['HTTP_USER_AGENT']) ) 
    28     $is_opera = 1; 
    29 elseif ( preg_match('/Nav/', $_SERVER['HTTP_USER_AGENT']) || preg_match('/Mozilla\/4\./', $_SERVER['HTTP_USER_AGENT']) ) 
    30     $is_NS4 = 1; 
     18if (strpos($_SERVER['HTTP_USER_AGENT'], 'Lynx') !== false) { 
     19    $is_lynx = true; 
     20} elseif (strpos($_SERVER['HTTP_USER_AGENT'], 'Gecko') !== false) { 
     21    $is_gecko = true; 
     22} elseif (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== false && strpos($_SERVER['HTTP_USER_AGENT'], 'Win')) { 
     23    $is_winIE = true; 
     24} elseif (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== false && strpos($_SERVER['HTTP_USER_AGENT'], 'Mac') !== false) { 
     25    $is_macIE = true; 
     26} elseif (strpos($_SERVER['HTTP_USER_AGENT'], 'Opera') !== false) { 
     27    $is_opera = true; 
     28} elseif (strpos($_SERVER['HTTP_USER_AGENT'], 'Nav') !== false && strpos($_SERVER['HTTP_USER_AGENT'], 'Mozilla/4.') !== false) { 
     29    $is_NS4 = true; 
     30
    3131 
    3232$is_IE = ( $is_macIE || $is_winIE ); 
    3333 
    3434// Server detection 
    35 $is_apache = ((strpos($_SERVER['SERVER_SOFTWARE'], 'Apache') !== false) || (strpos($_SERVER['SERVER_SOFTWARE'], 'LiteSpeed') !== false)) ? 1 : 0
    36 $is_IIS = (strpos($_SERVER['SERVER_SOFTWARE'], 'Microsoft-IIS') !== false) ? 1 : 0
     35$is_apache = ((strpos($_SERVER['SERVER_SOFTWARE'], 'Apache') !== false) || (strpos($_SERVER['SERVER_SOFTWARE'], 'LiteSpeed') !== false)) ? true : false
     36$is_IIS = (strpos($_SERVER['SERVER_SOFTWARE'], 'Microsoft-IIS') !== false) ? true : false
    3737 
    3838// if the config file does not provide the smilies array, let's define it here