爱程序网

【转】php判断操作系统或浏览器

来源: 阅读:

  1 function userOS($user_OSagent=''){  2     if(strpos($user_OSagent,"NT 6.1")) {  3         $visitor_os = "Windows7";  4     }elseif(preg_match('/NT 5.1/',$user_OSagent)){  5         $visitor_os = "Windows XP (SP2)";  6     }elseif(strpos($user_OSagent,"Windows XP")) {  7         $visitor_os = "Windows XP";  8     }elseif(strpos($user_OSagent,"NT 5.2") && strpos($user_OSagent,"WOW64")){  9         $visitor_os = "Windows XP 64-bit Edition"; 10     }elseif(strpos($user_OSagent,"NT 5.2")) { 11         $visitor_os = "Windows 2003"; 12     }elseif(strpos($user_OSagent,"NT 6.0")) { 13         $visitor_os = "Windows Vista"; 14     }elseif(strpos($user_OSagent,"NT 5.0")) { 15         $visitor_os = "Windows 2000"; 16     }elseif(strpos($user_OSagent,"4.9")) { 17         $visitor_os = "Windows ME"; 18     }elseif(strpos($user_OSagent,"NT 4")) { 19         $visitor_os = "Windows NT 4.0"; 20     }elseif(strpos($user_OSagent,"98")) { 21         $visitor_os = "Windows 98"; 22     }elseif(strpos($user_OSagent,"95")) { 23         $visitor_os = "Windows 95"; 24     }elseif(strpos($user_OSagent,"NT 9.0")) { 25         $visitor_os = "Windows NT 9.0"; 26     }elseif(strpos($user_OSagent,"Mac")) { 27         $visitor_os = "Mac"; 28     }elseif(strpos($user_OSagent,"Linux")) { 29         $visitor_os = "Linux"; 30     }elseif(strpos($user_OSagent,"Unix")) { 31         $visitor_os = "Unix"; 32     }elseif(strpos($user_OSagent,"FreeBSD")) { 33         $visitor_os = "FreeBSD"; 34     }elseif(strpos($user_OSagent,"SunOS")) { 35         $visitor_os = "SunOS"; 36     }elseif(strpos($user_OSagent,"BeOS")) { 37         $visitor_os = "BeOS"; 38     }elseif(strpos($user_OSagent,"OS/2")) { 39         $visitor_os = "OS/2"; 40     }elseif(strpos($user_OSagent,"PC")) { 41         $visitor_os = "Macintosh"; 42     }elseif(strpos($user_OSagent,"AIX")) { 43         $visitor_os = "AIX"; 44     }elseif(strpos($user_OSagent,"IBM OS/2")) { 45         $visitor_os = "IBM OS/2"; 46     }elseif(strpos($user_OSagent,"BSD")) { 47         $visitor_os = "BSD"; 48     }elseif(strpos($user_OSagent,"NetBSD")) { 49         $visitor_os = "NetBSD"; 50     }elseif(preg_match('/Apple/i',$user_OSagent)) { 51         $visitor_os = "Applepc"; 52     }elseif(strpos($user_OSagent,"NT 6.1")) { 53         $visitor_os = "Windows7"; 54     }elseif(preg_match('/Opera/i',$user_OSagent)) { 55         $visitor_os = "Opera"; 56     }elseif(preg_match('/Nokia/i', $user_OSagent)) { 57         $visitor_os = "nokia"; 58     }elseif(preg_match('/OPPO/i', $user_OSagent)) { 59         $visitor_os = "OPPO "; 60     }elseif(preg_match('/SymbianOS/i', $user_OSagent)) { 61         $visitor_os = "SymbianOS "; 62     }elseif(preg_match('/Windows Mobile/i', $user_OSagent)) { 63         $visitor_os = "Windows Mobile"; 64     }elseif(preg_match('/DoCoMo/i',$user_OSagent)){ 65         $visitor_os = "DoCoMo"; 66     }elseif(strpos($user_OSagent,"Red Hat")) { 67         $visitor_os = "linux"; 68     }elseif(preg_match('/SonyEricsson/i',$user_OSagent)) { 69         $visitor_os = "SonyEricsson"; 70     }elseif(preg_match('/Lynx/i',$user_OSagent)) { 71         $visitor_os = "Lynx"; 72     }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)) { 73         $visitor_os = "mobile"; 74     }else{ 75         $visitor_os =$user_OSagent; 76     } 77     return $visitor_os; 78 } 79  80 function userBrowser($user_OSagent){ 81     if(strpos($user_OSagent,"Maxthon") && strpos($user_OSagent,"MSIE")) { 82         $visitor_browser ="Maxthon(Microsoft IE)"; 83     }elseif(strpos($user_OSagent,"Maxthon 2.0")) { 84         $visitor_browser ="Maxthon 2.0"; 85     }elseif(strpos($user_OSagent,"Maxthon")) { 86         $visitor_browser ="Maxthon"; 87     }elseif(strpos($user_OSagent,"MSIE 7.0")) { 88         $visitor_browser ="IE7"; 89     }elseif(strpos($user_OSagent,"MSIE 6.0")) { 90         $visitor_browser ="IE6"; 91     }elseif(strpos($user_OSagent,"MSIE 5.5")) { 92         $visitor_browser ="IE5"; 93     }elseif(strpos($user_OSagent,"MSIE 5.0")) { 94         $visitor_browser ="IE5"; 95     }elseif(strpos($user_OSagent,"MSIE 4.01")) { 96         $visitor_browser ="IE4"; 97     }elseif(strpos($user_OSagent,"MSIE 8.0")) { 98         $visitor_browser ="IE8"; 99     }elseif(strpos($user_OSagent,"MSIE 9.0")) {100         $visitor_browser ="IE9";101     }elseif(strpos($user_OSagent,"NetCaptor")) {102         $visitor_browser ="NetCaptor";103     }elseif(strpos($user_OSagent,"Netscape")) {104         $visitor_browser ="Netscape";105     }elseif(strpos($user_OSagent,"Lynx")) {106         $visitor_browser ="Lynx";107     }elseif(strpos($user_OSagent,"Opera")) {108         $visitor_browser ="Opera";109     }elseif(strpos($user_OSagent,"Konqueror")) {110         $visitor_browser ="Konqueror";111     }elseif(strpos($user_OSagent,"Mozilla/5.0")) {112         $visitor_browser ="Mozilla";113     }elseif(preg_match('/ucweb/i', $user_OSagent)) {114         $visitor_browser ="ucweb";115     }elseif(preg_match('/Opera/i', $user_OSagent)) {116         $visitor_browser ="Opera";117     }elseif(preg_match('/SonyEricsson/i', $user_OSagent)) {118         $visitor_browser ="SonyEricsson";119     }elseif(preg_match('/Apple/i',$user_OSagent)) {120         $visitor_browser ="Apple";121     }elseif(preg_match('/OPPO/i',$user_OSagent)) {122         $visitor_browser ="OPPO";123     }elseif(strpos($user_OSagent,"i60")) {124         $visitor_browser ="lenovo i60";125     }elseif(preg_match('/Nokia/i', $user_OSagent)) {126         $visitor_browser ="nokia";127     }elseif(strpos($user_OSagent,"LG-MMS")) {128         $visitor_browser ="LG-BROWSER";129     }elseif(strpos($user_OSagent,"SMIT-BROWSER")) {130         $visitor_browser ="SMIT-BROWSER";131     }elseif(preg_match('/zet/i', $user_OSagent)) {132         $visitor_browser ='ZET-BROWSER';133     }elseif(preg_match('/Lynx/i', $user_OSagent)) {134         $visitor_browser ='Lynx';135     }elseif(strpos($user_OSagent,"Firefox")) {136         $visitor_browser ="Firefox";137     }elseif(strpos($user_OSagent,"U")) {138         $visitor_browser ="Firefox";139     }else {140         $visitor_browser ="$user_OSagent";141     }142     return $visitor_browser;143 }

相关文章列表: