📄 1.txt
字号:
Global.asa
*****************************************************************************
<script language=vbscript runat=server>
Sub Application_OnStart
Application("userclick")=0
Application("starttime")=now()
End Sub
</script>
*****************************************************************************
default.asp
*****************************************************************************
<!--这段代码放在需要限制访问次数页面的头部。-->
<!--如果需要多页面分别限制,可以对Application("userclick")稍作修改,或改用数据库
存储。-->
<%
Application.Lock
Application("userclick")=Application("userclick")+1
Application.UnLock
const vthmax=100 '默认限制为100次
const pertime=3600 '默认限制为3600秒
'计算时间差(精确到秒)
nowtime=now()
if datediff("s",datevalue(Application("starttime")),datevalue(nowtime))>=86400
then
daydiff=datediff("s",datevalue(Application("starttime")),datevalue(nowtime))
else
daydiff=0
end if
starthour=hour(Application("starttime"))
startminute=minute(Application("starttime"))
startsecond=second(Application("starttime"))
endhour=hour(nowtime)
endminute=minute(nowtime)
endsecond=second(nowtime)
hourdiff=(endhour-starthour)*3600
minutediff=(endminute-startminute)*60
seconddiff=endsecond-startsecond
timediff=daydiff+hourdiff+minutediff+seconddiff
'计算时间差代码结束
if timediff<=pertime then
if Application("userclick")>vthmax then
response.write "Sorry!您是自"&Application("starttime")&"算起,在"&pertime&"
秒时间内第"&Application("userclick")&"位来访者,您的这次访问超过了本站规定
每"&pertime&"秒时间内最多"&vthmax&"位访客的限制,请稍后再来!"
response.end
end if
else
Application.Lock
Application("starttime")=now()
Application("userclick")=0
Application.UnLock
end if
%>
<!--限制访问次数页面代码结束。-->
<html>
<head>
<meta http-equiv="Content-Language" content="en-us">
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>Homepage</title>
</head>
<body>
<p>正常访问!"您是自<%=Application("starttime")%>算起,在<%=pertime%>秒时间内第
<%=Application("userclick")%>位来访者。</p>
</body>
</html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -