获取浏览器和操作系统的函数
-------------------------------------
// Return visitor's browser
function return_browser()
{
$agent = $_SERVER["HTTP_USER_AGENT"]; if (preg_match('/Firefox/i',$agent)) {
$browser="Firefox";
} elseif (preg_match('/Netscape/i',$agent)) {
$browser="Netscape";
} elseif (preg_match('/NetCaptor/i',$agent)) {// MSIE
$browser="NetCaptor";
} elseif (preg_match('/MSN/i',$agent)) {// MSIE
$browser="MSN Explorer";
} elseif (preg_match('/Opera/i',$agent)) {// MSIE
$browser="Opera";
} elseif (preg_match('/AOL/i',$agent)) {
$browser="AOL";
} elseif (preg_match('/JAVA/i',$agent)) {
$browser="JAVA";
} elseif (preg_match('/MacWeb/i',$agent)) {
$browser="MacWeb";
} elseif (preg_match("/MSIE/i", $agent)) {
$str = explode(";",$agent);
$str = $str['1'];
$str = explode(" ",$str);
$browser_ver = $str['2'];
if ($browser_ver == "6.0") {
$browser = "IE6";
} else {
$browser = "IE5";
}
} else {
$browser = "Other";
}
return trim($browser);
}
// Return visitor's OS
function return_os()
{
$agent = $_SERVER["HTTP_USER_AGENT"]; if (preg_match('/Win/i', $agent) && preg_match('/NT 5.2/i', $agent)) {// Windows 2003
$os = "Win2003";
} elseif (preg_match('/Win/i', $agent) && preg_match('/NT 5.1/i', $agent)) {// Windows XP
$os = "WinXP";
} elseif (preg_match('/Win/i', $agent) && preg_match('/NT 5.0/i', $agent)) {// Windows 2000
$os = "Win2000";
} elseif (preg_match('/Win/i', $agent) && preg_match('/NT/i', $agent)) {// Windows NT
$os = "Win2000";
} elseif (preg_match('/Win/i', $agent) && preg_match('/4.90/i', $agent)) {// Windows ME
$os = "Win9X";
} elseif (preg_match('/Win/i', $agent) && preg_match('/98/i', $agent)) {// Windows 98
$os = "Win9X";
} elseif (preg_match('/Win/i', $agent) && preg_match('/95/i', $agent)) {// Windows 95
$os = "Win9X";
} elseif (preg_match('/Win/i', $agent) && preg_match('/32/i', $agent)) {// Windows 32
$os = "Win9X";
} elseif (preg_match('/Linux/i', $agent)) {// linux
$os = "Linux";
} elseif (preg_match('/BSD/i', $agent)) {// *BSD
$os = "Unix";
} elseif (preg_match('/Unix/i', $agent)) {// Unix
$os = "Unix";
} elseif (preg_match('/Sun/i', $agent)) {// SunOS
$os = "SunOS";
} elseif (preg_match('/Mac/i', $agent)) {// Macintosh
$os = "Macintosh";
} elseif (preg_match('/IBM/i', $agent)) {// IBMOS
$os = "IBMOS";
} else {// Other
$os = "Other";
}
return trim($os);
}
-------------------------------------
-------------------------------------
// Return visitor's browser
function return_browser()
{
$agent = $_SERVER["HTTP_USER_AGENT"]; if (preg_match('/Firefox/i',$agent)) {
$browser="Firefox";
} elseif (preg_match('/Netscape/i',$agent)) {
$browser="Netscape";
} elseif (preg_match('/NetCaptor/i',$agent)) {// MSIE
$browser="NetCaptor";
} elseif (preg_match('/MSN/i',$agent)) {// MSIE
$browser="MSN Explorer";
} elseif (preg_match('/Opera/i',$agent)) {// MSIE
$browser="Opera";
} elseif (preg_match('/AOL/i',$agent)) {
$browser="AOL";
} elseif (preg_match('/JAVA/i',$agent)) {
$browser="JAVA";
} elseif (preg_match('/MacWeb/i',$agent)) {
$browser="MacWeb";
} elseif (preg_match("/MSIE/i", $agent)) {
$str = explode(";",$agent);
$str = $str['1'];
$str = explode(" ",$str);
$browser_ver = $str['2'];
if ($browser_ver == "6.0") {
$browser = "IE6";
} else {
$browser = "IE5";
}
} else {
$browser = "Other";
}
return trim($browser);
}
// Return visitor's OS
function return_os()
{
$agent = $_SERVER["HTTP_USER_AGENT"]; if (preg_match('/Win/i', $agent) && preg_match('/NT 5.2/i', $agent)) {// Windows 2003
$os = "Win2003";
} elseif (preg_match('/Win/i', $agent) && preg_match('/NT 5.1/i', $agent)) {// Windows XP
$os = "WinXP";
} elseif (preg_match('/Win/i', $agent) && preg_match('/NT 5.0/i', $agent)) {// Windows 2000
$os = "Win2000";
} elseif (preg_match('/Win/i', $agent) && preg_match('/NT/i', $agent)) {// Windows NT
$os = "Win2000";
} elseif (preg_match('/Win/i', $agent) && preg_match('/4.90/i', $agent)) {// Windows ME
$os = "Win9X";
} elseif (preg_match('/Win/i', $agent) && preg_match('/98/i', $agent)) {// Windows 98
$os = "Win9X";
} elseif (preg_match('/Win/i', $agent) && preg_match('/95/i', $agent)) {// Windows 95
$os = "Win9X";
} elseif (preg_match('/Win/i', $agent) && preg_match('/32/i', $agent)) {// Windows 32
$os = "Win9X";
} elseif (preg_match('/Linux/i', $agent)) {// linux
$os = "Linux";
} elseif (preg_match('/BSD/i', $agent)) {// *BSD
$os = "Unix";
} elseif (preg_match('/Unix/i', $agent)) {// Unix
$os = "Unix";
} elseif (preg_match('/Sun/i', $agent)) {// SunOS
$os = "SunOS";
} elseif (preg_match('/Mac/i', $agent)) {// Macintosh
$os = "Macintosh";
} elseif (preg_match('/IBM/i', $agent)) {// IBMOS
$os = "IBMOS";
} else {// Other
$os = "Other";
}
return trim($os);
}
-------------------------------------
怒放的生命 多谢多谢了 我想要的就是这个
高手!!!!