那一抹温暖的阳光,是我们永恒的向往。
www.webbar.cn

php判断操作系统或浏览器

11

function userOS($user_OSagent=”){
if(strpos($user_OSagent,”NT 6.1″)) {
$visitor_os = “Windows7″;
}elseif(preg_match(‘/NT 5.1/’,$user_OSagent)){
$visitor_os = “Windows XP (SP2)”;
}elseif(strpos($user_OSagent,”Windows XP”)) {
$visitor_os = “Windows XP”;
}elseif(strpos($user_OSagent,”NT 5.2″) && strpos($user_OSagent,”WOW64″)){
$visitor_os = “Windows XP 64-bit Edition”;
}elseif(strpos($user_OSagent,”NT 5.2″)) {
$visitor_os = “Windows 2003″;
}elseif(strpos($user_OSagent,”NT 6.0″)) {
$visitor_os = “Windows Vista”;
}elseif(strpos($user_OSagent,”NT 5.0″)) {
$visitor_os = “Windows 2000″;
}elseif(strpos($user_OSagent,”4.9″)) {
$visitor_os = “Windows ME”;
}elseif(strpos($user_OSagent,”NT 4″)) {
$visitor_os = “Windows NT 4.0″;
}elseif(strpos($user_OSagent,”98″)) {
$visitor_os = “Windows 98″;
}elseif(strpos($user_OSagent,”95″)) {
$visitor_os = “Windows 95″;
}elseif(strpos($user_OSagent,”NT 9.0″)) {
$visitor_os = “Windows NT 9.0″;
}elseif(strpos($user_OSagent,”Mac”)) {
$visitor_os = “Mac”;
}elseif(strpos($user_OSagent,”Linux”)) {
$visitor_os = “Linux”;
}elseif(strpos($user_OSagent,”Unix”)) {
$visitor_os = “Unix”;
}elseif(strpos($user_OSagent,”FreeBSD”)) {
$visitor_os = “FreeBSD”;
}elseif(strpos($user_OSagent,”SunOS”)) {
$visitor_os = “SunOS”;
}elseif(strpos($user_OSagent,”BeOS”)) {
$visitor_os = “BeOS”;
}elseif(strpos($user_OSagent,”OS/2″)) {
$visitor_os = “OS/2″;
}elseif(strpos($user_OSagent,”PC”)) {
$visitor_os = “Macintosh”;
}elseif(strpos($user_OSagent,”AIX”)) {
$visitor_os = “AIX”;
}elseif(strpos($user_OSagent,”IBM OS/2″)) {
$visitor_os = “IBM OS/2″;
}elseif(strpos($user_OSagent,”BSD”)) {
$visitor_os = “BSD”;
}elseif(strpos($user_OSagent,”NetBSD”)) {
$visitor_os = “NetBSD”;
}elseif(preg_match(‘/Apple/i’,$user_OSagent)) {
$visitor_os = “Applepc”;
}elseif(strpos($user_OSagent,”NT 6.1″)) {
$visitor_os = “Windows7″;
}elseif(preg_match(‘/Opera/i’,$user_OSagent)) {
$visitor_os = “Opera”;
}elseif(preg_match(‘/Nokia/i’, $user_OSagent)) {
$visitor_os = “nokia”;
}elseif(preg_match(‘/OPPO/i’, $user_OSagent)) {
$visitor_os = “OPPO “;
}elseif(preg_match(‘/SymbianOS/i’, $user_OSagent)) {
$visitor_os = “SymbianOS “;
}elseif(preg_match(‘/Windows Mobile/i’, $user_OSagent)) {
$visitor_os = “Windows Mobile”;
}elseif(preg_match(‘/DoCoMo/i’,$user_OSagent)){
$visitor_os = “DoCoMo”;
}elseif(strpos($user_OSagent,”Red Hat”)) {
$visitor_os = “linux”;
}elseif(preg_match(‘/SonyEricsson/i’,$user_OSagent)) {
$visitor_os = “SonyEricsson”;
}elseif(preg_match(‘/Lynx/i’,$user_OSagent)) {
$visitor_os = “Lynx”;
}elseif(preg_match(‘/ucweb|MQQBrowser|J2ME|IUC|3GW100|LG-MMS|i60|Motorola|MAUI|m9|ME860|maui|C8500|gt|k-touch|X8|htc|GT-S5660|UNTRUSTED|SCH|tianyu|lenovo|SAMSUNG/i’,$user_OSagent)) {
$visitor_os = “mobile”;
}else{
$visitor_os =$user_OSagent;
}
return $visitor_os;
}

