Revision: 6243
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at May 12, 2008 06:59 by xuanyan
Initial Code
function get_os_browser($ua)
{
$low_ua = strtolower($ua);
if (strpos($low_ua,'maxthon') !== false)
{
preg_match('/maxthon[^\)|\(|\;]*/i',$ua,$match);
}
elseif (strpos($low_ua,'tencenttraveler') !== false)
{
preg_match('/tencenttraveler[^\)|\(|\;]*/i',$ua,$match);
}
elseif (strpos($low_ua,'msie') !== false)
{
preg_match('/msie[^\)|\(|\;]*/i',$ua,$match);
}
elseif (strpos($low_ua,'camino') !== false)
{
preg_match('/camino[^\)|\(|\;]*/i',$ua,$match);
}
elseif (strpos($low_ua,'opera') !== false)
{
preg_match('/opera[^\)|\(|\;]*/i',$ua,$match);
}
elseif (strpos($low_ua,'navigator') !== false)
{
preg_match('/navigator[^\)|\(|\;]*/i',$ua,$match);
}
elseif (strpos($low_ua,'firefox') !== false)
{
preg_match('/firefox[^\)|\(|\;]*/i',$ua,$match);
}
elseif (strpos($low_ua,'safari') !== false)
{
preg_match('/safari[^\)|\(|\;]*/i',$ua,$match);
}
else
{
$match[] = substr($ua,strrpos($ua,' '));
}
$browser = trim($match[0]);
if (strpos($low_ua,'windows') !== false)
{
preg_match('/([^;]*windows[^;]+);/i',$ua,$match);
$rep = array(
'Windows NT 5.0' => 'Windows 2000',
'Windows NT 5.1' => 'Windows XP',
'Windows NT 5.2' => 'Windows 2003',
'Windows NT 6.0' => 'Windows Vista',
);
$match[1] = strtr($match[1], $rep);
}
elseif (strpos($low_ua,'iphone') !== false)
{
preg_match('/([^;(]*iphone[^;]*);/i',$ua,$match);
}
elseif (strpos($low_ua,'mac os') !== false)
{
preg_match('/([^;]*macs[^;]+);/i',$ua,$match);
}
else
{
$agent = substr($ua,strpos($ua,'(')+1,strpos($ua,')')-strpos($ua,'(')-1);
$info = explode(';', $agent);
$match[1] = isset($info[2]) ? trim($info[2]) : 'unknow';
}
$os = trim($match[1]);
return array($os,$browser);
}
Initial URL
Initial Description
Initial Title
get_os_browswer_by_ua
Initial Tags
textmate
Initial Language
Other