这段ASP程序中控制同一ip限制时间点击计数怎么写? |
这段程序是处理点击后给dayhits等变量计数的程序,点一次加1,但我想控制在同一IP下一定时间内不能连续点击计数,程序应该怎么写呢?
<!--#include file="conn.asp"--> <!--#include file="function.asp"--> <%dim lastday,tdate,p_year,p_month,p_day,period_time,rs,monthday,sql,sql1,id id=trim(request("id")) id=checkStr(id) if not isInteger(id) then response.write "您没有选择相关网站,请返回" response.end end if set rs=server.createobject("adodb.recordset") sql="select lastday,id,monthday,url from logo where id="&id rs.open sql,conn,1,1 if not (rs.eof and rs.bof) then 'response.Write(theurl) 'response.End() id=rs("id") lastday=rs("lastday") monthday=rs("monthday") lastday=year(lastday) & "-" & month(lastday) & "-" & day(lastday) tdate=year(Now()) & "-" & month(Now()) & "-" & day(Now()) if trim(lastday)=trim(tdate) then sql1="update logo set dayhits=dayhits+1 where id="&id conn.Execute(sql1) ' response.write "success" else sql1="update logo set dayhits=1,lastday=now() where id="&id conn.Execute(sql1) ' response.write "error" end if sql1="update logo set lasthits=lasthits+1 where id="&id conn.Execute(sql1)
p_year=CInt(year(Now()))-CInt(year(monthday)) p_month=CInt(month(Now()))-CInt(month(monthday)) p_day=CInt(day(Now()))-CInt(day(monthday)) period_time=((p_year*12+p_month)*30+p_day) if cint(period_time)=<cint(30) then sql1="update logo set monhits=monhits+1 where id="&id conn.Execute(sql1) else sql1="update logo set monhits=1,monthday=now() where id="&id conn.Execute(sql1) end if response.redirect rs("url") end if rs.close set rs=nothing conn.close set conn=nothing%>
(编辑:网站学习网)
|
|
|
|