PHP获取操作系统和浏览器信息
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 |
"" ] //以下代码实现从客户端获取IP,操作系统,浏览器的信息 class clientGetObj //类 { function getBrowse() //取浏览器版本函数 { global $_SERVER; if(strpos($_SERVER["HTTP_USER_AGENT"],"MSIE 8.0")) return "Internet Explorer 8.0"; else if(strpos($_SERVER["HTTP_USER_AGENT"],"MSIE 7.0")) return "Internet Explorer 7.0"; else if(strpos($_SERVER["HTTP_USER_AGENT"],"MSIE 6.0")) return "Internet Explorer 6.0"; else if(strpos($_SERVER["HTTP_USER_AGENT"],"Firefox/3")) return "Firefox 3"; else if(strpos($_SERVER["HTTP_USER_AGENT"],"Firefox/2")) return "Firefox 2"; else if(strpos($_SERVER["HTTP_USER_AGENT"],"Chrome")) return "Google Chrome"; else if(strpos($_SERVER["HTTP_USER_AGENT"],"Safari")) return "Safari"; else if(strpos($_SERVER["HTTP_USER_AGENT"],"Opera")) return "Opera"; else return "未知"; } function getIP () //取IP函数 { global $_SERVER; if (getenv('HTTP_CLIENT_IP')) { $ip = getenv('HTTP_CLIENT_IP'); } else if (getenv('HTTP_X_FORWARDED_FOR')) { $ip = getenv('HTTP_X_FORWARDED_FOR'); } else if (getenv('REMOTE_ADDR')) { $ip = getenv('REMOTE_ADDR'); } else { $ip = $_SERVER['REMOTE_ADDR']; } return $ip; } function getOS () //取操作系统类型函数 { global $_SERVER; $agent = $_SERVER['HTTP_USER_AGENT']; $os = false; if (eregi('win', $agent) && strpos($agent, '95')){ $os = 'Windows 95'; } else if (eregi('win 9x', $agent) && strpos($agent, '4.90')){ $os = 'Windows ME'; } else if (eregi('win', $agent) && ereg('98', $agent)){ $os = 'Windows 98'; } else if (eregi('win', $agent) && eregi('nt 5.1', $agent)){ $os = 'Windows XP'; } else if (eregi('win', $agent) && eregi('nt 5', $agent)){ $os = 'Windows 2000'; } else if (eregi('win', $agent) && eregi('nt', $agent)){ $os = 'Windows NT'; } else if (eregi('win', $agent) && ereg('32', $agent)){ $os = 'Windows 32'; } else if (eregi('linux', $agent)){ $os = 'Linux'; } else if (eregi('unix', $agent)){ $os = 'Unix'; } else if (eregi('sun', $agent) && eregi('os', $agent)){ $os = 'SunOS'; } else if (eregi('ibm', $agent) && eregi('os', $agent)){ $os = 'IBM OS/2'; } else if (eregi('Mac', $agent) && eregi('PC', $agent)){ $os = 'Macintosh'; } else if (eregi('PowerPC', $agent)){ $os = 'PowerPC'; } else if (eregi('AIX', $agent)){ $os = 'AIX'; } else if (eregi('HPUX', $agent)){ $os = 'HPUX'; } else if (eregi('NetBSD', $agent)){ $os = 'NetBSD'; } else if (eregi('BSD', $agent)){ $os = 'BSD'; } else if (ereg('OSF1', $agent)){ $os = 'OSF1'; } else if (ereg('IRIX', $agent)){ $os = 'IRIX'; } else if (eregi('FreeBSD', $agent)){ $os = 'FreeBSD'; } else if (eregi('teleport', $agent)){ $os = 'teleport'; } else if (eregi('flashget', $agent)){ $os = 'flashget'; } else if (eregi('webzip', $agent)){ $os = 'webzip'; } else if (eregi('offline', $agent)){ $os = 'offline'; } else { $os = 'Unknown'; } return $os; } } |
分类: 技术