自己已经解决了,引用了贴心查询和首页HOME.PHP里的代码,测试成功,不用改php.nin
将stat.php文件替换为
- <?php
- $navigation.=IP地址查询;
- ///////////////////////////////////////Get IP/////////////////////////////////////
- if(getenv(HTTP_CLIENT_IP))
- {$REMOTE_ADDR = getenv(HTTP_CLIENT_IP);}
- elseif(getenv(HTTP_X_FORWARDED_FOR))
- {$REMOTE_ADDR = getenv(HTTP_X_FORWARDED_FOR);}
- else {$REMOTE_ADDR = getenv("REMOTE_ADDR");}
- $ipaddress=$REMOTE_ADDR;
- $address=ip_check($ipaddress);
- if(!empty($HTTP_REFERER)) $url=$HTTP_REFERER;
- else $url=$PHP_SELF;
- /////////////////////////////////////Browse Info//////////////////////////////////////////
- function browseinfo() {
- $Browsers =array("Lynx","MOSAIC","AOL","Opera","JAVA","MacWeb","WebExplorer","OmniWeb");
- $Agent = $GLOBALS["HTTP_USER_AGENT"];
- for ($i=0; $i<=7; $i++) {
- if (strpos($Agent,$Browsers[$i])) {
- $browser = $Browsers[$i];
- $browserver ="";
- }
- }
- if (ereg("Mozilla",$Agent) && !ereg("MSIE",$Agent)) {
- $temp =explode("(", $Agent); $Part=$temp[0];
- $temp =explode("/", $Part); $browserver=$temp[1];
- $temp =explode(" ",$browserver); $browserver=$temp[0];
- $browserver =preg_replace("/([\d\.]+)/","\\1",$browserver);
- $browserver = " $browserver";
- $browser = "Netscape Navigator";
- }
- if (ereg("Mozilla",$Agent) && ereg("Opera",$Agent)) {
- $temp =explode("(", $Agent); $Part=$temp[1];
- $temp =explode(")", $Part); $browserver=$temp[1];
- $temp =explode(" ",$browserver);$browserver=$temp[2];
- $browserver =preg_replace("/([\d\.]+)/","\\1",$browserver);
- $browserver = " $browserver";
- $browser = "Opera";
- }
- if (ereg("Mozilla",$Agent) && ereg("MSIE",$Agent)) {
- $temp = explode("(", $Agent); $Part=$temp[1];
- $temp = explode(";",$Part); $Part=$temp[1];
- $temp = explode(" ",$Part);$browserver=$temp[2];
- $browserver =preg_replace("/([\d\.]+)/","\\1",$browserver);
- $browserver = " $browserver";
- $browser = "Internet Explorer(IE)";
- }
- if ($browser!="") {
- $browseinfo = "$browser$browserver";
- }
- else {
- $browseinfo = "未知";
- }
- return $browseinfo;
- }
- ///////////////////////////////////OS Info/////////////////////////////////////////
- function osinfo() {
- $os="";
- $Agent = $GLOBALS["HTTP_USER_AGENT"];
- if (eregi('win',$Agent) && strpos($Agent, '95')) {
- $os="Windows 95";
- }
- elseif (eregi('win 9x',$Agent) && strpos($Agent, '4.90')) {
- $os="Windows ME";
- }
- elseif (eregi('win',$Agent) && ereg('98',$Agent)) {
- $os="Windows 98";
- }
- elseif (eregi('win',$Agent) && eregi('nt 5.1',$Agent)) {
- $os="Windows XP";
- }
- elseif (eregi('win',$Agent) && eregi('nt 5',$Agent)) {
- $os="Windows 2000";
- }
- elseif (eregi('win',$Agent) && eregi('nt 5.2',$Agent)) {
- $os="Windows Server 2003";
- }
- elseif (eregi('win',$Agent) && eregi('nt 6.0',$Agent)) {
- $os="Windows Longhorn XP";
- }
- elseif (eregi('win',$Agent) && eregi('nt',$Agent)) {
- $os="Windows NT";
- }
- elseif (eregi('win',$Agent) && ereg('32',$Agent)) {
- $os="Windows 32";
- }
- elseif (eregi('linux',$Agent)) {
- $os="Linux";
- }
- elseif (eregi('unix',$Agent)) {
- $os="Unix";
- }
- elseif (eregi('sun',$Agent) && eregi('os',$Agent)) {
- $os="SunOS";
- }
- elseif (eregi('ibm',$Agent) && eregi('os',$Agent)) {
- $os="IBM OS/2";
- }
- elseif (eregi('Mac',$Agent) && eregi('PC',$Agent)) {
- $os="Macintosh";
- }
- elseif (eregi('PowerPC',$Agent)) {
- $os="PowerPC";
- }
- elseif (eregi('AIX',$Agent)) {
- $os="AIX";
- }
- elseif (eregi('HPUX',$Agent)) {
- $os="HPUX";
- }
- elseif (eregi('NetBSD',$Agent)) {
- $os="NetBSD";
- }
- elseif (eregi('BSD',$Agent)) {
- $os="BSD";
- }
- elseif (ereg('OSF1',$Agent)) {
- $os="OSF1";
- }
- elseif (ereg('IRIX',$Agent)) {
- $os="IRIX";
- }
- elseif (eregi('FreeBSD',$Agent)) {
- $os="FreeBSD";
- }
- if ($os=='') $os = "未知";
- return $os;
- }
- ///////////////////////////////////Ip Check///////////////////////////////////////////////
- function ip_check($ip){
- $datadir = $GLOBALS['discuz_root'].'./ipdata/';
- $ip_detail = explode('.', $ip);
- if(file_exists($datadir.$ip_detail[0].'.txt')) {
- $ip_fdata = fopen($datadir.$ip_detail[0].'.txt', 'r');
- } else {
- if(!($ip_fdata = fopen($datadir.'0.txt', 'r'))) {
- echo 'IP data file error';
- }
- }
- for ($i = 0; $i <= 3; $i++) {
- $ip_detail[$i] = sprintf('%03d', $ip_detail[$i]);
- }
- $ip = join('.', $ip_detail);
- do {
- $ip_data = fgets($ip_fdata, 200);
- $ip_data_detail = explode("|", $ip_data);
- if($ip >= $ip_data_detail[0] && $ip <= $ip_data_detail[1]) {
- fclose($ip_fdata);
- return $ip_data_detail[2].$ip_data_detail[3];
- }
- } while(!feof($ip_fdata));
- fclose($ip_fdata);
- return '未知地址';
- }
- ///////////////////////////////////
- if(strpos($HTTP_SERVER_VARS[HTTP_USER_AGENT], "MSIE 6.0")) {
- $visitor_browser = "Internet Explorer 6.0";
- } elseif(strpos($HTTP_SERVER_VARS[HTTP_USER_AGENT], "MSIE 5.5")) {
- $visitor_browser = "Internet Explorer 5.5";
- } elseif(strpos($HTTP_SERVER_VARS[HTTP_USER_AGENT], "MSIE 5.0")) {
- $visitor_browser = "Internet Explorer 5.0";
- } elseif(strpos($HTTP_SERVER_VARS[HTTP_USER_AGENT], "MSIE 4.01")) {
- $visitor_browser = "Internet Explorer 4.01";
- } elseif(strpos($HTTP_SERVER_VARS[HTTP_USER_AGENT], "NetCaptor")) {
- $visitor_browser = "NetCaptor";
- } elseif(strpos($HTTP_SERVER_VARS[HTTP_USER_AGENT], "Netscape")) {
- $visitor_browser = "Netscape";
- } elseif(strpos($HTTP_SERVER_VARS[HTTP_USER_AGENT], "Lynx")) {
- $visitor_browser = "Lynx";
- } elseif(strpos($HTTP_SERVER_VARS[HTTP_USER_AGENT], "Opera")) {
- $visitor_browser = "Opera";
- } elseif(strpos($HTTP_SERVER_VARS[HTTP_USER_AGENT], "Konqueror")) {
- $visitor_browser = "Konqueror";
- } elseif(strpos($HTTP_SERVER_VARS[HTTP_USER_AGENT], "Mozilla/5.0")) {
- $visitor_browser = "Mozilla";
- } else {
- $visitor_browser = "其它";
- }
- //上面的是浏览器
- if(strpos($HTTP_SERVER_VARS[HTTP_USER_AGENT], "NT 5.1")) {
- $visitor_os = "Windows XP";
- }elseif(strpos($HTTP_SERVER_VARS[HTTP_USER_AGENT], "NT 5")) {
- $visitor_os = "Windows 2000";
- } elseif(strpos($HTTP_SERVER_VARS[HTTP_USER_AGENT], "4.9")) {
- $visitor_os = "Windows ME";
- } elseif(strpos($HTTP_SERVER_VARS[HTTP_USER_AGENT], "NT 4")) {
- $visitor_os = "Windows NT 4.0";
- } elseif(strpos($HTTP_SERVER_VARS[HTTP_USER_AGENT], "98")) {
- $visitor_os = "Windows 98";
- } elseif(strpos($HTTP_SERVER_VARS[HTTP_USER_AGENT], "95")) {
- $visitor_os = "Windows 95";
- } elseif(strpos($HTTP_SERVER_VARS[HTTP_USER_AGENT], "Mac")) {
- $visitor_os = "Mac";
- } elseif(strpos($HTTP_SERVER_VARS[HTTP_USER_AGENT], "Linux")) {
- $visitor_os = "Linux";
- } elseif(strpos($HTTP_SERVER_VARS[HTTP_USER_AGENT], "Unix")) {
- $visitor_os = "Unix";
- } elseif(strpos($HTTP_SERVER_VARS[HTTP_USER_AGENT], "FreeBSD")) {
- $visitor_os = "FreeBSD";
- } elseif(strpos($HTTP_SERVER_VARS[HTTP_USER_AGENT], "SunOS")) {
- $visitor_os = "SunOS";
- } elseif(strpos($HTTP_SERVER_VARS[HTTP_USER_AGENT], "BeOS")) {
- $visitor_os = "BeOS";
- } elseif(strpos($HTTP_SERVER_VARS[HTTP_USER_AGENT], "OS/2")) {
- $visitor_os = "OS/2";
- } elseif(strpos($HTTP_SERVER_VARS[HTTP_USER_AGENT], "PC")) {
- $visitor_os = "Macintosh";
- }elseif(strpos($HTTP_SERVER_VARS[HTTP_USER_AGENT], "AIX")) {
- $visitor_os = "AIX";
- } else {
- $visitor_os = "其他";
- }
-
- //////////////////上面是操作系统
- ?>
复制代码
将index.html文件里的
- 您的<SPAN class=bold>IP:</SPAN>$ipaddress <SPAN class=bold>来自:</SPAN>$address , <SPAN class=bold>操作系统:</SPAN>$os , <SPAN class=bold>浏览器:</SPAN>$browser
复制代码 替换为
- 您的<SPAN class=bold>IP:</SPAN>$onlineip <SPAN class=bold>来自:</SPAN>$address , 操作系统:<font color=blue>$visitor_os</font> 浏览器:<font color=blue>$visitor_browser</font>
复制代码 就行了,演示http://jixian.yi.org/bbs/index.php |