Index: browse-happy/1.0/tests.php
===================================================================
--- browse-happy/1.0/tests.php	(revision 111)
+++ browse-happy/1.0/tests.php	(working copy)
@@ -1,53 +1,56 @@
 <?php
 
-include dirname( __FILE__ ) . '/index.php';
+require dirname( __FILE__ ) . '/index.php';
 
 $tests = array (
-  'Mozilla/4.0 (Windows; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 2.0.50727)' => 'Windows Internet Explorer 6.0',
-  'Mozilla/4.0 (MSIE 6.0; Windows NT 5.1)' => 'Windows Internet Explorer 6.0',
-  'Mozilla/4.0 (MSIE 6.0; Windows NT 5.0)' => 'Windows Internet Explorer 6.0',
-  'Mozilla/4.0 (compatible;MSIE 6.0;Windows 98;Q312461)' => 'Windows Internet Explorer 6.0',
-  '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',
-  'Mozilla/4.0 (compatible; U; MSIE 6.0; Windows NT 5.1)' => 'Windows Internet Explorer 6.0',
-  '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',
-  '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',
-  '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',
-  'Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0)' => 'Windows Internet Explorer 9.0',
-  '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',
-  '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',
-  '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',
-  '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',
-  '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',
-  'Opera/9.80 (Windows NT 6.0; U; en) Presto/2.8.99 Version/11.10' => 'Windows Opera 11.10',
-  'Opera/9.80 (Windows NT 5.1; U; cs) Presto/2.7.62 Version/11.01' => 'Windows Opera 11.01',
-  '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',
-  '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',
-  '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',
-  'Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; de) Opera 11.01' => 'Windows Opera 11.01',
-  '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',
-  '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',
-  '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',
-  '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',
-  'Mozilla/5.0 (Macintosh; U; PPC Mac OS X; en) AppleWebKit/312.9 (KHTML, like Gecko) Safari/312.6' => 'Macintosh Safari 312.6',
-  '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',
-  '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',
-  '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',
-  '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',
-  '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',
-  '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',
-  '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',
-  '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',
-  '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',
-  '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',
-  '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',
-  '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',
-  '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',
-  'Mozilla/4.0 (compatible; Linux 2.6.10) NetFront/3.3 Kindle/1.0 (screen 600x800)' => 'Kindle Kindle 1.0',
-  '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',
-  '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',
-  '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',
-  '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',
-  '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',
+	'Mozilla/4.0 (Windows; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 2.0.50727)' => 'Internet Explorer 6.0',
+	'Mozilla/4.0 (MSIE 6.0; Windows NT 5.1)' => 'Internet Explorer 6.0',
+	'Mozilla/4.0 (MSIE 6.0; Windows NT 5.0)' => 'Internet Explorer 6.0',
+	'Mozilla/4.0 (compatible;MSIE 6.0;Windows 98;Q312461)' => 'Internet Explorer 6.0',
+	'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',
+	'Mozilla/4.0 (compatible; U; MSIE 6.0; Windows NT 5.1)' => 'Internet Explorer 6.0',
+	'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',
+	'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',
+	'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',
+	'Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0)' => 'Internet Explorer 9.0',
+	'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',
+	'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',
+	'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',
+	'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',
+	'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',
+	'Opera/9.80 (Windows NT 6.0; U; en) Presto/2.8.99 Version/11.10' => 'Opera 11.10',
+	'Opera/9.80 (Windows NT 5.1; U; cs) Presto/2.7.62 Version/11.01' => 'Opera 11.01',
+	'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',
+	'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',
+	'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',
+	'Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; de) Opera 11.01' => 'Opera 11.01',
+	'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',
+	'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',
+	'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',
+	'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',
+	'Mozilla/5.0 (Macintosh; U; PPC Mac OS X; en) AppleWebKit/312.9 (KHTML, like Gecko) Safari/312.6' => 'Safari',
+	'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',
+	'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',
+	'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)' => '',
+	'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)' => '',
+	'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)' => '',
+	'Mozilla/5.0 (Macintosh; U; Intel Mac OS X; en; rv:1.8.1.11) Gecko/20071128 Camino/1.5.4' => '',
+	'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' => '',
+	'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' => '',
+	'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' => '',
+	'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' => '',
+	'Mozilla/5.0 (iPhone; U; CPU like Mac OS X; en) AppleWebKit/420+ (KHTML, like Gecko) Version/3.0 Mobile/1C25 Safari/419.3' => '',
+	'Mozilla/4.0 (compatible; MSIE 7.0; Windows Phone OS 7.0; Trident/3.1; IEMobile/7.0) Asus;Galaxy6' => '',
+	'Mozilla/4.0 (compatible; MSIE 7.0; Windows Phone OS 7.0; Trident/3.1; IEMobile/7.0; LG; GW910)' => '',
+	'Mozilla/4.0 (compatible; MSIE 7.0; Windows Phone OS 7.0; Trident/3.1; IEMobile/7.0) LG;LG-E900h)' => '',
+	'Mozilla/4.0 (compatible; Linux 2.6.10) NetFront/3.3 Kindle/1.0 (screen 600x800)' => '',
+	'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)' => '',
+	'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)' => '',
+	'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' => '',
+	'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' => '',
+	'Opera/9.80 (Windows Mobile; WCE; Opera Mobi/WMD-50255; U; en) Presto/2.4.13 Version/10.00' => '',
+	'Opera/9.80 (S60; SymbOS; Opera Mobi/275; U; en) Presto/2.4.13 Version/10.00' => '',
+	'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',
 );
 
 $pass = $fail = 0;
