首页 | 心情日记 | 建站心得 | 编程技术 | 大盘分析 | 股市信息 | 学习园地 | 电脑技巧 | 物流外贸 | 另类其它 | 站长推荐 | 给我留言 | 相册

用户登陆
用户:
密码:
 
不保存保存一天
保存一月保存一年

站点日历
73 2024 - 4 48
 123456
78910111213
14151617181920
21222324252627
282930


站点统计

最新评论

日志搜索

 标题   内容


L-BLOG防止垃圾评论三法 ASP判断远程文件是否存在
未知 为L-Blog加上关键字过滤及IP过滤功能   [ 日期:2009-12-26 15:32:27 ]   [ 来自:本站原创 ]

海外邮件中继,海外退信中继,美国高速VPS,不限流量VPN,邮局维护和管理,邮件网关,EMOS邮件中继,POSTFIX邮件中继,Winwebmail邮件中继,Winmail邮件中继,DBMail邮件中继,JDMail邮件中继,Exchange邮件中继,MDaemon邮件中继 淘宝店:http://shantan.taobao.com 云邮科技官网:www.yunrelay.com

【字体设置:
首先声明:
一、偶使用的L-Blog版本可能有些旧,如果和你的不同,请参考着修改!
二、此项修改系添加两项功能,属于比较大的修改,无动手能力者慎重!

1、先把你的LB-Blog数据库下载回来,用Access打开LB-Blog的数据库,找到Blog_info表,点击设计,在表中增加两个字段:Blog_IP及Blog_Keyword,字段类型为备注,重新上传覆盖你的LB-Blog数据库,至此用来存放过滤IP和关键字的仓库准备完毕!

2、下载LB-BLOG根目录下的Command.asp,用记事本打开(记事本要取消自动换行选项),找到:

Dim blog_Infos,SiteName,SiteUrl,

这一行,在下面添加一行:

Dim FilterKeyword,FilterIP

找到:

SiteName=blog_Infos("blog_Name")
SiteURL=blog_Infos("blog_URL")

在下面添加:

FilterKeyWord = blog_Infos("blog_Keyword")
FilterIP = blog_Infos("blog_IP")

保存重新上传Command.asp。

3、用记事本打开Include/Function.asp文件,在最后面的%>前面添加三个函数。
程序代码:[ 复制代码到剪贴板 ]

Function fnChkFilterIP
'判断IP是否在过滤之内,被过滤返回True
    fnChkFilterIP = false
    Dim arrFilterIP
    Dim FilterIPIndex
    Dim arrGuestIP
    Dim arrChkIP
    if FilterIP <> "" Then
        arrFilterIP = Split(FilterIP,"|")
        arrGuestIP = Split(Guest_IP,".")
        for FilterIPIndex = 0 to Ubound(arrFilterIP)
            arrChkIP = Split(arrFilterIP(FilterIPIndex),".")
            if arrChkIP(0)<>"*" and arrChkIP(1)<>"*" and arrChkIP(2)<>"*" and arrChkIP(3)<>"*" Then
                '均不为*号,则直接比较四位
                if(arrFilterIP(FilterIPIndex) = Guest_IP)Then
                    fnChkFilterIP = true
                    exit for
                End If
            ElseIf arrChkIP(0)<>"*" and arrChkIP(1)<>"*" and arrChkIP(2)<>"*" and arrChkIP(3)="*" Then
                '判断前三位
                if(arrGuestIP(0)=arrChkIP(0) and arrGuestIP(1)=arrChkIP(1) and arrGuestIP(2)=arrChkIP(2))Then
                    fnChkFilterIP = true
                    exit for
                end if
            ElseIf arrChkIP(0)<>"*" and arrChkIP(1)<>"*" and arrChkIP(2)="*" and arrChkIP(3)="*" Then
                '判断前两位
                if(arrGuestIP(0)=arrChkIP(0) and arrGuestIP(1)=arrChkIP(1))Then
                    fnChkFilterIP = true
                    exit for
                end if
            ElseIf arrChkIP(0)<>"*" and arrChkIP(1)="*" and arrChkIP(2)="*" and arrChkIP(3)="*" Then
                '判断前一位
                if(arrGuestIP(0)=arrChkIP(0))Then
                    fnChkFilterIP = true
                    exit for
                end if
            End If
        Next
    End If

