Instructions for use
1. Add a reference to the AntiRefresh.asp file at the top of the page to be protected, such as:
<!--#include virtual="AntiRefresh.asp" -->
2. Then add the calling code
The code copy is as follows:
<%
Const VarNameDateArr="www_domai_net_App_DataArr" 'Quote Name
Const VarNameIPArr="www_domai_net_App_IPArr" 'Quote Name
Dim objAntiRefresh
Set objAntiRefresh= new AntiRefresh
objAntiRefresh.BufferSize=100 'Quantity Size
objAntiRefresh.CacheItemAvailTime=2'Interval time
If Not objAntiRefresh.IsValidAccess() Then
Set objAntiRefresh=Nothing
Response.Write("Your visits have been frequent in the past, please try again in 2 seconds.")
Response.End()
End If
Set objAntiRefresh=Nothing
%>
Among them, the
Const VarNameDateArr="www_domai_net_App_DataArr" 'Quote Name
Const VarNameIPArr="www_domai_net_App_IPArr" 'Quote Name
For example, if you want to add a refresher to List.asp and search.asp, then you copy the above calling code to these two pages, or ensure that the code of the two pages is consistent. The effect is that if you visit the List.asp page, you will not be able to access the List.asp or Search.asp page within 2 seconds
If you want two pages to be independent, that is, after you access List.asp, you will not be able to access List.asp again within 2 seconds, but you can access Search.asp. Otherwise, you must ensure that the Const VarNameDateArr="xxx" of the two pages is different. For example, the first one is also used to use xxxList, and the first page is used xxxSearch,
like:
Const VarNameDateArr="www_domai_net_App_DataArr_Search" '(_List)
Const VarNameIPArr="www_domai_net_App_IPArr_Search" '(_List)
Nagging these is for friends who don’t know much so that they can use these codes. If you understand Asp, the above will be easy to understand for you.
The following is the AntiRefresh.asp file source code
The code copy is as follows:
<%
'*********************************************
'* Page anti-refresh module*
'* WDFrog, 2007-8-16
'*********************************************
Class AntiRefresh
Private IPArr,DateArr
Private m_BufferSize
Private m_CacheItemAvailTime
Private Sub Class_Initialize()
Application.Lock()
m_BufferSize=100
m_CacheItemAvailTime=2
End Sub
Private Sub Class_Terminate()
Application.UnLock()
End Sub
Public Property Get CacheItemAvailTime
CacheItemAvailTime=m_CacheItemAvailTime
End Property
Public Property Let CacheItemAvailTime(Value)
m_CacheItemAvailTime=Value
End Property
Public Property Get BufferSize
BufferSize=m_BufferSize
End Property
Public Property Let BufferSize(Value)
m_BufferSize=Value
End Property
Private Sub EnsureArr()
If IsArray(Application(VarNameDateArr)) Then
DateArr=Application(VarNameDateArr)
Else
ReDim DateArr(BufferSize)
End If
If IsArray(Application(VarNameIPArr)) Then
IPArr=Application(VarNameIPArr)
Else
ReDim IPArr(BufferSize)
End If
End Sub
Public Function IsValidAccess()
Dim ip,i
ip=GetIP()
IsValidAccess=True