<?php require_once('Connections/config.php'); ?>
<?php
function 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;
}
?>
<?php
if (!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>
<?php
mysql_free_result($ip_dir);
?>
不知那里错了,现在不显示信息MySQLPHP函数检测

解决方案 »

  1.   

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

  2.   

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

  3.   

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

  4.   

    SELECT * FROM ip_manag WHERE address = '-1'?????