28,390
社区成员
发帖
与我相关
我的任务
分享
<%
if request.Cookies("AccTimes")="" then
response.Cookies("AccTimes")=0
response.Cookies("LastTime")=now()
response.Cookies("Forbidden")="false" '设置一 个是否能访问的标志,初始是能访问的
else
AccTimes=request.Cookies("AccTimes")
LastTime=request.Cookies("LastTime")
end if
if request.Cookies("Forbidden")="false" then
if not (LastTime="" or LastTime=Empty or AccTimes="" or AccTimes=Empty) then
if datediff("n",LastTime,now()) >= 0 and datediff("n",LastTime,now()) < 1 then '记录1分钟以内的访问次数
if AccTimes < 20 then ' 20次以内,则次数累加
AccTimes = AccTimes + 1
response.Cookies("AccTimes") = AccTimes
else '超过20次,禁止访问
response.Write "Forbidden!"
response.Cookies("Forbidden")="true" '给访问标志赋值,以后都不让访问
response.End()
end if
response.Write AccTimes&"<br>" '测试用,可以删掉
else ' 对于在1分钟之内没有超过20次访问的情况,须将时间和次数都重新设置
response.Cookies("LastTime")=now()
response.Cookies("AccTimes")=0
end if
end if
elseif request.Cookies("Forbidden")="true" then
response.Write "Forbidden!"
response.End()
end if
%>
<%
if request.Cookies("AccTimes")="" then
response.Cookies("AccTimes")=0
response.Cookies("LastTime")=now()
else
AccTimes=request.Cookies("AccTimes")
LastTime=request.Cookies("LastTime")
end if
if not (LastTime="" or LastTime=Empty or AccTimes="" or AccTimes=Empty) then
if datediff("n",LastTime,now()) >= 0 and datediff("n",LastTime,now()) < 1 then '记录1分钟以内的访问次数
if AccTimes < 20 then ' 20次以内,则次数累加
AccTimes = AccTimes + 1
response.Cookies("AccTimes") = AccTimes
else '超过20次,禁止访问
response.Write "Forbidden!"
response.End()
end if
response.Write AccTimes&"<br>" '测试用,可以删掉
else ' 对于在1分钟之内没有超过20次访问的情况,须将时间和次数都重新设置
response.Cookies("LastTime")=now()
response.Cookies("AccTimes")=0
end if
end if
%>
<%utimes=clng(request.Cookies("utimes"))
if utimes="" or isnull(utimes) then
response.Cookies("utimes")=1
response.cookies("utimes").expires=date +365 'cookies有效天数
else
response.Cookies("utimes")=utimes+1
if utimes+1>20 then
response.Write "禁止访问"
response.end
end if
end if
%>