Mobile Browser Identification

Written something you are proud of, post it here.
Post Reply
User avatar
ta2shop
Posts: 179
Joined: Sat May 07, 2011 9:07 am
Location: madrid, Spain
Contact:

Mobile Browser Identification

Post by ta2shop »

hy guys, just thinking to bragg about my new script, that y made ;)
it is about browser detection, actuali it only detect blackberry's and samsung's , but i hope that with your help, people who have a mobile phone with internet conection, can point out the $_SERVER['HTTP_USER_AGENT']; for my so i can extend the script.
here it goes:
index.php
<?php
include('functions.include.inc.php');
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Browser Identification</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<link rel="stylesheet" type="text/css" href="style.css"/>

</head>
<body>

<table align="left" border="0" cellpadding="10" cellspacing="5">
		<tr>
        	<td colspan="2" align="left" valign="top">
            <?php echo "<b>Your Browser:</b> " .$navegador; ?>
            </td>
        </tr>
        <tr>
        	<td valign="top"> 
            <strong>Web Browsers</strong><br />
        	Mozilla FireFox.<br />
        	Google Crome.<br />
        	Safari.<br />
        	Internet Explorer 8.<br />
        	Internet Explorer 9.<br />
            Opera 11.<br />
            </td>
            <td valign="top">
            <strong>Mobile Browsers</strong><br />
        	BlackBerry Curve 8520.<br />
        	Samsung Galaxy 3.<br />
        	Samsung GT-S3550.<br />
        	HTC Desire.<br />
            Opera Mobile 10.<br />
            </td>
        </tr>
        <tr>
        	<td colspan="2" align="left">
            <?php require('browser.form.inc.php'); ?>	
            </td>
        </tr>
</table>
</body>
</html>
and the functions.php
<?php
$pre = $_SERVER['HTTP_USER_AGENT'];
$size = "width='80' height='80'";
  
if(strpos($pre, "MSIE 9.0")!=0)
$navegador = "Internet Explorer 9 <br> <img src='img/ie.jpg'" .$size.">";

else if(strpos($pre, "MSIE 8.0")!=0)
$navegador = "Internet Explorer 8 <br> <img src='img/ie.jpg'".$size."/>";

else if(strpos($pre, "AppleWebKit/534.24")!=0)
$navegador = "Google Crome <br> <img src='img/chrome.jpg'" .$size. "/>";

else if(strpos($pre, "AppleWebKit/533.19.4")!=0)
$navegador = "Safari <br> <img src='img/safari.jpg'".$size." />";

else if(strpos($pre, "Firefox")!=0)
$navegador = "Firefox <br> <img src='img/firefox.jpg' ".$size." />";

else if(strpos($pre, "MIDP-2.1")!=0)
$navegador = "BlackBerry 8520 <br> <img src='img/blackberry.JPG' ".$size." />";

else if(strpos($pre, "AppleWebKit/530.17")!=0)
$navegador = "Samsung Galaxy 3 <br> <img src='img/samsung.jpg' ".$size." />";

else if(strpos($pre, "AppleWebKit/533.1")!=0)
$navegador = "HTC Desire <br> <img src='img/htc.jpg' ".$size." />";

else if(strpos($pre, "MIDP-2.0")!=0)
$navegador = "Samsung GT-S3550 <br> <img src='img/samsung.jpg' ".$size." />";

else if(strpos($pre, "Presto/2.8.131 Version/11.10")!=0)
$navegador = "Opera 11 <br> <img src='img/opera.png' ".$size." />";

else if(strpos($pre, "Presto/2.5.25 Version/10.54")!=0)
$navegador = "Opera 10 Mobil <br> <img src='img/opera.mobil.png' ".$size." />";

else
$navegador = "Unknown";
 
?>
the test.php file, this just for detecting new browsers.
<?php
echo $_SERVER['HTTP_USER_AGENT'];
?>

also the zip file of all the images used :)
img.zip
(233.34 KiB) Downloaded 294 times
well hope you find it usful, and also i want to ask thoes of you who have a mobil phone with internet conection, to just run the "test.php" file and send my a PM with the exact string it echo's and your mobil phone exact model name and number, this wai i will update the script to more browsers.

