
有的朋友想在统计中加上昨日访问量的输出统计(2005版本的acc和sql统计均适合),可以用以下方法:
请在count/counter.asp中加上如下代码(红色所示):
if foundinarr(regcount_fill, "iscountonline", ",") = true then
if onlinetime="" or isnumeric(onlinetime)=0 then onlinetime=100
onnowtime = dateadd("s",-onlinetime,now())
dim rsonline
if countdatabasetype="sql" then
set rsonline = conn_counter.execute("select count(userip) from pe_statonline where lasttime>'"&onnowtime&"'")
else
set rsonline = conn_counter.execute("select count(userip) from pe_statonline where lasttime>#"&onnowtime&"#")
end if
onlinenum = rsonline(0) ' 当前在线人数
set rsonline=nothing
if countdatabasetype="sql" then
set rsonline = conn_counter.execute("select lasttime,ontime from pe_statonline where lasttime>'"&onnowtime&"' and userip='"&ip&"'")
else
set rsonline = conn_counter.execute("select lasttime,ontime from pe_statonline where lasttime>#"&onnowtime&"# and userip='"&ip&"'")
end if
if rsonline.eof then
update()
else
if rsonline(0)=rsonline(1) then
update()
else
conn_counter.execute("update pe_statinfolist set totalview=totalview+1")
end if
end if
set rsonline=nothing
else
if instr(application(lastipcache),"#" & ip & "#") then ' 如果ip已经存在于保存的列表中,是刷新
conn_counter.execute("update pe_statinfolist set totalview=totalview+1")
else
application.lock
application(lastipcache)=saveip(application(lastipcache)) ' 更新最近需要防刷的ip
application.unlock
update()
end if
end if
'--------输出昨日访问量代码开始
dim nyesterdaynum
if isempty(application("nyesterdayvisitornum")) then
dim yesterdaystrlong
yesterdaystrlong=year(dateadd("d","-1",date()))&"-"&month(dateadd("d","-1",date()))&"-"&day(dateadd("d","-1",date()))
set rs=server.createobject("adodb.recordset")
if countdatabasetype="sql" then
sql="select * from pe_statday where tday='"&yesterdaystrlong&"'"
else
sql="select * from pe_statday where tday=#"&yesterdaystrlong&"#"
end if
rs.open sql,conn_counter,1,1
if not rs.bof or not rs.eof then
for i=0 to 23
nyesterdaynum=nyesterdaynum+rs(cstr(i))
next
else
nyesterdaynum=0
end if
application.lock
application("nyesterdayvisitornum")=nyesterdaynum
application.unlock
set rs=nothing
rs.close
else
nyesterdaynum=application("nyesterdayvisitornum")
end if
'--------输出昨日访问量代码完毕
call closeconn_counter()
style=lcase(trim(request("style")))
select case style
case "simple"
showinfo="总访问量:" & allnum & "人次<br>"
if foundinarr(regcount_fill, "iscountonline", ",") = true then
showinfo=showinfo&"当前在线:" & onlinenum & "人"
end if
case "all"
showinfo=showinfo&"总访问量:" & allnum & "人次<br>"
showinfo=showinfo&"总浏览量:" & totalview & "人次<br>"
' showinfo=showinfo&"统计天数:" & statdaynum & "天<br>"
showinfo=showinfo&"昨日访问:" & nyesterdaynum & "人<br>"
showinfo=showinfo&"今日访问:" & daynum & "人次<br>"
showinfo=showinfo&"日均访问:" & avedaynum & "人次<br>"
if foundinarr(regcount_fill, "iscountonline", ",") = true then
showinfo=showinfo&"当前在线:" & onlinenum & "人"
end if
case "common"
showinfo="总访问量:" & allnum & "人次<br>"
showinfo=showinfo&"总浏览量:" & totalview & "人次<br>"
if foundinarr(regcount_fill, "iscountonline", ",") = true then
showinfo=showinfo&"当前在线:" & onlinenum & "人"
end if
end select
if style<>"none" then
response.write "document.write(" & chr(34) & showinfo & chr(34) & ")"
end if
效果:
总访问量:327873人次
总浏览量:992879人次
昨日访问:435人
今日访问:2人次
日均访问:788人次
当前在线:7人
成功了!噢耶!
万分感谢管理员!
昨日访问:435人
代码中少了个“次”字。应该是 showinfo=showinfo&"昨日访问:" & nyesterdaynum & "人次<br>"