asp防止刷新功能实现代码(2)


Else
ReDim IPArr(BufferSize)
End If
End Sub
Public Function IsValidAccess()
Dim ip,i
ip=GetIP()
IsValidAccess=True
EnsureArr()
For i=1 To BufferSize
If IPArr(i)=ip Then
If DateDiff("s",CDate(DateArr(i)),Now()) < CacheItemAvailTime Then
IsValidAccess=False
Exit Function
End If
End If
Next
Call QueueHandle()
DateArr(1)=Now()
IPArr(1)=ip
Application(VarNameIPArr)=IPArr
Application(VarNameDateArr)=DateArr
End Function
Public Function ClearCache()
Set Application(VarNameDateArr)=Nothing
Set Application(VarNameIPArr)=Nothing
End Function
Private Sub QueueHandle()
Dim i,j
For i=BufferSize-1 To 1 Step -1
DateArr(i+1)=DateArr(i)
Next
For j=BufferSize-1 To 1 Step -1
IPArr(j+1)=IPArr(j)
Next
End Sub
Private Function GetIP()
Dim strIPAddr
If Request.ServerVariables("HTTP_X_FORWARDED_FOR") = "" OR InStr(Request.ServerVariables("HTTP_X_FORWARDED_FOR"), "unknown") > 0 Then
strIPAddr = Request.ServerVariables("REMOTE_ADDR")
ElseIf InStr(Request.ServerVariables("HTTP_X_FORWARDED_FOR"), ",") > 0 Then
strIPAddr = Mid(Request.ServerVariables("HTTP_X_FORWARDED_FOR"), 1, InStr(Request.ServerVariables("HTTP_X_FORWARDED_FOR"), ",")-1)
ElseIf InStr(Request.ServerVariables("HTTP_X_FORWARDED_FOR"), ";") > 0 Then
strIPAddr = Mid(Request.ServerVariables("HTTP_X_FORWARDED_FOR"), 1, InStr(Request.ServerVariables("HTTP_X_FORWARDED_FOR"), ";")-1)
Else
strIPAddr = Request.ServerVariables("HTTP_X_FORWARDED_FOR")
End If
GetIP = (Trim(Mid(strIPAddr, 1, 30)))
End Function
End Class
%>


asp防止刷新
复制代码 代码如下:

Sub chkreflash()
    dim ScriptName
    ScriptName=lcase(request.ServerVariables("PATH_INFO"))
    dim posttime,DoReflashPage,ReflashPage,SplitReflashPage
    posttime=1 '防止刷新时间
    DoReflashPage=false
    ReflashPage="|Article_one.asp"
    SplitReflashPage=split(ReflashPage,"|")
        for i=0 to ubound(SplitReflashPage)
             if instr(scriptname,SplitReflashPage(i))>0 then
                DoReflashPage=true
            exit for
             end if
        next
    if (not isnull(session("ReflashTime"))) and posttime>0 and DoReflashPage then

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:http://www.heiqu.com/3507.html