End Function

程序代码:[ 复制代码到剪贴板 ]
Function fnChkFilterKeyword(Str)
    '判断是否包含被过滤的字符,包含返回True
    fnChkFilterKeyword = false
    Dim arrFilterKeyword
    Dim FilterKeyIndex
    if FilterKeyword<>"" Then
        arrFilterKeyword = Split(FilterKeyword,"|")
        for FilterKeyIndex=0 to Ubound(arrFilterKeyWord)
            if(StrCount(str,arrFilterKeyWord(FilterKeyIndex))>0)Then
                    fnChkFilterKeyword = true
                    exit for
            end if    
        Next    
    End If        
End Function

程序代码:[ 复制代码到剪贴板 ]
Function StrCount(Str,SubStr)        '统计指定字符出现的次数
    Dim iStrCount
    Dim iStrStart
    Dim iTemp
    iStrCount = 0
    iStrStart = 1
    iTemp = 0
    Do While iStrStart < Len(Str)
        iTemp = Instr(iStrStart,Str,SubStr,vbTextCompare)
        If iTemp <=0 Then
            iStrStart = Len(Str)
        Else
            iStrStart = iTemp + Len(SubStr)
            
            iStrCount = iStrCount + 1
        End If
        
    Loop
    StrCount = iStrCount
End Function

保存重新上传Function.asp文件。

4、打开根目录下的BlogComm.asp文件,找到:

msg_Title="出现错误"
        msg_Content="<a href=""javascr&#105;pt:history.go(-1);"">你发表评论速度太快了,点击返回上一页</a>"

在下面添加:

ElseIF (fnChkFilterKeyWord(Request.Form("Message"))) Then
        msg_Title="出现错误"
        msg_Content="<a href=""javascr&#105;pt:history.go(-1);"">您所发表的言论不被允许,点击返回上一页</a>"
    ElseIF (fnChkFilterIP) Then
        msg_Title="出现错误"
        msg_Content="<a href=""javascr&#105;pt:history.go(-1);"">您所使用的计算机不被允许发表评论,点击返回上一页</a>"

保存重新上传BlogComm.asp文件!

5、打开Admincp.asp文件,找到:

<%Else%><br>
    </p>
<div class="msg_head"><%=SiteName%> 系统信息</div>

在上面加上:
程序代码:[ 复制代码到剪贴板 ]
<%ElseIf  Request.QueryString("action")="filterIP" Then
'过滤IP
Dim strIPList
if Request("IPList") <> "" Then
    strIPList = ""
    strIPList = Replace(Request("IPList"),vbcrlf,"|")
    strIPList = Trim(Replace(strIPList,"||",""))
    if Right(strIPList,1) = "|" Then
        strIPList = Left(strIPList,Len(strIPList)-1)
    End If
    '提交数据库
    SQL = "Update [blog_info] Set Blog_IP = '" & strIPlist & "'"
    Conn.execute(SQL)
End If
    SQL = "Select blog_IP From [blog_Info]"
    strIPList = Conn.Execute(SQL)(0)
    strIPList = Replace(strIPList,"|",vbcrlf)
