另类的IP屏蔽for LBS2
2007-07-13 12:27:47
升级了新版的LBS后垃圾广告明显少了, 但俗话说”上有政策,下有对策”, 还是不能彻底杜绝垃圾制造者. 在删垃圾的时候正好看到这些垃圾制造者的IP地址基本上就这么几个, 可能对方是固定IP的, 于是就想起了IP屏蔽. LBS2.0.303之前的版本都有IP屏蔽的功能, 304之后似乎就取消了. 唯有自己添加了.
这里要要感谢网友zkxp提供的vbs版的源码. 不仅能屏蔽单个IP, 还能使用*通配符屏蔽IP段. 我稍做修改写成了JS版的.
打开class/function.asp文件,在最后一个大括号之前添加:
但是这里有个更好的解决方法, 我的目的是防止垃圾留言, 而不是禁止垃圾制造者访问blog, 因此这里有个更”毒”的方法
修改上面那段代码中的
Comments Feed: http://www.atan.cn/feed.asp?q=comment&id=514
这里要要感谢网友zkxp提供的vbs版的源码. 不仅能屏蔽单个IP, 还能使用*通配符屏蔽IP段. 我稍做修改写成了JS版的.
打开class/function.asp文件,在最后一个大括号之前添加:
// IpBan v0.1beta.
// Core code from zkxp - http://zkxp.cnblogs.com/
// Modified by atan - http://www.atan.cn/
this.checkIpBan=function(){
var BanIPGroup = "192.168.*.*|127.0.0.1|123.*.321.231"
if(IsForbidIP(BanIPGroup))
{
Response.Write("IP Forbidden");
Response.End();
}
function IsForbidIP(vBadIP){
var counter, arrIPPart, arrBadIP, arrBadIPPart, i, j;
arrBadIP = vBadIP.split("|");
arrIPPart = theUser.IP.split(".");
for (i = 0; i<=arrBadIP.length-1; i++){
counter = 0;
arrBadIPPart = arrBadIP[i].split(".");
for (j = 0; j<=arrIPPart.length-1; j++)
{
if ((arrBadIPPart[j] == "*") || (arrIPPart[j] == arrBadIPPart[j]))
{
counter = counter + 1;
}
}
if (counter == 4)
{
return true;
}
}
return false;
}
}
然后在global.asp里添加如下代码即可实现IP屏蔽:// Core code from zkxp - http://zkxp.cnblogs.com/
// Modified by atan - http://www.atan.cn/
this.checkIpBan=function(){
var BanIPGroup = "192.168.*.*|127.0.0.1|123.*.321.231"
if(IsForbidIP(BanIPGroup))
{
Response.Write("IP Forbidden");
Response.End();
}
function IsForbidIP(vBadIP){
var counter, arrIPPart, arrBadIP, arrBadIPPart, i, j;
arrBadIP = vBadIP.split("|");
arrIPPart = theUser.IP.split(".");
for (i = 0; i<=arrBadIP.length-1; i++){
counter = 0;
arrBadIPPart = arrBadIP[i].split(".");
for (j = 0; j<=arrIPPart.length-1; j++)
{
if ((arrBadIPPart[j] == "*") || (arrIPPart[j] == arrBadIPPart[j]))
{
counter = counter + 1;
}
}
if (counter == 4)
{
return true;
}
}
return false;
}
}
<%func.checkIpBan();%>
但是这里有个更好的解决方法, 我的目的是防止垃圾留言, 而不是禁止垃圾制造者访问blog, 因此这里有个更”毒”的方法
修改上面那段代码中的
Response.Write("IP Forbidden");
Response.End();
为:Response.End();
Response.Redirect("default.asp");
并在article.asp和gbook.asp里添加(不要在global.asp里添加哦):<%func.checkIpBan();%>
效果我就不用说了吧, 屏蔽的同时还能带来流量~~ [Last Modified By atan, at 2007-07-13 12:32:17]
Comments Feed: http://www.atan.cn/feed.asp?q=comment&id=514
View Mode: Show All |
Comments: 20 |
Trackbacks: 0 | Toggle Order | Views: 20743
[ 2007-07-22 16:49:22 ]
这功能不能用啦!
[ 2008-12-27 03:09:07 ]
Sorry for my post,
[ 2008-12-27 11:54:37 ]
Hi, good site,
[ 2009-01-03 23:57:54 ]
Hi, visit my link please,
[ 2009-01-04 00:22:59 ]
Soft,
[ 2009-01-04 03:57:48 ]
Privet,
[ 2009-01-04 07:43:27 ]
Visit,
[ 2009-01-05 14:53:55 ]
Privet,
[ 2009-01-05 17:02:16 ]
Soft,
[ 2009-01-05 19:12:05 ]
Hi, good site,
[ 2009-01-05 21:19:23 ]
Hello, thx for all,
[ 2009-02-04 02:05:29 ]
out.txt;3;3
[ 2009-02-04 05:43:56 ]
out.txt;3;3
[ 2009-02-04 07:34:39 ]
out.txt;3;3
[ 2009-02-04 09:23:54 ]
out.txt;3;3
[ 2009-02-04 13:12:42 ]
out.txt;3;3
[ 2009-02-04 15:13:38 ]
out.txt;3;3
[ 2009-02-04 17:16:01 ]
out.txt;3;3
[ 2009-04-05 08:37:07 ]
oQTEcr vkoo7wvY5Xkfak7bf1Th
[ 2009-04-19 13:14:49 ]
ajetcgjxgqcmcxwthsxbuatdjabofc
You can't post comment on this article.








