Home >Backend Development >PHP Tutorial >检测系统IP地址显示使用人信息

检测系统IP地址显示使用人信息

WBOY
WBOYOriginal
2016-06-23 14:06:43914browse

<?php require_once('Connections/config.php'); ?><?phpfunction GetIP(){if(!empty($_SERVER["HTTP_CLIENT_IP"]))  $cip = $_SERVER["HTTP_CLIENT_IP"];else if(!empty($_SERVER["HTTP_X_FORWARDED_FOR"]))  $cip = $_SERVER["HTTP_X_FORWARDED_FOR"];else if(!empty($_SERVER["REMOTE_ADDR"]))  $cip = $_SERVER["REMOTE_ADDR"];else  $cip = "无法获取!";return $cip;}?><?phpif (!function_exists("GetSQLValueString")) {function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") {  if (PHP_VERSION < 6) {    $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;  }  $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);  switch ($theType) {    case "text":      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";      break;        case "long":    case "int":      $theValue = ($theValue != "") ? intval($theValue) : "NULL";      break;    case "double":      $theValue = ($theValue != "") ? doubleval($theValue) : "NULL";      break;    case "date":      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";      break;    case "defined":      $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;      break;  }  return $theValue;}}$colname_ip_dir = "-1";if (isset($_GET['GetIP()'])) {  $colname_ip_dir = $_GET['GetIP()'];}mysql_select_db($database_config, $config);$query_ip_dir = sprintf("SELECT * FROM ip_manag WHERE address = %s", GetSQLValueString($colname_ip_dir, "text"));$ip_dir = mysql_query($query_ip_dir, $config) or die(mysql_error());$row_ip_dir = mysql_fetch_assoc($ip_dir);$totalRows_ip_dir = mysql_num_rows($ip_dir);?><HTML><HEAD><title>检测操作系统和浏览器类型</title><meta http-equiv="Content-Type" content="text/html; charset=gbk" /></HEAD><body><table width="200" border="1" align="center" cellpadding="0" cellspacing="0">  <tr>    <td>机构部门</td>    <td>IP地址</td>    <td>使用人</td>  </tr>  <tr>    <td><?php echo $row_ip_dir['agency']; ?></td>    <td><?php echo $row_ip_dir['address']; ?></td>    <td><?php echo $row_ip_dir['name']; ?></td>  </tr></table></bady></html><?phpmysql_free_result($ip_dir);?>


不知那里错了,现在不显示信息


回复讨论(解决方案)

你是想获取访问者的ip吗?

是的,获取访问者的IP地址并显示查找数据库,如有IP信息,显示使用人信息,如没有显示未收录。

你可以echo $query_ip_dir ;看看sql是什么。应该是没有那条记录吧。

鉴于 HTTP_CLIENT_IP 和 HTTP_X_FORWARDED_FOR 都是可以伪造的
你的程序并无实际意义

SELECT * FROM ip_manag WHERE address = '-1'

?????

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn