<?php include("banIP.php");?>
禁用单个ip如下:
<?php //禁用ip地址 $ip=$_SERVER["REMOTE_ADDR"]; $ban=file_get_contents("ban.dat"); if(stripos($ban,$ip)) { die("Your IP Address is:$ip,you're forbiden to view this page!"); } echo "Your IP Address is:$ip,hello!"; ?>ban.dat文件如下:
BEGIN: 119.184.251.245 127.0.0.1 192.168.1.100禁用ip段如下:
<?php //禁用ip地址 $ip=$_SERVER["REMOTE_ADDR"]; while($ip[count($ip-1)]!='.')$ip=substr($ip,1, -1); //整理出ip段 $ban=file_get_contents("ban.dat"); if(stripos($ban,$ip)) { die("U're forbiden to view this page!"); } echo "Hello!"; ?>--------------------- 作者:luckymaoyy 来源:CSDN 原文:https://blog.csdn.net/luckymaoyy/article/details/73733396 版权声明:本文为博主原创文章,转载请附上博文链接!