EDIT* just changed the code, it is stil in 2 separate files, but much more better structured now, thanks JaceK , also note that the index.php it is only displayng some html and text.
Last edited by ta2shop on Mon May 16, 2011 9:23 am, edited 1 time in total.
Image
User avatar
jacek
Site Admin
Posts: 3262
Joined: Thu May 05, 2011 1:45 pm
Location: UK
Contact:

Re: Mobile Browser Identification

Post by jacek »

http://www.user-agents.org/index.shtml

The internet has everything ;)
Image
User avatar
ta2shop
Posts: 179
Joined: Sat May 07, 2011 9:07 am
Location: madrid, Spain
Contact:

Re: Mobile Browser Identification

Post by ta2shop »

yes it does, but that is not my, mine made!
if i just copy the browsers strings from there, what do i learn?
it actualy tokt my a whole day to fine out the string for the browsers you sy in my script :lol:
Image
Carbine
Posts: 58
Joined: Fri May 06, 2011 1:47 pm
Location: UK, Nottinghamshire
Contact:

Re: Mobile Browser Identification

Post by Carbine »

You could have used the switch statement I suppose xD but nice
User avatar
ta2shop
Posts: 179
Joined: Sat May 07, 2011 9:07 am
Location: madrid, Spain
Contact:

Re: Mobile Browser Identification

Post by ta2shop »

i have to lookup the swith thing. :lol:
Image
User avatar
jacek
Site Admin
Posts: 3262
Joined: Thu May 05, 2011 1:45 pm
Location: UK
Contact:

Re: Mobile Browser Identification

Post by jacek »

