◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。
Email:sunwindy[A]gmail.com
关于catalog.asp的再续
Post by 密陀僧, 2007-11-12, Views:下面说一下这个banip类的用法
1、在c_system_lib.asp中加入:
'*********************************************************
' 目的: 定义TBanIP类
' 输入: 无
' 返回: 无
'*********************************************************
Class TBanIP
Public CLSID
Public Name
Public Interval
Public Length
Private IpList()
Private TimeList()
Private IpNow
Private TimeNow
Private Function ChangeTimeToInteger(dtmTime)
ChangeTimeToInteger=(Year(dtmTime)*60*60*24*30*365 + Month(dtmTime)*60*60*24*30 + Day(dtmTime)*60*60*24 + Hour(dtmTime)*60*60 + Minute(dtmTime)*60 + Second(dtmTime))*1000
End Function
Public Function LoadList()
Dim i
Dim aryIpList
Dim aryTimeList
Application.Lock
aryIpList=Application(CLSID & Name & "IpList")
aryTimeList=Application(CLSID & Name & "TimeList")
Application.UnLock
ReDim Preserve IpList(Length)
ReDim Preserve TimeList(Length)
If IsArray(aryIpList) Then
For i=0 to Length
IpList(i)=aryIpList(i)
TimeList(i)=aryTimeList(i)
Next
Else
End If
End Function
Public Function SaveList()
Application.Lock
Application(CLSID & Name & "IpList")=IpList
Application(CLSID & Name & "TimeList")=TimeList
Application.UnLock
End Function
Private Function ClearList()
Dim i
Dim j
For i=0 To Length
If TimeNow-TimeList(i)>Interval Then
IpList(i)=Empty
TimeList(i)=0
j=i
End If
Next
For i=j+1 To Length
IpList(i-j-1)=IpList(i)
TimeList(i-j-1)=TimeList(i)
IpList(i)=Empty
TimeList(i)=0
Next
End Function
Public Function Check(strIP)
Dim i
IpNow=strIP
TimeNow=ChangeTimeToInteger(Now())
ClearList()
For i=0 to Length
If Not IsEmpty(IpList(i)) Then
If IpList(i)=IpNow Then Check=False
Exit Function
End If
Next
For i=0 to Length
If IsEmpty(IpList(i)) Then
IpList(i)=IpNow
TimeList(i)=TimeNow
Check=True
Exit Function
End If
Next
For i=0 to Length-1
IpList(i)=IpList(i+1)
TimeList(i)=TimeList(i+1)
Next
IpList(Length)=IpNow
TimeList(Length)=TimeNow
Check=True
End Function
Private Sub Class_Initialize()
End Sub
Private Sub Class_Terminate()
End Sub
End Class
'*********************************************************2、在c_system_base.asp的Sub System_Initialize()中加入引用:
Dim BanIP
If BlogUser.Level>2 Then '如非管理员则做防刷限制
Set BanIP=New TBanIP
BanIP.CLSID=ZC_BLOG_CLSID
BanIP.Name="防刷catalog" '随便起个名字
BanIP.Length=50 '队列的长度,可以记住50个不同的IP
BanIP.Interval=1000 '时间间隔,单位是毫秒
BanIP.LoadList
If BanIP.Check(Request.ServerVariables("LOCAL_ADDR"))=False Then
'如果当前IP出现在这个列表里,说明它在规定时间内重复出现了
Call ShowError(0)
End If
BanIP.SaveList
Set BanIP=Nothing
End If
Set BlogUser =New TUser
BlogUser.Verify()
==============================神奇的休止符================================
或许你还对下面的文章感兴趣
- 关于catalog.asp这个页面的续 (2007-11-8 1:59:46)
- [注意] Zblog的catalog.asp可被利用发起拒绝服务攻击 (2007-11-7 1:5:44)
- 介绍一个好东西Totoro,zblog的评论审核插件 (2007-8-10 17:19:11)
- zblog由access转sql server修改笔记 (2007-2-5 18:24:24)
- zblog紧跟潮流,升级到1.7版 (2007-2-4 22:41:1)
- 把blog升级到sql版 (2006-11-30 21:7:58)
- zblog的版权声明 (2006-11-13 12:52:25)
- zblog原来是这样关闭文章评论的 (2006-10-12 17:47:33)
- zblog 1.6最终版之预览版试用 (2006-8-1 0:59:24)
- 给zblog加上运行代码功能 (2006-7-24 15:36:30)
