PHP完全自学手册(珍藏版) 中文pdf扫描版下载
$sql = "192.168.0.168
127.0.0.1"; function getIP() { static $realip; if (isset($_SERVER)){ if (isset($_SERVER["HTTP_X_FORWARDED_FOR"])){ $realip = $_SERVER["HTTP_X_FORWARDED_FOR"]; } else if (isset($_SERVER["HTTP_CLIENT_IP"])) { $realip = $_SERVER["HTTP_CLIENT_IP"]; } else { $realip = $_SERVER["REMOTE_ADDR"]; } } else { if (getenv("HTTP_X_FORWARDED_FOR")){ $realip = getenv("HTTP_X_FORWARDED_FOR"); } else if (getenv("HTTP_CLIENT_IP")) { $realip = getenv("HTTP_CLIENT_IP"); } else { $realip = getenv("REMOTE_ADDR"); } } return $realip; } $ip = getIP(); $array = explode("\n",$sql); if(in_array($ip,$array)){ exit('无权防问'); } else { echo $ip; }
转载请注明:谷谷点程序 » php禁用ip访问的简单实现方法