This was my attempt at a similar thing from a while ago, there really is no clean way to do it for a large number of browsers.
function get_platform_info($ua = null){
	if ($ua === null){
		$ua = $_SERVER['HTTP_USER_AGENT'];
	}
	
	$ua = str_replace(array("\r", "\n"), '', strtolower($ua));
	
	$bname		= 'Unknown';
	$bver		= 'Unknown';
	$osname		= 'Unknown';
	$osver		= 'Unknown';
	
	// find the OS and version if possible.
	if (strpos($ua, 'iphone') !== false || strpos($ua, 'ipad') !== false || strpos($ua, 'ipod') !== false){
		$osname = 'iOS';
		preg_match('#(?:iphone|ios|os) ([0-9\._]+)#', $ua, $version);
		$osver = (empty($version[1])) ? 'Unknown' : str_replace('_', '.', $version[1]);
	}else if (strpos($ua, 'android') !== false){
		$osname = 'Android';
		preg_match('#android ([0-9\.]+)#', $ua, $version);
		$osver = (empty($version[1])) ? 'Unknown' : $version[1];
	}else if (strpos($ua, 'blackberry') !== false){
		$osname = 'BlackBerry';
		preg_match('#(?:blackberry[0-9]+|version)/([0-9\.]+)#', $ua, $version);
		$osver = (empty($version[1])) ? 'Unknown' : $version[1];
	}else if (strpos($ua, 'symbianos') !== false){
		$osname = 'SymbianOS';
		preg_match('#symbianos/([0-9\.]+)#', $ua, $version[1]);
		$osver = (empty($version[1])) ? 'Unknown' : $version[1];
	}else if (strpos($ua, 'palmos') !== false || strpos($ua, 'palmsource') !== false){
		$osname = 'PalmOS';
		preg_match('#palmos ([0-9\.]+)#', $ua, $version);
		$osver = (empty($version[1])) ? 'Unknown' : $version[1];
	}else if (strpos($ua, 'wm5') !== false){
		$osname = 'Windows Mobile';
		$osver = '5';
	}else if (strpos($ua, 'windows phone') !== false || strpos($ua, 'windows mobile') !== false || strpos($ua, 'mobileexplorer') !== false){
		$osname = 'Windows Mobile';
		preg_match('#(?:windows (?:phone|mobile) |mobileexplorer/)([0-9\.]+)#', $ua, $version);
		$osver = (empty($version[1])) ? 'Unknown' : $version[1];
	}else if (strpos($ua, 'kindle') !== false){
		$osname = 'Amazon Kindle';
		preg_match('#kindle/([0-9\.]+)#', $ua, $version);
		$osver = (empty($version[1])) ? 'Unknown' : $version[1];
	}else if (strpos($ua, 'webos') !== false){
		$osname = 'WebOS';
		preg_match('#webos/([0-9\.]+)#', $ua, $version);
		$osver = (empty($version[1])) ? 'Unknown' : $version[1];
	}else if (strpos($ua, 'benq-') !== false){
		$osname = 'BenQ Mobile Device';
	}else if (strpos($ua, 'lg-') !== false || strpos($ua, 'lge') !== false){
		$osname = 'LG Mobile Device';
	}else if (strpos($ua, 'nokia') !== false){
		$osname = 'Nokia Mobile Device';
	}else if (strpos($ua, 'motorola') !== false || strpos($ua, 'mot') !== false){
		$osname = 'Motorola Mobile Device';
	}else if (strpos($ua, 'nintendo wii') !== false){
		$osname = 'Nintendo Wii Console';
	}else if (strpos($ua, 'o2 xda') !== false){
		$osname = 'o2 Mobile Device';
	}else if (strpos($ua, 'samsung') !== false || strpos($ua, 'sec') !== false){
		$osname = 'Samsung Mobile Device';
	}else if (strpos($ua, 'sanyo') !== false){
		$osname = 'Sanyo Mobile Device';
	}else if (strpos($ua, 'sharp') !== false){
		$osname = 'Sharp Mobile Device';
	}else if (strpos($ua, 'sie-') !== false){
		$osname = 'Siemens Mobile Device';
	}else if (strpos($ua, 'sonyericsson') !== false){
		$osname = 'Sony/Ericsson Mobile Device';
	}else if (strpos($ua, 'playstation portable') !== false || strpos($ua, 'psp') !== false){
		$osname = 'Sony PSP';
	}else if (strpos($ua, 'playstation') !== false){
		$osname = 'Sony Playstation';
	}else if (strpos($ua, 'linux') !== false || strpos($ua, 'x11') !== false){
		if (strpos($ua, 'ubuntu') !== false){
			$osname = 'Ubuntu';
			$regexp = '#ubuntu/([0-9\.]+)#';
		}else if (strpos($ua, 'mint') !== false){
			$osname = 'Linux Mint';
			$regexp = '#mint/([0-9\.]+)#';
		}else if (strpos($ua, 'debian') !== false){
			$osname = 'Debian';
			$regexp = '#debian/([0-9\.]+)#';
		}else if (strpos($ua, 'knoppix') !== false){
			$osname = 'Knoppix';
			$regexp = '#knoppix/([0-9\.]+)#';
		}else if (strpos($ua, 'kubuntu') !== false){
			$osname = 'Kubuntu';
			$regexp = '#ubuntu/([0-9\.]+)#';
		}else if (strpos($ua, 'xubuntu') !== false){
			$osname = 'Xubuntu';
			$regexp = '#ubuntu/([0-9\.]+)#';
		}else if (strpos($ua, 'fedora') !== false){
			$osname = 'Fedora';
			$regexp = '#fedora/([0-9\.]+)#';
		}else if (strpos($ua, 'centos') !== false){
			$osname = 'centOS';
			$regexp = '#centos/([0-9\.]+)#';
		}else if (strpos($ua, 'mandriva') !== false){
			$osname = 'Mandriva';
			$regexp = '#mandriva/([0-9\.]+)#';
		}else if (strpos($ua, 'redhat') !== false || strpos($ua, 'red_hat') !== false || strpos($ua, 'red-hat') !== false || strpos($ua, 'sunos') !== false){
			$osname = 'Red Hat';
			$regexp = '#(?:redhat|red_hat|red-hat|sunos)/([0-9\.]+)#';
		}else if (strpos($ua, 'suse') !== false){
			$osname = 'openSUSE';
			$regexp = '#suse/([0-9\.]+)#';
		}else if (strpos($ua, 'slackware') !== false){
			$osname = 'Slackware';
			$regexp = '#slackware/([0-9\.]+)#';
		}else if (strpos($ua, 'backtrack') !== false){
			$osname = 'Backtrack';
			$regexp = '#backtrack/([0-9\.]+)#';
		}else if (strpos($ua, 'gentoo') !== false){
			$osname = 'Gentoo';
			$regexp = '#gentoo/([0-9\.]+)#';
		}else{
			$osname = 'Linux';
		}
		
		if (isset($regexp)){
			preg_match($regexp, $ua, $version);
		}
		
		$osver = (empty($version[1])) ? 'Unknown' : $version[1];
	}else if (strpos($ua, 'win') !== false){
		$osname = 'Windows';
		
		if (strpos($ua, 'windows 95') !== false || strpos($ua, 'windows_95') !== false || strpos($ua, 'win95') !== false){
			$osver = '95';
		}else if (strpos($ua, 'windows 98') !== false || strpos($ua, 'win98') !== false){
			$osver = '98';
		}else if (strpos($ua, 'windows nt 5.0') !== false || strpos($ua, 'windows 2000') !== false){
			$osver = '2000';
		}else if (strpos($ua, 'windows nt 5.1') !== false || strpos($ua, 'windows xp') !== false){
			$osver = 'XP';
		}else if (strpos($ua, 'windows nt 5.2') !== false){
			$osver = 'Server 2003';
		}else if (strpos($ua, 'windows nt 6.0') !== false){
			$osver = 'Vista';
		}else if (strpos($ua, 'windows nt 6.1') !== false){
			$osver = '7';
		}else if (strpos($ua, 'windows me') !== false){
			$osver = 'ME';
		}else if (strpos($ua, 'windows ce') !== false){
			$osver = 'CE';
		}else if (strpos($ua, 'windows nt') !== false || strpos($ua, 'winnt') !== false){
			$osver = 'NT 4.0';
		}
	}else if (strpos($ua, 'macintosh') !== false || strpos($ua, 'mac os') !== false){
		if (strpos($ua, 'mac os x') !== false){
			$osname = 'Mac OS X';
		}else{
			$osname = 'Mac OS';
		}
		
		preg_match('#mac os x ([0-9\._]+)#', $ua, $version);
		
		$osver = (empty($version[1])) ? 'Unknown' : str_replace('_', '.', $version[1]);
	}
	
	// because we need to check for these again later.
	unset($regexp, $version);
	
	// find the browser and version if possible.
	// list of browser user agents from http://www.zytrax.com/tech/web/browser_ids.htm
	if (strpos($ua, 'amaya') !== false){
		$bname = 'Amaya';
		$regexp = '#amaya/([0-9\.]+)#';
	}else if (strpos($ua, 'amigavoyager') !== false){
		$bname = 'Amiga Voyager';
		$regexp = '#amigavoyager/([0-9\.]+)#';
	}else if (strpos($ua, 'xchaos_arachne') !== false){
		$bname = 'Arachne';
		$regexp = '#xchaos_arachne/([0-9\.]+)#';
	}else if (strpos($ua, 'apt-http') !== false){
		$bname = 'apt-get';
		$regexp = '#apt-http/([0-9\.]+)#';
	}else if (strpos($ua, 'arora') !== false){
		$bname = 'Arora';
		$regexp = '#arora/([0-9\.]+)#';
	}else if (strpos($ua, 'avant browser') !== false){
		$bname = 'Avant Browser';
	}else if (strpos($ua, 'amiga-aweb') !== false){
		$bname = 'Amiga Aweb';
		$regexp = '#amiga-aweb/([0-9\.]+)#';
	}else if (strpos($ua, 'browsex') !== false){
		$bname = 'BrowseX';
		$regexp = '#browsex \(([0-9\.]+)#';
	}else if (strpos($ua, 'camino') !== false){
		$bname = 'Camino';
		$regexp = '#camino/([0-9\.]+)#';
	}else if (strpos($ua, 'charon') !== false){
		$bname = 'Charon';
	}else if (strpos($ua, 'check&get') !== false){
		$bname = 'Check&Get';
		$regexp = '#check&get ([0-9\.]+)#';
	}else if (strpos($ua, 'chimera') !== false){
		$bname = 'Chimera';
		$regexp = '#chimera/([0-9\.]+)#';
	}else if (strpos($ua, 'amaya') !== false){
		$bname = 'Amaya';
		$regexp = '#amaya/([0-9\.]+)#';
	}else if (strpos($ua, 'comodo_dragon') !== false){
		$bname = 'Comodo Dragon';
		$regexp = '#dragon/([0-9\.]+)#';
	}else if (strpos($ua, ' iron') !== false){
		$bname = 'SRWare Iron';
		$regexp = '#iron/([0-9\.]+)#';
	}else if (strpos($ua, 'like gecko) chrome') !== false){
		$bname = 'Google Chrome';
		$regexp = '#chrome/([0-9\.]+)#';
	}else if (strpos($ua, 'curl') !== false){
		$bname = 'cURL';
		$regexp = '#curl/([0-9\.]+)#';
	}else if (strpos($ua, 'democracy') !== false){
		$bname = 'Democracy';
		$regexp = '#democracy/([0-9\.]+)#';
	}else if (strpos($ua, 'dillo') !== false){
		$bname = 'Dillo';
		$regexp = '#dillo/([0-9\.]+)#';
	}else if (strpos($ua, 'doczilla') !== false){
		$bname = 'DocZilla';
		$regexp = '#doczilla/([0-9\.]+)#';
	}else if (strpos($ua, 'edbrowse') !== false){
		$bname = 'edbrowse';
		$regexp = '#edbrowse/([0-9\.]+)#';
	}else if (strpos($ua, 'elinks') !== false){
		$bname = 'ELinks';
		$regexp = '#elinks/([0-9\.]+)#';
	}else if (strpos($ua, 'emacs-w3') !== false){
		$bname = 'Emacs/w3s';
		$regexp = '#emacs-w3/([0-9\.]+)#';
	}else if (strpos($ua, 'epiphany') !== false){
		$bname = 'Epiphany';
		$regexp = '#epiphany/([0-9\.]+)#';
	}else if (strpos($ua, 'fetch libfetch') !== false){
		$bname = 'Fetch';
	}else if (strpos($ua, 'fennec') !== false){
		$bname = 'Mobile Firefox';
		$regexp = '#fennec/([0-9\.]+)#';
	}else if (strpos($ua, 'flock') !== false){
		$bname = 'Flock';
		$regexp = '#flock/([0-9\.]+)#';
	}else if (strpos($ua, 'galeon') !== false){
		$bname = 'Galeon';
		$regexp = '#galeon/([0-9\.]+)#';
	}else if (strpos($ua, 'iceweasel') !== false){
		$bname = 'IceWeasel';
		$regexp = '#iceweasel/([0-9\.]+)#';
	}else if (strpos($ua, 'iseape') !== false){
		$bname = 'IceApe';
		$regexp = '#iceape/([0-9\.]+)#';
	}else if (strpos($ua, 'icecat') !== false){
		$bname = 'IceCat';
		$regexp = '#icecat/([0-9\.]+)#';
	}else if (strpos($ua, 'palemoon') !== false){
		$bname = 'Palemoon';
		$regexp = '#palemoon/([0-9\.]+)#';
	}else if (strpos($ua, 'swiftfox') !== false){
		$bname = 'SwiftFox';
		$regexp = '#firefox/([0-9\.]+)#';
	}else if (strpos($ua, 'firefox') !== false){
		$bname = 'Firefox';
		$regexp = '#firefox/([0-9\.]+)#';
	}else if (strpos($ua, 'superswan') !== false){
		$bname = 'Firefox';
		$regexp = '#superswan/([0-9\.]+)#';
	}else if (strpos($ua, 'deepnet explorer') !== false){
		$bname = 'GreenBrowser';
		$regexp = '#deepnet explorer ([0-9\.]+)#';
	}else if (strpos($ua, 'ibrowse') !== false){
		$bname = 'IBrowse';
		$regexp = '#ibrowse/([0-9\.]+)#';
	}else if (strpos($ua, 'icab') !== false){
		$bname = 'iCab';
		$regexp = '#icab(?:/| )([0-9\.]+)#';
	}else if (strpos($ua, 'alertsite.com') !== false){
		$bname = 'AlertSite.com';
		$regexp = '#ipd/([0-9\.]+)#';
	}else if (strpos($ua, 'ice browser') !== false){
		$bname = 'ICE';
		$regexp = '#browser/([0-9\.]+)#';
	}else if (strpos($ua, 'kazehakase') !== false){
		$bname = 'Kazehakase';
		$regexp = '#kazehakase/([0-9\.]+)#';
	}else if (strpos($ua, 'kkman') !== false){
		$bname = 'Kkman';
		$regexp = '#kkman([0-9\.]+)#';
	}else if (strpos($ua, 'k-melon') !== false){
		$bname = 'K-Melon';
		$regexp = '#(?:k\-melon |k-melon/|k-melonccfme )([0-9\.]+)#';
	}else if (strpos($ua, 'konqueror') !== false){
		$bname = 'Konqueror';
		$regexp = '#konqueror/([0-9\.]+)#';
	}else if (strpos($ua, 'lobo') !== false){
		$bname = 'Lobo';
		$regexp = '#lobo/([0-9\.]+)#';
	}else if (strpos($ua, 'lynx') !== false){
		$bname = 'Lynx';
		$regexp = '#lynx/([0-9\.]+)#';
	}else if (strpos($ua, 'maxathon') !== false){
		$bname = 'Maxathon';
	}else if (strpos($ua, 'maxthon') !== false){
		$bname = 'Maxthon';
		$regexp = '#maxthon/([0-9\.]+)#';
	}else if (strpos($ua, 'midori') !== false){
		$bname = 'midori';
		$regexp = '#midori/([0-9\.]+)#';
	}else if (strpos($ua, 'mosaic') !== false){
		$bname = 'Mosaic';
		$regexp = '#(mosaic|digital)/([0-9\.]+)#';
	}else if (strpos($ua, 'seamonkey') !== false){
		$bname = 'Mozilla (SeaMonkey)';
		$regexp = '#seamonkey/([0-9\.]+)#';
	}else if (strpos($ua, 'crazy browser') !== false){
		$bname = 'Crazy Browser';
		$regexp = '#crazy browser ([0-9\.]+)#';
	}else if (strpos($ua, 'theworld') !== false){
		$bname = 'TheWorld';
	}else if (strpos($ua, 'bsalsa') !== false){
		$bname = 'bsalsa';
	}else if (strpos($ua, 'sleipnir') !== false){
		$bname = 'Sleipnir';
		$regexp = '#sleipnir/([0-9\.]+)#';
	}else if (strpos($ua, 'slimbrowser') !== false){
		$bname = 'SlimBrowser';
	}else if (strpos($ua, 'mucommander') !== false){
		$bname = 'muCommander';
		$regexp = '#mucommander v([0-9\.]+)#';
	}else if (strpos($ua, 'netpositive') !== false){
		$bname = 'NetPositive';
		$regexp = '#netpositive/([0-9\.]+)#';
	}else if (strpos($ua, 'navigator') !== false){
		$bname = 'Netscape Navigator';
		$regexp = '#navigator/([0-9\.]+)#';
	}else if (strpos($ua, 'netscape') !== false){
		$bname = 'Netscape Navigator';
		$regexp = '#(?:netscape|netscape6)/([0-9\.]+)#';
	}else if (strpos($ua, 'netsurf') !== false){
		$bname = 'Netsurf';
		$regexp = '#netsurf/([0-9\.]+)#';
	}else if (strpos($ua, 'offbyone') !== false){
		$bname = 'OffByOne';
	}else if (strpos($ua, 'omniweb') !== false){
		$bname = 'Omniweb';
		$regexp = '#omniweb(?:/v|/)([0-9\.]+)#';
	}else if (strpos($ua, 'opera mini') !== false){
		$bname = 'Opera Mini';
		$regexp = '#opera mini(?:/| )([0-9\.]+)#';
	}else if (strpos($ua, 'opera') !== false){
		$bname = 'Opera';
		$regexp = '#version(?:/| )([0-9\.]+)#';
	}else if (strpos($ua, 'printsmart') !== false){
		$bname = 'HP Web PrintSmart';
		$regexp = '#printsmart (?:[a-z0-9]+) ([0-9\.]+)#';
	}else if (strpos($ua, 'prism') !== false){
		$bname = 'Mozilla Prism';
		$regexp = '#prism/([0-9\.]+)#';
	}else if (strpos($ua, 'retawq') !== false){
		$bname = 'retawq';
		$regexp = '#retawq/([0-9\.]+)#';
	}else if (strpos($ua, 'shiira') !== false){
		$bname = 'Shirra';
	}else if (strpos($ua, ' sis ') !== false){
		$bname = 'Spectrum Internet Suite';
		$regexp = '#sis /([0-9\.]+)#';
	}else if (strpos($ua, 'spicebird') !== false){
		$bname = 'Spicebird';
		$regexp = '#spicebird/([0-9\.]+)#';
	}else if (strpos($ua, 'songbird') !== false){
		$bname = 'Songbird';
		$regexp = '#songbird/([0-9\.]+)#';
	}else if (strpos($ua, 'stainless') !== false){
		$bname = 'Stainless';
		$regexp = '#stainless/([0-9\.]+)#';
	}else if (strpos($ua, 'strata') !== false){
		$bname = 'Strata';
		$regexp = '#strata/([0-9\.]+)#';
	}else if (strpos($ua, 'sylera') !== false){
		$bname = 'Sylera';
		$regexp = '#sylera/([0-9\.]+)#';
	}else if (strpos($ua, 'w3clinemode') !== false){
		$bname = 'W2C Line Mode';
		$regexp = '#w3clinemode/([0-9\.]+)#';
	}else if (strpos($ua, 'w3m') !== false){
		$bname = 'w3m';
		$regexp = '#w3m/([0-9\.]+)#';
	}else if (strpos($ua, 'wget') !== false){
		$bname = 'Wget';
		$regexp = '#wget/([0-9\.]+)#';
	}else if (strpos($ua, 'xenu_link_sleuth') !== false){
		$bname = 'Xenu\'s Link Analyser';
		$regexp = '#xenu_link_sleuth_([0-9\.]+)#';
	}else if (strpos($ua, 'netmath') !== false){
		$bname = 'Maxima';
	}else if (strpos($ua, 'avantgo') !== false){
		$bname = 'AvantGo';
		$regexp = '#avantgo ([0-9\.]+)#';
	}else if (strpos($ua, 'docomo') !== false){
		$bname = 'DoCoMo (NTT Mobile)';
		$regexp = '#docomo/([0-9\.]+)#';
	}else if (strpos($ua, 'eudoraweb') !== false){
		$bname = 'EudoraWeb';
		$regexp = '#eudoraweb ([0-9\.]+)#';
	}else if (strpos($ua, 'minimo') !== false){
		$bname = 'Minimo';
		$regexp = '#minimo/([0-9\.]+)#';
	}else if (strpos($ua, 'plink') !== false){
		$bname = 'PocketLink';
		$regexp = '#plink ([0-9\.]+)#';
	}else if (strpos($ua, 'netfront') !== false){
		$bname = 'NetFront';
		$regexp = '#netfront(?:/| )([0-9\.]+)#';
	}else if (strpos($ua, 'pie') !== false){
		$bname = 'Pocket Internet Explorer';
	}else if (strpos($ua, 'xiino') !== false){
		$bname = 'Xiino';
		$regexp = '#xiino/([0-9\.]+)#';
	}else if (strpos($ua, 'iemobile') !== false){
		$bname = 'Internet Explorer Mobile';
		$regexp = '#iemobile ([0-9\.]+)#';
	}else if (strpos($ua, 'elaine') !== false){
		$bname = 'PalmPilot';
	}else if (strpos($ua, 'msie') !== false){
		$bname = 'Internet Explorer';
		$regexp = '#msie ([0-9\.]+)#';
	}else if (strpos($ua, 'safari') !== false){
		if (strpos($ua, 'mobile') !== false){
			$bname = 'Mobile Safari';
		}else{
			$bname = 'Safari';
		}
		
		$regexp = '#(?:version|safari)/([0-9\.]+)#';
	}else if (strpos($ua, 'wdg_validator') !== false){
		$bname = 'WDG Validator';
		$regexp = '#wdg_validator/([0-9\.]+)#';
	}else if (strpos($ua, 'w3c_validator') !== false){
		$bname = 'W3C Validator';
		$regexp = '#w3c_validator/([0-9\.]+)#';
	}else if (strpos($ua, 'bobby') !== false){
		$bname = 'Bobby (validator)';
		$regexp = '#bobby/([0-9\.]+)#';
	}else if (strpos($ua, 'w3c_css_validator') !== false){
		$bname = 'W3C CSS Validator';
		$regexp = '#w3c_css_validator_jfouffa/([0-9\.]+)#';
	}else if (strpos($ua, 'httpclient') !== false){
		$bname = 'HTTPClient';
		$regexp = '#httpclient/([0-9\.]+)#';
	}
	
	if (isset($regexp)){
		preg_match($regexp, $ua, $version);
	}
	
	$bver = (empty($version[1])) ? 'Unknown' : $version[1];
	
	return array(
		'browser'	=> array(
			'name'		=> $bname,
			'version'	=> $bver
		),
		
		'platform'	=> array(
			'name'		=> $osname,
			'version'	=> $osver
		)
	);
}
Image
User avatar
ta2shop
Posts: 179
Joined: Sat May 07, 2011 9:07 am
Location: madrid, Spain
Contact:

