获得客户浏览器与操作系统信息
时间:2008-04-03 来源:liuxingyuyuni
?php
/**
* @company xingquan
* @auther BianJiang
* @date Thu Apr 03 14:01:36 CST 2008
* @copyright Shen Yang Xing Quan
* @todo 获得客户浏览器,操作系统,IP地址信息
* @version 0.1
*/
function getClientInfo() {
$agent = $_SERVER['HTTP_USER_AGENT'];
// Get client explorer info
if(strpos($agent, 'MSIE 7.0')!==FALSE) $explorer = 'IE 7';
elseif(strpos($agent, 'MSIE 6.0')!==FALSE) $explorer = 'IE6';
elseif(strpos($agent, 'Firefox') !==FALSE) $explorer = 'Firefox';
elseif(strpos($agent, 'Opera') !==FALSE) $explorer = 'Opera';
elseif(strpos($agent, 'Netscape')!==FALSE) $explorer = 'Netscape';
elseif(strpos($agent, 'MAXTHON') !==FALSE) $explorer = 'Maxthon';
elseif(strpos($agent, 'Safari') !==FALSE) $explorer = 'Safari';
elseif(strpos($agent, "Firebird")!==FALSE) $explorer = "Firebird";
else $explorer = 'Unknow';
// Get client system info
if(strpos($agent, 'Windows NT 5.0') !== FALSE) $os = 'Windows 2000';
elseif(strpos($agent, 'Windows NT 5.1') !== FALSE) $os= 'Windows XP';
elseif(strpos($agent, 'Windows NT 5.2') !== FALSE) $os= 'Windows 2003';
elseif(strpos($agent, 'Windows NT 6.0') !== FALSE) $os= 'Windows Vista';
elseif(strpos($agent, 'Windows NT') !== FALSE) $os= 'Windows NT';
elseif(strpos($agent, 'Windows 98') !== FALSE) $os= 'Windows 98';
elseif(strpos($agent, 'unix') !== FALSE) $os= 'Unix';
elseif(strpos($agent, 'linux')!== FALSE) $os= 'Linux';
elseif(strpos($agent, 'SunOS')!== FALSE) $os= 'SunOS';
elseif(strpos($agent, 'BSD')!== FALSE) $os= 'FreeBSD';
elseif(strpos($agent, 'Mac')!== FALSE) $os= 'Mac';
else $os = 'Unknow';
// Get client ip addr
if(isset($_SERVER['HTTP_CLIENT_IP'])) $ip = $_SERVER['HTTP_CLIENT_IP'];
elseif(isset($_SERVER['HTTP_X_FORWARDED_FOR'])) $ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
elseif(isset($_SERVER['REMOTE_ADDR'])) $ip = $_SERVER['REMOTE_ADDR'];
else $ip = 'Unknow';
return array(
'explorer' => $explorer,
'system' => $os,
'ip' => $ip
);
}
print_r(getClientInfo());
?>
相关阅读 更多 +
排行榜 更多 +