function userBrowser($user_OSagent){
if(strpos($user_OSagent,”Maxthon”) && strpos($user_OSagent,”MSIE”)) {
$visitor_browser =”Maxthon(Microsoft IE)”;
}elseif(strpos($user_OSagent,”Maxthon 2.0″)) {
$visitor_browser =”Maxthon 2.0″;
}elseif(strpos($user_OSagent,”Maxthon”)) {
$visitor_browser =”Maxthon”;
}elseif(strpos($user_OSagent,”MSIE 7.0″)) {
$visitor_browser =”IE7″;
}elseif(strpos($user_OSagent,”MSIE 6.0″)) {
$visitor_browser =”IE6″;
}elseif(strpos($user_OSagent,”MSIE 5.5″)) {
$visitor_browser =”IE5″;
}elseif(strpos($user_OSagent,”MSIE 5.0″)) {
$visitor_browser =”IE5″;
}elseif(strpos($user_OSagent,”MSIE 4.01″)) {
$visitor_browser =”IE4″;
}elseif(strpos($user_OSagent,”MSIE 8.0″)) {
$visitor_browser =”IE8″;
}elseif(strpos($user_OSagent,”MSIE 9.0″)) {
$visitor_browser =”IE9″;
}elseif(strpos($user_OSagent,”NetCaptor”)) {
$visitor_browser =”NetCaptor”;
}elseif(strpos($user_OSagent,”Netscape”)) {
$visitor_browser =”Netscape”;
}elseif(strpos($user_OSagent,”Lynx”)) {
$visitor_browser =”Lynx”;
}elseif(strpos($user_OSagent,”Opera”)) {
$visitor_browser =”Opera”;
}elseif(strpos($user_OSagent,”Konqueror”)) {
$visitor_browser =”Konqueror”;
}elseif(strpos($user_OSagent,”Mozilla/5.0″)) {
$visitor_browser =”Mozilla”;
}elseif(preg_match(‘/ucweb/i’, $user_OSagent)) {
$visitor_browser =”ucweb”;
}elseif(preg_match(‘/Opera/i’, $user_OSagent)) {
$visitor_browser =”Opera”;
}elseif(preg_match(‘/SonyEricsson/i’, $user_OSagent)) {
$visitor_browser =”SonyEricsson”;
}elseif(preg_match(‘/Apple/i’,$user_OSagent)) {
$visitor_browser =”Apple”;
}elseif(preg_match(‘/OPPO/i’,$user_OSagent)) {
$visitor_browser =”OPPO”;
}elseif(strpos($user_OSagent,”i60″)) {
$visitor_browser =”lenovo i60″;
}elseif(preg_match(‘/Nokia/i’, $user_OSagent)) {
$visitor_browser =”nokia”;
}elseif(strpos($user_OSagent,”LG-MMS”)) {
$visitor_browser =”LG-BROWSER”;
}elseif(strpos($user_OSagent,”SMIT-BROWSER”)) {
$visitor_browser =”SMIT-BROWSER”;
}elseif(preg_match(‘/zet/i’, $user_OSagent)) {
$visitor_browser =’ZET-BROWSER';
}elseif(preg_match(‘/Lynx/i’, $user_OSagent)) {
$visitor_browser =’Lynx';
}elseif(strpos($user_OSagent,”Firefox”)) {
$visitor_browser =”Firefox”;
}elseif(strpos($user_OSagent,”U”)) {
$visitor_browser =”Firefox”;
}else {
$visitor_browser =”$user_OSagent”;
}
return $visitor_browser;
}

时间:2013-10-09
分类:PHP , 编程语言

Comments are closed.

Search