越简单越好!

获取客户端操作系统

发表于 2007-10-08 15:11 | 110次阅读 0次点赞   PHP

function GetClinetOS(){
$Agent = $_SERVER["HTTP_USER_AGENT"];
$os = '未知';

if (strpos($Agent, 'Win') && strpos($Agent, '95')) { $os = "Windows 95";}
elseif (strpos($Agent,'Win') && ereg($Agent, '98')) { $os = "Windows 98";}
elseif (strpos($Agent,'Win') && strpos($Agent, 'NT 5.0')) { $os = "Windows NT 5.0";}
elseif (strpos($Agent, 'Win') && strpos($Agent, 'NT 5.1')) { $os = "Windows NT 5.1";}
elseif (strpos($Agent, 'Win') && strpos($Agent, 'NT 5.2')) { $os = "Windows NT 5.2";}
elseif (strpos($Agent, 'Win') && strpos($Agent, 'NT')) { $os = "Windows NT";}
elseif (strpos($Agent, 'Win') && strpos($Agent, '32')) { $os = "Windows 32";}
elseif (strpos($Agent, 'Win')) { $os = "Windows";}
elseif (strpos($Agent, 'Linux')) { $os = "Linux";}
elseif (strpos($Agent, 'Unix')) { $os = "Unix";}
elseif (strpos($Agent, 'sun') && strpos($Agent, 'OS')) { $os = "sun";}
elseif (strpos($Agent, 'IBM') && strpos($Agent, 'OS')) { $os = "IBM";}
elseif (strpos($Agent, 'Mac') && strpos($Agent, 'PC')) { $os = "Mac";}
elseif (strpos($Agent, 'PowerPC')) { $os = "PowerPC";}
elseif (strpos($Agent, 'AIX')) { $os = "AIX";}
elseif (strpos($Agent, 'HPUX')) { $os = "HPUX";}
elseif (strpos($Agent, 'NetBSD')) { $os = "NetBSD";}
elseif (strpos($Agent, 'BSD')) { $os = "BSD";}
elseif (strpos($Agent, 'OSF1')) { $os = "OSF1";}
elseif (strpos($Agent, 'IRIX')) { $os = "IRIX";}
elseif (strpos($Agent, 'FreeBSD')) { $os = "FreeBSD";}

return $os;
}

返回顶部 ^