ASP anti-refresh function

Source: Internet
Author: User

ASP anti-refresh function

Sub Preventrefresh ()
Dim Refreshtime,isrefresh
Refreshtime = 10 ' Prevent refresh time, unit (seconds)
Isrefresh = 1 ' Use anti-refresh function, 0 = no, 1 = yes
If Isrefresh = 1 Then
If (Not IsEmpty ("Refreshtime")) and Refreshtime > 0 Then
If DateDiff ("s", Session ("Refreshtime"), now ()) < Refreshtime Then
Response.Write "<meta Http-equiv=content-type content=text/html; Charset=gb2312><meta http-equiv=refresh content= "&RefreshTime&" ><br> this page has the anti-refresh mechanism enabled, please do not &RefreshTime& "In seconds to refresh this page continuously <BR> is opening the page, please later ..."
Response.End
Else
Session ("refreshtime") = Now ()
End If
Else
Session ("refreshtime") = Now ()
End If
End If
End Sub

Public Sub Getusertodayinfo ()
Dim Lastlogin,userdayinfo
Lastlogin = Request.Cookies ("newasp_net") ("Lasttime")
Userdayinfo = Request.Cookies ("newasp_net") ("Usertoday")
If not IsDate (lastlogin) Then lastlogin = Now ()
On Error Resume Next
If DateDiff ("D", Lastlogin,now ()) <>0 Then
Newasp.execute ("UPDATE [Nc_user] SET usertoday= ' 0,0,0,0,0,0 ', lasttime=" & nowstring & "WHERE username= '" & Newasp.membername & "' and Userid=" & Newasp.memberid)
Userdayinfo = "0,0,0,0,0,0"
Response.Cookies ("Newasp_net") ("usertoday") = Userdayinfo
Response.Cookies ("Newasp_net") ("lasttime") = Now ()
End If
Usertoday = Split (Userdayinfo, ",")
If Ubound (usertoday) <> 5 Then
Newasp.execute ("UPDATE [Nc_user] SET usertoday= ' 0,0,0,0,0,0 ', lasttime=" & nowstring & "WHERE username= '" & Newasp.membername & "' and Userid=" & Newasp.memberid)
Userdayinfo = "0,0,0,0,0,0"
Response.Cookies ("Newasp_net") ("usertoday") = Userdayinfo
Response.Cookies ("Newasp_net") ("lasttime") = Now ()
Usertoday = Split (Userdayinfo, ",")
End If
End Sub
Public Function updateusertoday (ByVal str)
On Error Resume Next
If Trim (str) <> "" Then
Newasp.execute ("UPDATE [Nc_user] SET usertoday= '" & str & ' WHERE username= ' "& Newasp.membername &" ' and Userid= "& Newasp.memberid)
Response.Cookies ("Newasp_net") ("usertoday") = str
End If
End Function

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.