一般而言这样处理,一个ip在一天内只能下载一次,因此,只需要记录当天的ip即可。
下面是一个这样原理的计数器,你参考一下:
<%
'防刷新计数器
Response.Expires=-1
dim conn,connstr,rs,vip,vips,vtoday,vyesterday,vtodaytime,vsaveips,vmax,vmaxtime,vdays,vdayavg
set conn=Server.CreateObject("ADODB.Connection"
connstr="Provider=Microsoft.Jet.OLEDB.4.0;Data Source="&Server.MapPath("num/num.mdb"
conn.open connstr
vip="#"&Request.servervariables("REMOTE_ADDR"
set rs=conn.execute("select vips,vtoday,vtodaytime,vsaveips,vmax,vmaxtime from [num]"
if rs.eof and rs.bof then
sql="insert into [num] (vips,vtoday,vyesterday,vtodaytime,vsaveips,vmax,vmaxtime,vstarttime) values(0,0,0,Date(),'#',0,Date(),Now())"
conn.execute(sql)
else
if rs(2)=Date() then
if Instr(rs(3),vip)=False then
vips=rs(0)+1
vtoday=rs(1)+1
if rs(3)="#"
then
vsaveips=vip
else
vsaveips=rs(3)&vip
end if
conn.execute("update [num] set vips='"&vips&"',vtoday='"&vtoday&"',vsaveips='"&vsaveips&"'"
end if
else
vips=rs(0)+1
vtoday=1
vyesterday=rs(1)
vtodaytime=Date()
vsaveips=vip
conn.execute("update [num] set vips='"&vips&"',vtoday='"&vtoday&"',vyesterday='"&vyesterday&"',vtodaytime='"&vtodaytime&"',vsaveips='"&vsaveips&"'"
end if
if clng(rs(1))>clng(rs(4)) then
vmax=rs(1)
vmaxtime=Now()
conn.execute("update [num] set vmax='"&vmax&"',vmaxtime='"&vmaxtime&"'"
end if
end if
rs.close
set rs=nothing
set rs=conn.execute("select vips,vtoday,vyesterday,vtodaytime,vsaveips,vmax,vmaxtime,vstarttime from [num]"
vdays=now()-cdate(rs(7))
vdayavg=rs(0)/vdays
vdays=int((vdays*10^3)+0.5)/10^3
if vdays<1 then
vdays="0"
&
vdays
vdayavg=int((vdayavg*10^3)+0.5)/10^3
……