@@ -55,7 +58,14 @@
 
 foreach ( $tests as $ua => $assert ) {
 	$parsed = parse_user_agent( $ua );
-	$result = $parsed['platform'] . ' ' . $parsed['name'] . ' ' . $parsed['version'];
+	$result = array();
+	if ( !empty( $parsed['name'] ) )
+		$result[] = $parsed['name'];
+
+	if ( !empty( $parsed['version'] ) )
+		$result[] = $parsed['version'];
+
+	$result = implode( ' ', $result );
 	if ( $assert === $result ) {
 		++$pass;
 	} else {
Index: browse-happy/1.0/index.php
===================================================================
--- browse-happy/1.0/index.php	(revision 111)
+++ browse-happy/1.0/index.php	(working copy)
@@ -13,65 +13,82 @@
 * @return array containing platform, name, and version
 */
 function parse_user_agent( $user_agent ) {
-	$data = array();
+	$data = array(
+		'platform'        => '',
+		'name'            => '',
+		'update_url'      => '',
+		'img_src'         => '',
+		'img_src_ssl'     => '',
+		'current_version' => '',
+		'version'         => '',
+		'upgrade'         => 0,
+		'insecure'        => 0
+	);
 
-    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 ) )
-        $data['platform'] = $regs['platform'];
+	// Opera first because it seems to be the only non IE browser with MSIE in the UA
+	if ( false !== stripos( $user_agent, 'Opera' ) ) {
+		if ( false !== stripos( $user_agent, 'Opera Mobi' ) )
+			return $data;
 
-    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 );
-    
-    // If Version/x.x.x was specified in UA string store it and ignore it
-    if ( $key = array_search( 'Version', $result['name'] ) ) {
-        $version = $result['version'][ $key ];
-        unset( $result['name'][ $key ] );
-        unset( $result['version'][ $key ] );
-    }
+		$data['name'] = 'Opera';
+		if ( preg_match( '#Version/([0-9.]+)#i', $user_agent, $version ) ) {
+			$data['version'] = $version[1];
+		} elseif ( preg_match( '#Opera ([0-9.]+)#i', $user_agent, $version ) ) {
+			$data['version'] = $version[1];
+		}
+		$data['insecure'] = version_compare( $data['version'], '10.50', '<' );
+	} elseif ( false !== stripos( $user_agent, 'MSIE' ) ) {
+		if ( false !== stripos( $user_agent, 'IEMobile' ) )
+			return $data;
 
-    if ( 'AppleWebKit' == $result['name'][0] ) {
-        if ( $key = array_search( 'Mobile Safari', $result['name'] ) ) {
-            $data['name'] = 'Mobile Safari';
-        // } elseif ( ( 'Android' == $data['platform'] && !($key = 0) ) || $key = array_search( 'Chrome', $result['name'] ) ) {
-        } elseif ( $key = array_search( 'RockMelt', $result['name'] ) ) {
-            $data['name'] = 'RockMelt';
-        } elseif ( $key = array_search( 'Chrome', $result['name'] ) ) {
-            $data['name'] = 'Chrome';
-        } elseif ( ! empty( $data['platform'] ) && 'PlayBook' == $data['platform'] ) {
-            $data['name'] = 'PlayBook';
-        } elseif ( $key = array_search( 'Kindle', $result['name'] ) ) {
-            $data['name'] = 'Kindle';
-        } elseif ( $key = array_search( 'Safari', $result['name'] ) ) {
-            $data['name'] = 'Safari';
-        } else {
-            $key = 0;
-            $data['name'] = 'webkit';
-        }
-        $data['version'] = $result['version'][ $key ];
-    } elseif ( $key = array_search( 'Opera', $result['name'] ) ) {
-        $data['name'] = $result['name'][$key];
-        $data['version'] = $result['version'][ $key ];
-    } elseif ( 'MSIE' == $result['name'][0] ) {
-        if ( $key = array_search( 'IEMobile', $result['name'] ) ) {
-            $data['name'] = 'Internet Explorer Mobile';
-        } else {
-            $data['name'] = 'Internet Explorer';
-            $key = 0;
-        }
-        $data['version'] = $result['version'][ $key ];
-    } else {
-        $data['name'] = $result['name'][0];
-        $data['version'] = $result['version'][0];
-    }
+		$data['name'] = 'Internet Explorer';
+		if ( false !== stripos( $user_agent, 'Trident' ) ) {
+			preg_match( '#Trident/([0-9.]+)#i', $user_agent, $trident );
+			switch( $trident[1] ) {
+				case '5.0':
+					$data['version'] = '9.0';
+					break;
+				case '4.0':
+					$data['version'] = '8.0';
+					break;
+			}
+		}
+		if ( empty( $data['version'] ) ) {
+			if ( preg_match( '#MSIE ([0-9.]+)#i', $user_agent, $version ) )
+				$data['version'] = $version[1];
+		}
+		$data['insecure'] = version_compare( $data['version'], '8', '<' );
+	} elseif ( false !== stripos( $user_agent, 'Chrome' ) ) {
+		//Ignore Chromium
+		if ( false !== stripos( $user_agent, 'Chromium' ) )
+			return $data;
 
-    if ( in_array( $data['name'], array( 'Kindle' ) ) )
-        $data['platform'] = $data['name'];
+		$data['name'] = 'Chrome';
 
-    if ( in_array( $data['platform'], array( 'Android', 'iPad', 'iPhone' ) ) )
-	$data['name'] = $data['platform'];
+		if ( preg_match( '#Chrome/([0-9.]+)#i', $user_agent, $version ) )
+			$data['version'] = $version[1];
 
-    // If Version/x.x.x was specified in UA string
-    if ( ! empty( $version ) )
-        $data['version'] = $version;
+		$data['insecure'] = version_compare( $data['version'], '4.1.249.1042', '<' );
+	} elseif ( false !== stripos( $user_agent, 'Safari' ) ) {
+		if ( false !== stripos( $user_agent, 'Mobile' ) || false !== stripos( $user_agent, 'Playbook' ) || false !== stripos( $user_agent, 'Kindle' ) )
+			return $data;
 
+		$data['name'] = 'Safari';
+		if ( preg_match( '#Version/([0-9.]+)#i', $user_agent, $version ) )
+			$data['version'] = $version[1];
+
+		$data['insecure'] = version_compare( $data['version'], '4', '<' );
+	} elseif ( false !== stripos( $user_agent, 'Firefox' ) ) {
+		if ( false !== stripos( $user_agent, 'Camino' ) )
+			return $data;
+
+		$data['name'] = 'Firefox';
+		if ( preg_match( '#Firefox/([0-9.]+)#i', $user_agent, $version ) )
+			$data['version'] = $version[1];
+
+		$data['insecure'] = version_compare( $data['version'], '3.6.9', '<' );
+	}
+
 	$browser_data = browsehappy_get_browser_data( $data['name'] );
 	$data['update_url']  = $browser_data ? $browser_data->url : '';
 	$data['img_src']     = $browser_data ? $browser_data->img_src : '';
@@ -79,7 +96,6 @@
 
 	$data['current_version'] = get_browser_version_from_name( $data['name'] );
 	$data['upgrade']         = ( !empty( $data['current_version'] ) && version_compare( $data['version'], $data['current_version'], '<' ) );
-	$data['insecure']        = ( 'Internet Explorer' == $data['name'] && version_compare( $data['version'], '8', '<' ) );
 
 	return $data;
 }