%>
     <table border="1" cellpadding="0" style="border-collapse: collapse" width="100%" id="table1" bordercolor="#C0C0C0">
        <tr>
            <td height="22"><b>&nbsp;设置IP过滤</b> - 被过滤的用户将不能发表评论</td>
        </tr>
        <tr>
            <td align="center">
                <table border="0" cellpadding="0" style="border-collapse: collapse" width="90%" id="table2">
                <form action="admincp.asp?action=filterIP" method="post">
                    <tr>
                        <td height="30">IP过滤列表 (如:192.168.0.1 或使用*来代替 每行一个 必须为XX.XX.XX.XX形式 )</td>
                    </tr>
                    <tr>
                        <td bgcolor="#D8DFE2" height="1"></td>
                    </tr>
                    <tr>
                        <td height="30"><textarea rows="10" name="IPList" cols="33"><%=strIPList%></textarea></td>
                    </tr>
                    <tr>
                        <td height="30">
                        <input type="submit" value="提交" name="B1"></td>
                    </tr>
                    <tr>
                        <td height="30"></td>
                    </tr>
                    </form>
                </table>
            </div>
            </td>
        </tr>
    </table>
<%ElseIf  Request.QueryString("action")="filterKeyword" Then
'过滤关键字

Dim strKeyList
if Request("KeyList") <> "" Then
    strKeyList = ""
    strKeyList = Replace(Request("KeyList"),vbcrlf,"|")
    strKeyList = Trim(Replace(strKeyList,"||",""))
    if Right(strKeyList,1) = "|" Then
        strKeyList = Left(strKeyList,Len(strKeyList)-1)
    End If
    '提交数据库
    SQL = "Update [blog_info] Set Blog_Keyword = '" & strKeylist & "'"
    Conn.execute(SQL)
End If
    SQL = "Select blog_keyword From [blog_Info]"
    strkeyList = Conn.Execute(SQL)(0)
    strkeyList = Replace(strkeyList,"|",vbcrlf)
%>
<table border="1" cellpadding="0" style="border-collapse: collapse" width="100%" id="table1" bordercolor="#C0C0C0">
        <tr>
            <td height="22"><b>&nbsp;设置关键字过滤</b> - 含有被过滤的关键字将不能发表评论</td>
        </tr>
        <tr>
            <td align="center">
                <table border="0" cellpadding="0" style="border-collapse: collapse" width="90%" id="table2">
                <form action="admincp.asp?action=filterKeyword" method="post">
                    <tr>
                        <td height="30">输入要过滤的关键字,每行一个,不区分大小写(如过滤连接:http://),不允许输入|符号</td>
                    </tr>
                    <tr>
                        <td bgcolor="#D8DFE2" height="1"></td>
                    </tr>
                    <tr>
                        <td height="30">
                        <textarea rows="10" name="KeyList" cols="33"><%=strKeyList%></textarea></td>
                    </tr>
                    <tr>
                        <td height="30">
                        <input type="submit" value="提交" name="B1"></td>
                    </tr>
                    <tr>
                        <td height="30"></td>
                    </tr>
                    </form>
                </table>
            </div>
            </td>
        </tr>
    </table>

6、在admincp.asp中找到:

<a href="admincp.asp?action=linkscheck"><b>链接验证</b></a><br />

在下面加上:

<b><a href="admincp.asp?action=filterIP">IP过滤</a></b><br />
<b><a href="admincp.asp?action=filterKeyword">关键字过滤</a></b><br />

现在你可以进入你的系统管理里面,使用IP过滤和关键字过滤来添加要过滤的东西了!

至此你的LB-Blog已经具体这两项防护外衣,可以抵挡大部分的垃圾了,欢迎大家转载,但请注明出处,如果你在修改过程中遇到问题,可以跟我留言!


暂时没有评论
   发表评论 - 不要忘了输入验证码哦!
作者: 用户:  密码:  我要注册 验证码: 
为防止广告注册机程序,验证码不会自动显示,请点击此处显示或者(刷新)验证码!
评论:

禁止表情
禁止UBB
禁止图片
识别链接
识别关键字
确定发布?
最多可以输入200个字,目前你已经输入了0个字;你今日还可以发表10条评论!
 
   

CopyRight © 2008-2010 广东金融学院030904班 All Rights Reserved
Powered by www.030904.com