<?php

require_once('inc/conn.php');
$opendb = new mydb();

$sql = "select * from ls_config";
$query = $opendb->query($sql);
$value = mysql_fetch_assoc($query);

function trimall($str)//删除空格
{
    $qian=array(" ","　","\t","\n","\r");
    $hou=array("","","","","");
    return str_replace($qian,$hou,$str); 
}

//禁止某个IP
$banned_ip = explode(",",$value['shieldIP']);

if ( in_array( getenv("REMOTE_ADDR"), trimall($banned_ip) )){
	echo "fail";
}else{
	echo "success";
}

/*//禁止某个IP段
$ban_range_low=ip2long("119.6.20.65");
$ban_range_up=ip2long("119.6.20.67");
$ip=ip2long($_SERVER["REMOTE_ADDR"]);
if ($ip>$ban_range_low && $ip<$ban_range_up)
{
echo "您的IP在被禁止的IP段之中，禁止访问！";
exit();
} */
?>