为ecshop加上IP屏蔽功能,限制ip访问
2012-05-31 11:28 yangpan 阅读(231) 评论(0) 编辑 收藏 举报
1. includes文件夹下新建ip.php文件,内容为:
getIpAdr($thisip);
$thenetip=get_netip($thisip);
for($i=0;$ilocation.href='error.php';";
}
//else {
// echo "";
//}
/*///////////////////////////////////
//屏蔽IP地址段 V0.1
//时间:2011.09.24 15:40
//代码:http://www.hisune.com
*/////////////////////////////////////
?>
2. includes文件夹下新建ip.txt空白文本文档
3. 根目录下新建error.php,内容为:
错误,您的IP不在本站的服务范围之内。
抱歉,您的IP地址不在本站的服务范围之内!请联系网站管理员。
Sorry, your IP address is not within the scope of the services this site! Please contact the webmaster.
4 . 在includes文件夹下init.php文件末端插入:
require(ROOT_PATH . 'includes/ip.php');
5. admin文件夹下新建ip.php文件,内容为:
IP段屏蔽设置";
echo "{$item}
在其后加入:
![](themes/bk/images/warning.gif)
Sorry, your IP address is not within the scope of the services this site! Please contact the webmaster.
";
echo "
";
//write
if($_POST['submit']){
$ft = fopen("../includes/ip.txt","w+");
fwrite($ft,"$_POST[ipkill]");
fclose($ft);
echo "";
}
/**
* IP地址段屏蔽后台程序
* ============================================================================
* 版权所有 2011-2012 海尚网络,并保留所有权利。
* 网站地址: http://www.hisune.com;
* ----------------------------------------------------------------------------
*文件版本:0.1
*编写时间:2011-09-22 13:55:12
*作者:寒风
*个人网站:http://www.coolwinds.cn
*专业建站:http://www.hisune.com
* ============================================================================
**/
?>
6. admin/templates/top.htm文件:
";
echo "";
echo "
";
echo "";
echo "
"; echo "
"; echo "192.168.0"; echo "
"; echo "
"; echo "
"; echo "
";
echo "1. 在左侧输入要屏蔽的IP地址段
";
echo ""; echo "
2. IP地址段为前三位,每一行一个IP段如:
";
echo "192.168.1";
echo ""; echo "192.168.0"; echo "
"; echo "
"; echo "
3. 您当前登录的IP地址为:
";
echo "".$ip=$_SERVER["REMOTE_ADDR"]."";
echo ""; echo "