IP屏蔽for LBS2 数据库版

2007-07-23 13:00:59
之前写过一个"另类的IP屏蔽for LBS2", 很多朋友要求最好是能在数据库中修改的, 正好周末有空, 改写了一下, 发上来请大家指教.

打开class/function.asp
查找
return output;
}
在下面添加
 // IpBan v0.2beta.
// Core code from zkxp - http://zkxp.cnblogs.com/
// Modified by atan - http://www.atan.cn/
this.checkIpBan=function(){
 var BanIPGroup = theCache.settings["ipBanList"]
 if(IsForbidIP(BanIPGroup))
 {
    Response.Redirect(theCache.settings["baseURL"]);
 }
 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;
 }
}


打开admin.asp
查找
<tr>
<td class="formbox-rowheader"><%=lang["upload_type"]%>:</td>
<td class="formbox-content"><input type="text" name="uploadTypes" size="60" value="<%=func.HTMLEncodeLite(theCache.settings["uploadTypes"])%>" maxlength="250" class="text" /> <span class="comment-text">(<%=lang["seperate_by"]%>)</span></td>
</tr>
在下面添加
<tr>
<td class="formbox-rowheader"><%=lang["ipban_list"]%>:</td>
<td class="formbox-content"><input type="text" name="ipBanList" size="60" value="<%=func.HTMLEncodeLite(theCache.settings["ipBanList"])%>" maxlength="500" class="text" /> <span class="comment-text">(<%=lang["ipban_support"]%>)</span></td>
</tr>

打开source/src_admin.asp
查找
connBlog.exec(genStrUpdate("uploadtypes"));
在下面添加
connBlog.exec(genStrUpdate("ipbanlist"));

打开lang/admin.asp
查找
t["seperate_by"]="Seperated By ,";
在下面添加
t["ipban_list"]="IP Ban List";
t["ipban_support"]="Seperated By |, use * as wildcards";

打开article.asp
查找
<!---#include file="source/src_article.asp"-->
在下面添加
<%func.checkIpBan();%>

打开gbook.asp
查找
<!---#include file="source/src_gbook.asp"-->
在下面添加
<%func.checkIpBan();%>

升级数据库
这里提供两种方式升级(二选一):
1.  手动
打开数据库, 在blog_Settings表中的最后一行添加如图所示的数据
click to enlarge

2.  自动
下载 _upgrade_ipban_atan.zip 文件, 解压后修改其中
var blogDB="data/blog.mdb";
为自己blog数据库的实际路径. 最后运行此文件完成升级(升级前请作好备份).

使用方式
登录后台管理, 在Global Settings里的最后可以找到"IP Ban List", 在后面添加您需要屏蔽的IP地址, 用"|"分隔多个IP, 支持通配符*, 例:
127.0.0.1|192.168.*.1|123.*.231.*

数据库升级文件: Click Here To Download
[Last Modified By atan, at 2007-07-23 13:03:21]
Comments Feed Comments Feed: http://www.atan.cn/feed.asp?q=comment&id=516

View Mode: Show All | Comments: 3 | Trackbacks: 0 | Toggle Order | Views: 16595
Quote 生活笔谈*
[ 2007-08-07 11:21:18 ]
皮肤似乎太黑了点!!不过依旧很酷!
Quote 1232*
[ 2007-08-13 12:39:18 ]
Quotes From 生活笔谈
皮肤似乎太黑了点!!不过依旧很酷!
Quote 生活笔谈
[ 2007-09-04 15:06:49 ]
不知道你的登陆代码测试完毕没有?
如果成熟了的话希望你可以发布出来,
个人挺喜欢那个登陆效果的!
呵呵,我是LBS博客天空的管理员!

You can't post comment on this article.

Login

or

Register

labs