Re: Mobile Browser Identification

Post by ta2shop »

ou my lord thats a big file!! :lol:
Image
User avatar
jacek
Site Admin
Posts: 3262
Joined: Thu May 05, 2011 1:45 pm
Location: UK
Contact:

Re: Mobile Browser Identification

Post by jacek »

ta2shop wrote:ou my lord thats a big file!! :lol:
Exactly, if you have the last browser in the list and the last OS in the list there are about 100 unnecessary if operations.
Image
User avatar
Helx
Posts: 350
Joined: Thu May 17, 2012 6:45 am
Location: Auckland, New Zealand

Re: Mobile Browser Identification

Post by Helx »

jacek wrote:
ta2shop wrote:ou my lord thats a big file!! :lol:
Exactly, if you have the last browser in the list and the last OS in the list there are about 100 unnecessary if operations.
Something I've always wanted to know, having this file wont affect the user, right? Just the server?
bowersbros
Posts: 534
Joined: Thu May 05, 2011 8:19 pm

Re: Mobile Browser Identification

Post by bowersbros »

abcedea wrote:
jacek wrote:
ta2shop wrote:ou my lord thats a big file!! :lol:
Exactly, if you have the last browser in the list and the last OS in the list there are about 100 unnecessary if operations.
Something I've always wanted to know, having this file wont affect the user, right? Just the server?
Unless you do this in the background (ie, not at runtime) then no, it affects the user. Because PHP is interpreted, it runs line by line, so once it gets to this section of the code it has to perform each operation, and the user wont be able to progress until it is done.
I don't like to brag, but I wasn't circumcised. I was circumnavigated. ;)

