临时写了一个做跳转的程序,能运行,帮我看看有没有漏洞,有没有不合理的地方,谢谢。
<?php
$db=mssql_connect("192.168.0.7","sa","****") or die ("无法连接Sql Sever数据库!");
mssql_select_db("sub") or die ("无法打开数据据库!");
$ip=$_SERVER['REMOTE_ADDR'];
$ipArr = explode(".", $ip);
$ipTwoBlock=$ipArr[0].".".$ipArr[1];
$ipThreeBlock=$ipArr[0].".".$ipArr[1].".".$ipArr[2];
$sql="select count(*) as num from ip where ip='".$ipTwoBlock."' or ip='".$ipThreeBlock."'";
$query=mssql_query($sql,$db);
$rs=mssql_fetch_array($query);
if($rs["num"]!=0)
{
header("Location:http://open.fudan.edu.cn/index.php");
}
else
{
header("Location:http://open.fudan.org.cn/index.php");
}
DBClose($db);
?>
//功能:获取客户端IP地址,取其是否是教科网还是外网的IP,然后分别使用不同的域名。