您现在的位置: 雪儿网络 >> 站长学院 >> 网页设计 >> 文章正文

文章标题

动易2005版在统计中加上昨日访问量的方法

『 更新时间:2006-10-8 』『 字体:变小 变大 』『 作者:jgxx_zb | 来源:动易论坛 』

以下是引用bwsky在2005-4-1 23:22:13的发言:

有的朋友想在统计中加上昨日访问量的输出统计(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>"

 

【点击数:】【发表评论】【加入收藏】【告诉好友】【打印此文】【关闭窗口

关文章

您的姓名:
评分等级:
1分 2分 3分 4分 5分
评论内容:
1、严禁发表危害国家安全、政治、黄色淫秽等内容的评论。
2、用户需对自己在使用雪儿网络服务过程中的行为承担法律责任。
3、本站管理员有权保留或删除评论内容。
4、评论内容只代表网友个人观点,与本网站立场无关。
雪儿网络
copyright©2006-2008 xueol.com 鄂icp备06022161号
返回网站顶部