WordPress.org

Make WordPress Core

Ticket #18381: 18381.diff

File 18381.diff, 19.6 KB (added by aaroncampbell, 4 years ago)
  • browse-happy/1.0/tests.php

     
    11<?php 
    22 
    3 include dirname( __FILE__ ) . '/index.php'; 
     3include './index.php'; 
    44 
    55$tests = array ( 
    6   'Mozilla/4.0 (Windows; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 2.0.50727)' => 'Windows Internet Explorer 6.0', 
    7   'Mozilla/4.0 (MSIE 6.0; Windows NT 5.1)' => 'Windows Internet Explorer 6.0', 
    8   'Mozilla/4.0 (MSIE 6.0; Windows NT 5.0)' => 'Windows Internet Explorer 6.0', 
    9   'Mozilla/4.0 (compatible;MSIE 6.0;Windows 98;Q312461)' => 'Windows Internet Explorer 6.0', 
    10   'Mozilla/4.0 (Compatible; Windows NT 5.1; MSIE 6.0) (compatible; MSIE 6.0; Windows NT 5.1; .NET CLR 1.1.4322; .NET CLR 2.0.50727)' => 'Windows Internet Explorer 6.0', 
    11   'Mozilla/4.0 (compatible; U; MSIE 6.0; Windows NT 5.1)' => 'Windows Internet Explorer 6.0', 
    12   'Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1) ; .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729; .NET4.0C; .NET4.0E)' => 'Windows Internet Explorer 7.0', 
    13   'Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; .NET4.0C; .NET4.0E; Tablet PC 2.0)' => 'Windows Internet Explorer 8.0', 
    14   'Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; Trident/4.0; Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1) ; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; .NET4.0C; InfoPath.3; Tablet PC 2.0)' => 'Windows Internet Explorer 8.0', 
    15   'Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0)' => 'Windows Internet Explorer 9.0', 
    16   'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.9.1.5) Gecko/20091102 Firefox/3.5.5 (.NET CLR 3.5.21022)' => 'Windows Firefox 3.5.5', 
    17   'Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2.15) Gecko/20110303 Firefox/3.6.15 FirePHP/0.5' => 'Windows Firefox 3.6.15', 
    18   'Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US) AppleWebKit/534.13 (KHTML, like Gecko) Chrome/9.0.597.98 Safari/534.13' => 'Windows Chrome 9.0.597.98', 
    19   'Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US) AppleWebKit/534.16 (KHTML, like Gecko) Chrome/10.0.648.114 Safari/534.16' => 'Windows Chrome 10.0.648.114', 
    20   'Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US) AppleWebKit/534.7 (KHTML, like Gecko) Chrome/7.0.517.41 Safari/534.7' => 'Windows Chrome 7.0.517.41', 
    21   'Opera/9.80 (Windows NT 6.0; U; en) Presto/2.8.99 Version/11.10' => 'Windows Opera 11.10', 
    22   'Opera/9.80 (Windows NT 5.1; U; cs) Presto/2.7.62 Version/11.01' => 'Windows Opera 11.01', 
    23   'Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2.13) Gecko/20101213 Opera/9.80 (Windows NT 6.1; U; zh-tw) Presto/2.7.62 Version/11.01' => 'Windows Opera 11.01', 
    24   'Mozilla/5.0 (Windows NT 6.1; U; nl; rv:1.9.1.6) Gecko/20091201 Firefox/3.5.6 Opera 11.01' => 'Windows Opera 11.01', 
    25   'Mozilla/5.0 (Windows NT 6.1; U; de; rv:1.9.1.6) Gecko/20091201 Firefox/3.5.6 Opera 11.01' => 'Windows Opera 11.01', 
    26   'Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; de) Opera 11.01' => 'Windows Opera 11.01', 
    27   'Mozilla/5.0 (Windows; U; Windows NT 6.1; tr-TR) AppleWebKit/533.20.25 (KHTML, like Gecko) Version/5.0.4 Safari/533.20.27' => 'Windows Safari 5.0.4', 
    28   'Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.6; en-US; rv:1.9.2.3) Gecko/20100401 Firefox/3.6.3' => 'Macintosh Firefox 3.6.3', 
    29   'Mozilla/5.0 (Macintosh; U; PPC Mac OS X 10_4_11; en) AppleWebKit/531.22.7 (KHTML, like Gecko) Version/4.0.5 Safari/531.22.7' => 'Macintosh Safari 4.0.5', 
    30   'Mozilla/5.0 (Macintosh; U; PPC Mac OS X 10_4_11; en) AppleWebKit/533.18.1 (KHTML, like Gecko) Version/4.1.2 Safari/533.18.5' => 'Macintosh Safari 4.1.2', 
    31   'Mozilla/5.0 (Macintosh; U; PPC Mac OS X; en) AppleWebKit/312.9 (KHTML, like Gecko) Safari/312.6' => 'Macintosh Safari 312.6', 
    32   'Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_3; en-us) AppleWebKit/533.16 (KHTML, like Gecko) Version/5.0 Safari/533.16' => 'Macintosh Safari 5.0', 
    33   'Mozilla/5.0 (Macintosh; U; PPC Mac OS X 10.5; it; rv:1.9.0.19) Gecko/2010111021 Camino/2.0.6 (MultiLang) (like Firefox/3.0.19)' => 'Macintosh Camino 2.0.6', 
    34   'Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.6; en; rv:1.9.0.18) Gecko/2010021619 Camino/2.0.2 (like Firefox/3.0.18)' => 'Macintosh Camino 2.0.2', 
    35   'Mozilla/5.0 (Macintosh; U; PPC Mac OS X Mach-O; it; rv:1.8.1.21) Gecko/20090327 Camino/1.6.7 (MultiLang) (like Firefox/2.0.0.21pre)' => 'Macintosh Camino 1.6.7', 
    36   'Mozilla/5.0 (Macintosh; U; Intel Mac OS X; en; rv:1.8.1.11) Gecko/20071128 Camino/1.5.4' => 'Macintosh Camino 1.5.4', 
    37   'Mozilla/5.0 (Linux; U; Android 2.2; en-us; SGH-T959 Build/FROYO) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1' => 'Linux Mobile Safari 4.0', 
    38   'Mozilla/5.0 (iPad; U; CPU iPhone OS 3_2 like Mac OS X; en-us) AppleWebKit/531.21.10 (KHTML, like Gecko) Version/4.0.4 Mobile/7B314 Safari/531.21.10' => 'iPad Safari 4.0.4', 
    39   'Mozilla/5.0 (iPad; U; CPU OS 3_2 like Mac OS X; en-us) AppleWebKit/531.21.10 (KHTML, like Gecko) Version/4.0.4 Mobile/7B334b Safari/531.21.10' => 'iPad Safari 4.0.4', 
    40   'Mozilla/5.0 (iPhone; U; CPU iPhone OS 4_2_6 like Mac OS X; en-us) AppleWebKit/533.17.9 (KHTML, like Gecko) Version/5.0.2 Mobile/8E200 Safari/6533.18.5' => 'iPhone Safari 5.0.2', 
    41   'Mozilla/5.0 (iPhone; U; CPU like Mac OS X; en) AppleWebKit/420+ (KHTML, like Gecko) Version/3.0 Mobile/1C25 Safari/419.3' => 'iPhone Safari 3.0', 
    42   'Mozilla/4.0 (compatible; MSIE 7.0; Windows Phone OS 7.0; Trident/3.1; IEMobile/7.0) Asus;Galaxy6' => 'Windows Phone OS Internet Explorer Mobile 7.0', 
    43   'Mozilla/4.0 (compatible; MSIE 7.0; Windows Phone OS 7.0; Trident/3.1; IEMobile/7.0; LG; GW910)' => 'Windows Phone OS Internet Explorer Mobile 7.0', 
    44   'Mozilla/4.0 (compatible; MSIE 7.0; Windows Phone OS 7.0; Trident/3.1; IEMobile/7.0) LG;LG-E900h)' => 'Windows Phone OS Internet Explorer Mobile 7.0', 
    45   'Mozilla/4.0 (compatible; Linux 2.6.10) NetFront/3.3 Kindle/1.0 (screen 600x800)' => 'Kindle Kindle 1.0', 
    46   'Mozilla/5.0 (Linux; U; en-US) AppleWebKit/528.5+ (KHTML, like Gecko, Safari/528.5+) Version/4.0 Kindle/3.0 (screen 600x800; rotate)' => 'Kindle Kindle 4.0', 
    47   'Mozilla/5.0 (Linux; U; en-US) AppleWebKit/528.5+ (KHTML, like Gecko, Safari/538.5+) Version/4.0 Kindle/3.0 (screen 600x800; rotate)' => 'Kindle Kindle 4.0', 
    48   'Mozilla/5.0 (PlayBook; U; RIM Tablet OS 1.0.0; en-US) AppleWebKit/534.8 (KHTML, like Gecko) Version/0.0.1 Safari/534.8' => 'PlayBook PlayBook 0.0.1', 
    49   'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_6_7) AppleWebKit/534.24 (KHTML, like Gecko) RockMelt/0.9.58.494 Chrome/11.0.696.71 Safari/534.24' => 'Macintosh RockMelt 0.9.58.494', 
    50   'Mozilla/5.0 (Linux; U; Android 3.1; en-us; GT-P7510 Build/HMJ37) AppleWebKit/534.13 (KHTML, like Gecko) Version/4.0 Safari/534.13' => 'Android Safari 4.0', 
     6  'Mozilla/4.0 (Windows; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 2.0.50727)' => 'Internet Explorer 6.0', 
     7  'Mozilla/4.0 (MSIE 6.0; Windows NT 5.1)' => 'Internet Explorer 6.0', 
     8  'Mozilla/4.0 (MSIE 6.0; Windows NT 5.0)' => 'Internet Explorer 6.0', 
     9  'Mozilla/4.0 (compatible;MSIE 6.0;Windows 98;Q312461)' => 'Internet Explorer 6.0', 
     10  'Mozilla/4.0 (Compatible; Windows NT 5.1; MSIE 6.0) (compatible; MSIE 6.0; Windows NT 5.1; .NET CLR 1.1.4322; .NET CLR 2.0.50727)' => 'Internet Explorer 6.0', 
     11  'Mozilla/4.0 (compatible; U; MSIE 6.0; Windows NT 5.1)' => 'Internet Explorer 6.0', 
     12  'Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1) ; .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729; .NET4.0C; .NET4.0E)' => 'Internet Explorer 7.0', 
     13  'Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; .NET4.0C; .NET4.0E; Tablet PC 2.0)' => 'Internet Explorer 8.0', 
     14  'Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; Trident/4.0; Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1) ; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; .NET4.0C; InfoPath.3; Tablet PC 2.0)' => 'Internet Explorer 8.0', 
     15  'Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0)' => 'Internet Explorer 9.0', 
     16  'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.9.1.5) Gecko/20091102 Firefox/3.5.5 (.NET CLR 3.5.21022)' => 'Firefox 3.5.5', 
     17  'Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2.15) Gecko/20110303 Firefox/3.6.15 FirePHP/0.5' => 'Firefox 3.6.15', 
     18  'Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US) AppleWebKit/534.13 (KHTML, like Gecko) Chrome/9.0.597.98 Safari/534.13' => 'Chrome 9.0.597.98', 
     19  'Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US) AppleWebKit/534.16 (KHTML, like Gecko) Chrome/10.0.648.114 Safari/534.16' => 'Chrome 10.0.648.114', 
     20  'Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US) AppleWebKit/534.7 (KHTML, like Gecko) Chrome/7.0.517.41 Safari/534.7' => 'Chrome 7.0.517.41', 
     21  'Opera/9.80 (Windows NT 6.0; U; en) Presto/2.8.99 Version/11.10' => 'Opera 11.10', 
     22  'Opera/9.80 (Windows NT 5.1; U; cs) Presto/2.7.62 Version/11.01' => 'Opera 11.01', 
     23  'Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2.13) Gecko/20101213 Opera/9.80 (Windows NT 6.1; U; zh-tw) Presto/2.7.62 Version/11.01' => 'Opera 11.01', 
     24  'Mozilla/5.0 (Windows NT 6.1; U; nl; rv:1.9.1.6) Gecko/20091201 Firefox/3.5.6 Opera 11.01' => 'Opera 11.01', 
     25  'Mozilla/5.0 (Windows NT 6.1; U; de; rv:1.9.1.6) Gecko/20091201 Firefox/3.5.6 Opera 11.01' => 'Opera 11.01', 
     26  'Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; de) Opera 11.01' => 'Opera 11.01', 
     27  'Mozilla/5.0 (Windows; U; Windows NT 6.1; tr-TR) AppleWebKit/533.20.25 (KHTML, like Gecko) Version/5.0.4 Safari/533.20.27' => 'Safari 5.0.4', 
     28  'Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.6; en-US; rv:1.9.2.3) Gecko/20100401 Firefox/3.6.3' => 'Firefox 3.6.3', 
     29  'Mozilla/5.0 (Macintosh; U; PPC Mac OS X 10_4_11; en) AppleWebKit/531.22.7 (KHTML, like Gecko) Version/4.0.5 Safari/531.22.7' => 'Safari 4.0.5', 
     30  'Mozilla/5.0 (Macintosh; U; PPC Mac OS X 10_4_11; en) AppleWebKit/533.18.1 (KHTML, like Gecko) Version/4.1.2 Safari/533.18.5' => 'Safari 4.1.2', 
     31  'Mozilla/5.0 (Macintosh; U; PPC Mac OS X; en) AppleWebKit/312.9 (KHTML, like Gecko) Safari/312.6' => 'Safari', 
     32  'Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_3; en-us) AppleWebKit/533.16 (KHTML, like Gecko) Version/5.0 Safari/533.16' => 'Safari 5.0', 
     33  'Mozilla/5.0 (Windows; U; Windows NT 5.1; fr-FR) AppleWebKit/523.15 (KHTML, like Gecko) Version/3.0 Safari/523.15' => 'Safari 3.0', 
     34  'Mozilla/5.0 (Macintosh; U; PPC Mac OS X 10.5; it; rv:1.9.0.19) Gecko/2010111021 Camino/2.0.6 (MultiLang) (like Firefox/3.0.19)' => '', 
     35  'Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.6; en; rv:1.9.0.18) Gecko/2010021619 Camino/2.0.2 (like Firefox/3.0.18)' => '', 
     36  'Mozilla/5.0 (Macintosh; U; PPC Mac OS X Mach-O; it; rv:1.8.1.21) Gecko/20090327 Camino/1.6.7 (MultiLang) (like Firefox/2.0.0.21pre)' => '', 
     37  'Mozilla/5.0 (Macintosh; U; Intel Mac OS X; en; rv:1.8.1.11) Gecko/20071128 Camino/1.5.4' => '', 
     38  'Mozilla/5.0 (Linux; U; Android 2.2; en-us; SGH-T959 Build/FROYO) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1' => '', 
     39  'Mozilla/5.0 (iPad; U; CPU iPhone OS 3_2 like Mac OS X; en-us) AppleWebKit/531.21.10 (KHTML, like Gecko) Version/4.0.4 Mobile/7B314 Safari/531.21.10' => '', 
     40  'Mozilla/5.0 (iPad; U; CPU OS 3_2 like Mac OS X; en-us) AppleWebKit/531.21.10 (KHTML, like Gecko) Version/4.0.4 Mobile/7B334b Safari/531.21.10' => '', 
     41  'Mozilla/5.0 (iPhone; U; CPU iPhone OS 4_2_6 like Mac OS X; en-us) AppleWebKit/533.17.9 (KHTML, like Gecko) Version/5.0.2 Mobile/8E200 Safari/6533.18.5' => '', 
     42  'Mozilla/5.0 (iPhone; U; CPU like Mac OS X; en) AppleWebKit/420+ (KHTML, like Gecko) Version/3.0 Mobile/1C25 Safari/419.3' => '', 
     43  'Mozilla/4.0 (compatible; MSIE 7.0; Windows Phone OS 7.0; Trident/3.1; IEMobile/7.0) Asus;Galaxy6' => '', 
     44  'Mozilla/4.0 (compatible; MSIE 7.0; Windows Phone OS 7.0; Trident/3.1; IEMobile/7.0; LG; GW910)' => '', 
     45  'Mozilla/4.0 (compatible; MSIE 7.0; Windows Phone OS 7.0; Trident/3.1; IEMobile/7.0) LG;LG-E900h)' => '', 
     46  'Mozilla/4.0 (compatible; Linux 2.6.10) NetFront/3.3 Kindle/1.0 (screen 600x800)' => '', 
     47  'Mozilla/5.0 (Linux; U; en-US) AppleWebKit/528.5+ (KHTML, like Gecko, Safari/528.5+) Version/4.0 Kindle/3.0 (screen 600x800; rotate)' => '', 
     48  'Mozilla/5.0 (Linux; U; en-US) AppleWebKit/528.5+ (KHTML, like Gecko, Safari/538.5+) Version/4.0 Kindle/3.0 (screen 600x800; rotate)' => '', 
     49  'Mozilla/5.0 (PlayBook; U; RIM Tablet OS 1.0.0; en-US) AppleWebKit/534.8 (KHTML, like Gecko) Version/0.0.1 Safari/534.8' => '', 
     50  'Mozilla/5.0 (X11; Linux i686) AppleWebKit/534.30 (KHTML, like Gecko) Ubuntu/11.04 Chromium/12.0.742.112 Chrome/12.0.742.112 Safari/534.30' => '', 
     51  'Opera/9.80 (Windows Mobile; WCE; Opera Mobi/WMD-50255; U; en) Presto/2.4.13 Version/10.00' => '', 
     52  'Opera/9.80 (S60; SymbOS; Opera Mobi/275; U; en) Presto/2.4.13 Version/10.00' => '', 
     53  'Mozilla/5.0 (Windows; U; Windows NT 5.1; fi-FI) AppleWebKit/528.16 (KHTML, like Gecko) Version/4.0 Safari/528.16' => 'Safari 4.0', 
    5154); 
    5255 
    5356$pass = $fail = 0; 
     
    5558 
    5659foreach ( $tests as $ua => $assert ) { 
    5760        $parsed = parse_user_agent( $ua ); 
    58         $result = $parsed['platform'] . ' ' . $parsed['name'] . ' ' . $parsed['version']; 
     61        $result = array(); 
     62        if ( !empty( $parsed['name'] ) ) 
     63                $result[] = $parsed['name']; 
     64 
     65        if ( !empty( $parsed['version'] ) ) 
     66                $result[] = $parsed['version']; 
     67 
     68        $result = implode( ' ', $result ); 
    5969        if ( $assert === $result ) { 
    6070                ++$pass; 
    6171        } else { 
  • browse-happy/1.0/index.php

     
    1313* @return array containing platform, name, and version 
    1414*/ 
    1515function parse_user_agent( $user_agent ) { 
    16         $data = array(); 
     16        $data = array( 
     17                'platform'        => '', 
     18                'name'            => '', 
     19                'update_url'      => '', 
     20                'img_src'         => '', 
     21                'img_src_ssl'     => '', 
     22                'current_version' => '', 
     23                'version'         => '', 
     24                'upgrade'         => 0, 
     25                'insecure'        => 0 
     26        ); 
    1727 
    18     if ( preg_match('/^.+?(?P<platform>Android|iPhone|iPad|Windows|Linux|Macintosh|Windows Phone OS|RIM Tablet OS|PlayBook)(?: NT)*(?: [ix]?[0-9._]+)*(;|\))/im', $user_agent, $regs ) ) 
    19         $data['platform'] = $regs['platform']; 
     28        // Opera first because it seems to be the only non IE browser with MSIE in the UA 
     29        if ( false !== stripos( $user_agent, 'Opera' ) ) { 
     30                if ( false !== stripos( $user_agent, 'Opera Mobi' ) ) 
     31                        return $data; 
    2032 
    21     preg_match_all( '%(?P<name>Camino|Kindle|Firefox|(?:Mobile )?Safari|MSIE|RockMelt|AppleWebKit|Chrome|IEMobile|Opera|Version)(?:[/ ])(?P<version>[0-9.]+)%im', $user_agent, $result, PREG_PATTERN_ORDER ); 
    22      
    23     // If Version/x.x.x was specified in UA string store it and ignore it 
    24     if ( $key = array_search( 'Version', $result['name'] ) ) { 
    25         $version = $result['version'][ $key ]; 
    26         unset( $result['name'][ $key ] ); 
    27         unset( $result['version'][ $key ] ); 
    28     } 
     33                $data['name'] = 'Opera'; 
     34                if ( preg_match( '#Version/([0-9.]+)#i', $user_agent, $version ) ) { 
     35                        $data['version'] = $version[1]; 
     36                } elseif ( preg_match( '#Opera ([0-9.]+)#i', $user_agent, $version ) ) { 
     37                        $data['version'] = $version[1]; 
     38                } 
     39                $data['insecure'] = version_compare( $data['version'], '10.50', '<' ); 
     40        } elseif ( false !== stripos( $user_agent, 'MSIE' ) ) { 
     41                if ( false !== stripos( $user_agent, 'IEMobile' ) ) 
     42                        return $data; 
    2943 
    30     if ( 'AppleWebKit' == $result['name'][0] ) { 
    31         if ( $key = array_search( 'Mobile Safari', $result['name'] ) ) { 
    32             $data['name'] = 'Mobile Safari'; 
    33         // } elseif ( ( 'Android' == $data['platform'] && !($key = 0) ) || $key = array_search( 'Chrome', $result['name'] ) ) { 
    34         } elseif ( $key = array_search( 'RockMelt', $result['name'] ) ) { 
    35             $data['name'] = 'RockMelt'; 
    36         } elseif ( $key = array_search( 'Chrome', $result['name'] ) ) { 
    37             $data['name'] = 'Chrome'; 
    38         } elseif ( ! empty( $data['platform'] ) && 'PlayBook' == $data['platform'] ) { 
    39             $data['name'] = 'PlayBook'; 
    40         } elseif ( $key = array_search( 'Kindle', $result['name'] ) ) { 
    41             $data['name'] = 'Kindle'; 
    42         } elseif ( $key = array_search( 'Safari', $result['name'] ) ) { 
    43             $data['name'] = 'Safari'; 
    44         } else { 
    45             $key = 0; 
    46             $data['name'] = 'webkit'; 
    47         } 
    48         $data['version'] = $result['version'][ $key ]; 
    49     } elseif ( $key = array_search( 'Opera', $result['name'] ) ) { 
    50         $data['name'] = $result['name'][$key]; 
    51         $data['version'] = $result['version'][ $key ]; 
    52     } elseif ( 'MSIE' == $result['name'][0] ) { 
    53         if ( $key = array_search( 'IEMobile', $result['name'] ) ) { 
    54             $data['name'] = 'Internet Explorer Mobile'; 
    55         } else { 
    56             $data['name'] = 'Internet Explorer'; 
    57             $key = 0; 
    58         } 
    59         $data['version'] = $result['version'][ $key ]; 
    60     } else { 
    61         $data['name'] = $result['name'][0]; 
    62         $data['version'] = $result['version'][0]; 
    63     } 
     44                $data['name'] = 'Internet Explorer'; 
     45                if ( false !== stripos( $user_agent, 'Trident' ) ) { 
     46                        preg_match( '#Trident/([0-9.]+)#i', $user_agent, $trident ); 
     47                        switch( $trident[1] ) { 
     48                                case '5.0': 
     49                                        $data['version'] = '9.0'; 
     50                                        break; 
     51                                case '4.0': 
     52                                        $data['version'] = '8.0'; 
     53                                        break; 
     54                        } 
     55                } 
     56                if ( empty( $data['version'] ) ) { 
     57                        if ( preg_match( '#MSIE ([0-9.]+)#i', $user_agent, $version ) ) 
     58                                $data['version'] = $version[1]; 
     59                } 
     60                $data['insecure'] = version_compare( $data['version'], '8', '<' ); 
     61        } elseif ( false !== stripos( $user_agent, 'Chrome' ) ) { 
     62                //Ignore Chromium 
     63                if ( false !== stripos( $user_agent, 'Chromium' ) ) 
     64                        return $data; 
    6465 
    65     if ( in_array( $data['name'], array( 'Kindle' ) ) ) 
    66         $data['platform'] = $data['name']; 
     66                $data['name'] = 'Chrome'; 
    6767 
    68     if ( in_array( $data['platform'], array( 'Android', 'iPad', 'iPhone' ) ) ) 
    69         $data['name'] = $data['platform']; 
     68                if ( preg_match( '#Chrome/([0-9.]+)#i', $user_agent, $version ) ) 
     69                        $data['version'] = $version[1]; 
    7070 
    71     // If Version/x.x.x was specified in UA string 
    72     if ( ! empty( $version ) ) 
    73         $data['version'] = $version; 
     71                $data['insecure'] = version_compare( $data['version'], '4.1.249.1042', '<' ); 
     72        } elseif ( false !== stripos( $user_agent, 'Safari' ) ) { 
     73                if ( false !== stripos( $user_agent, 'Mobile' ) || false !== stripos( $user_agent, 'Playbook' ) || false !== stripos( $user_agent, 'Kindle' ) ) 
     74                        return $data; 
    7475 
     76                $data['name'] = 'Safari'; 
     77                if ( preg_match( '#Version/([0-9.]+)#i', $user_agent, $version ) ) 
     78                        $data['version'] = $version[1]; 
     79 
     80                $data['insecure'] = version_compare( $data['version'], '4', '<' ); 
     81        } elseif ( false !== stripos( $user_agent, 'Firefox' ) ) { 
     82                if ( false !== stripos( $user_agent, 'Camino' ) ) 
     83                        return $data; 
     84 
     85                $data['name'] = 'Firefox'; 
     86                if ( preg_match( '#Firefox/([0-9.]+)#i', $user_agent, $version ) ) 
     87                        $data['version'] = $version[1]; 
     88 
     89                $data['insecure'] = version_compare( $data['version'], '3.6.9', '<' ); 
     90        } 
     91 
    7592        $browser_data = browsehappy_get_browser_data( $data['name'] ); 
    7693        $data['update_url']  = $browser_data ? $browser_data->url : ''; 
    7794        $data['img_src']     = $browser_data ? $browser_data->img_src : ''; 
     
    7996 
    8097        $data['current_version'] = get_browser_version_from_name( $data['name'] ); 
    8198        $data['upgrade']         = ( !empty( $data['current_version'] ) && version_compare( $data['version'], $data['current_version'], '<' ) ); 
    82         $data['insecure']        = ( 'Internet Explorer' == $data['name'] && version_compare( $data['version'], '8', '<' ) ); 
    8399 
    84100        return $data; 
    85101}