有些时候,独裁是被迫的……

最近以来,一直有人在我的留言本上发一些无聊的广告。删了又发,我真不懂这个家伙是什么心理里,于是给留言本加了两个功能,
一者屏蔽一些关键词,源码如下:
Function CheckBadWords(byVal theString)
Dim WordFilterEntry,WordFilterArray,re,theMatches,tmpString,i
Set re = new RegExp
re.IgnoreCase = True
re.Global = True
WordFilterArray = Split(WordFilterList,",")
For Each WordFilterEntry IN WordFilterArray
tmpString = ""
For i = 1 To Len(WordFilterEntry)-1
tmpString = tmpString&Mid(WordFilterEntry,i,1)&"(["&Mid(WordFilterEntry,i,1)&"_\s\W]*)"
Next
tmpString = tmpString&Right(WordFilterEntry,1)
re.Pattern = tmpString
set theMatches = re.Execute(theString)
If theMatches.Count>0 Then
Response.Redirect("index.asp?Err=0x02")
End If
Next
set theMatches = nothing
set re = nothing
CheckBadWords = theString
End Function
二者屏蔽ip,源码如下:
Function CheckIP(IP)
IPFilterArray = Split(IPFilterList,",")
For Each IPArray IN IPFilterArray
FilterIP = Split(IPArray,".")
HostIP = Split(IP,".")
If HostIP(0) = FilterIP(0) AND HostIP(1) = FilterIP(1) AND HostIP(2) = FilterIP(2) AND HostIP(3) = FilterIP(3) Then
Response.Write("index.asp?Err=0x03")
Response.End()
End If
Next
End Function

具体的屏蔽内容就不公布了,希望某些无聊的家伙能自重点,本来不需这样强制的,sigh。。。。

你可能感兴趣的:(asp)