Backend Development

PHP Browser Information

Submitted by Nobody, , Thread ID: 50516

Thread Closed
10-10-2017, 05:20 PM
#1
Function to retrieve browser information.




function browser_al($useragent = '')
{
if ($useragent == '')
{
$useragent = $_SERVER['HTTP_USER_AGENT'];
}
$browser_name = '';
$browsers = array();

$browsers[] = array('name' => 'AmigaVoyager', 'useragent' => 'AmigaVoyager');
$browsers[] = array('name' => 'Apple Generic', 'useragent' => 'CFNetwork');

RE: PHP Browser Information

#2
function browser_al($useragent = '')
{
if ($useragent == '')
{
$useragent = $_SERVER['HTTP_USER_AGENT'];
}
$browser_name = '';
$browsers = array();

$browsers[] = array('name' => 'AmigaVoyager', 'useragent' => 'AmigaVoyager');
$browsers[] = array('name' => 'Apple Generic', 'useragent' => 'CFNetwork');
$browsers[] = array('name' => 'Camino', 'useragent' => 'Camino');
$browsers[] = array('name' => 'Ensemble2', 'useragent' => 'Ensemble2');
$browsers[] = array('name' => 'Epiphany', 'useragent' => 'Epiphany');
$browsers[] = array('name' => 'firefox', 'useragent' => 'Firefox');
$browsers[] = array('name' => 'firefox', 'useragent' => 'Firefox/1.0');
$browsers[] = array('name' => 'firefox', 'useragent' => 'Firefox/1.5');
$browsers[] = array('name' => 'firefox', 'useragent' => 'BonEcho');
$browsers[] = array('name' => 'firefox', 'useragent' => 'Firefox/2');
$browsers[] = array('name' => 'firefox', 'useragent' => 'Firefox/3');
$browsers[] = array('name' => 'firefox', 'useragent' => 'GranParadiso');
$browsers[] = array('name' => 'firefox', 'useragent' => 'Phoenix');
$browsers[] = array('name' => 'firefox', 'useragent' => 'Firebird');
$browsers[] = array('name' => 'Galeon', 'useragent' => 'Galeon');
$browsers[] = array('name' => 'Google Chrome', 'useragent' => 'chrome');
$browsers[] = array('name' => 'iCab', 'useragent' => 'iCab');
$browsers[] = array('name' => 'Iceweasel', 'useragent' => 'Iceweasel');
$browsers[] = array('name' => 'ie', 'useragent' => 'MSIE');
$browsers[] = array('name' => 'ie', 'useragent' => 'MSIE5.');
$browsers[] = array('name' => 'ie', 'useragent' => 'MSIE6.');
$browsers[] = array('name' => 'ie', 'useragent' => 'MSIE7.');
$browsers[] = array('name' => 'ie', 'useragent' => 'MSIE8.');
$browsers[] = array('name' => 'K-Meleon', 'useragent' => 'K-Meleon');
$browsers[] = array('name' => 'Konqueror', 'useragent' => 'Konqueror');
$browsers[] = array('name' => 'Lynx', 'useragent' => 'Lynx');
$browsers[] = array('name' => 'Mozilla Minefield', 'useragent' => 'Minefield');
$browsers[] = array('name' => 'Netscape', 'useragent' => 'Netscape');
$browsers[] = array('name' => 'NewsCopier', 'useragent' => 'NewsCopier');
$browsers[] = array('name' => 'opera', 'useragent' => 'Opera');
$browsers[] = array('name' => 'Pocket Internet Explorer', 'useragent' => 'MicrosoftPocketInternetExplorer');
$browsers[] = array('name' => 'Pocket Internet Explorer', 'useragent' => 'MSPIE');
$browsers[] = array('name' => 'Radianrss', 'useragent' => 'radianrss');
$browsers[] = array('name' => 'RssReader', 'useragent' => 'rssreader.com');
$browsers[] = array('name' => 'Safari', 'useragent' => 'AppleSyndication');
$browsers[] = array('name' => 'Safari', 'useragent' => 'Safari');
$browsers[] = array('name' => 'SeaMonkey', 'useragent' => 'SeaMonkey');
$browsers[] = array('name' => 'Swiftweasel', 'useragent' => 'Swiftweasel');
$browsers[] = array('name' => 'Thunderbird', 'useragent' => 'Thunderbird');
$browsers[] = array('name' => 'Vienna', 'useragent' => 'Vienna');

foreach ($browsers as $browser)
{
if (stripos(strtolower($useragent), strtolower($browser['useragent'])) !== FALSE)
{
$browser_name = $browser['name'];
}
}
unset($browsers, $browser, $useragent);

if ($browser_name)
{
return $browser_name;
}
else
{
return false;
}
}

Users browsing this thread: 1 Guest(s)