Want to learn something new? Or maybe reinforce what you already know? Or just help out? Please subscribe to my videos: http://goo.gl/58pN9
User avatar
Helx
Posts: 350
Joined: Thu May 17, 2012 6:45 am
Location: Auckland, New Zealand

Re: Mobile Browser Identification

Post by Helx »

bowersbros wrote:-snip-
Unless you do this in the background (ie, not at runtime) then no, it affects the user. Because PHP is interpreted, it runs line by line, so once it gets to this section of the code it has to perform each operation, and the user wont be able to progress until it is done.
Oh that's not good :<
I suppose it explains why some websites take so long to load...
bowersbros
Posts: 534
Joined: Thu May 05, 2011 8:19 pm

Re: Mobile Browser Identification

Post by bowersbros »

abcedea wrote:
bowersbros wrote:-snip-
Unless you do this in the background (ie, not at runtime) then no, it affects the user. Because PHP is interpreted, it runs line by line, so once it gets to this section of the code it has to perform each operation, and the user wont be able to progress until it is done.
Oh that's not good :<
I suppose it explains why some websites take so long to load...
Most websites don't do this, they instead use responsive design.

But, that could also be down to shit servers too
I don't like to brag, but I wasn't circumcised. I was circumnavigated. ;)

Want to learn something new? Or maybe reinforce what you already know? Or just help out? Please subscribe to my videos: http://goo.gl/58pN9
Post Reply