关于限制访问次数的问题!!

panjisheng 2002-01-12 03:17:14
各位好!!
我是新来的朋友,刚接触ASP 朋友们让我到这里来去经!!

我想要一个限制访问量的页面,具体内容是这样的
----------
一个ASP 页面 在一个小时内,允许访问固定次数, 如果访问次数大于“固定次数” 则 “报错”
判断 如果 距离最后一次成功访问页面的时间 大于60分钟后 重新统计访问次数!
-------------
谁能告诉我应该怎样做这个程序啊!?
...全文
372 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
Soft21 2002-01-13
  • 打赏
  • 举报
回复
大家好啊,好啊,Up!
wuxineyou 2002-01-12
  • 打赏
  • 举报
回复
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>
*****************************************************************************
在iis5.1+ie6下调试通过!
panjisheng 2002-01-12
  • 打赏
  • 举报
回复
0=-0
panjisheng 2002-01-12
  • 打赏
  • 举报
回复
啊??什么意思啊~~~我是新来的~~~对这个论坛还是熟悉!!

怎么加分的??我好象还有100多分
希偌 2002-01-12
  • 打赏
  • 举报
回复
很简单,你出多少分???
我帮你做!

28,391

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