如何在统计中加上昨日访问量的输出统计?
【字体:
如何在统计中加上昨日访问量的输出统计?
作者:admin    文章来源:本站原创    点击数:1228    更新时间:2013/11/6

有的朋友想在统计中加上昨日访问量的输出统计,可以用以下方法(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,CacheData
If CacheIsEmpty("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
 CacheData = Application("nYesterDayVisitorNum")
 If IsArray(CacheData) Then
  CacheData(0) = nYesterDayNum
  CacheData(1) = Now()
 Else
  ReDim CacheData(2)
  CacheData(0) = nYesterDayNum
  CacheData(1) = Now()
 End If
 Application.Lock
 Application("nYesterDayVisitorNum") = CacheData
 Application.UnLock
Else
 CacheData = Application("nYesterDayVisitorNum")
 If IsArray(CacheData) Then
  nYesterDayNum = CacheData(0)
 Else
  nYesterDayNum = 0
 End If
End If
Function CacheIsEmpty(MyCacheName)
    CacheIsEmpty = True
    CacheData = Application(MyCacheName)
    If Not IsArray(CacheData) Then Exit Function
    If Not IsDate(CacheData(1)) Then Exit Function
    If DateDiff("s", CDate(CacheData(1)), Now()) < 8640 Then
        CacheIsEmpty = False
    End If
End Function
'--------输出昨日访问量代码完毕
Call CloseConn_counter()
style=lcase(trim(Request("style")))
select case style
case "simple"
ShowInfo="总访问量:" & AllNum & "人次
"
If FoundInArr(RegCount_Fill, "IsCountOnline", ",") = True Then
  ShowInfo=ShowInfo&"当前在线:" & OnlineNum & "人"
End If
case "all"
ShowInfo=ShowInfo&"总访问量:" & AllNum & "人次
"
ShowInfo=ShowInfo&"总浏览量:" & TotalView & "人次
"
' ShowInfo=ShowInfo&"统计天数:" & StatDayNum & "天
"
ShowInfo=ShowInfo&"昨日访问:" & nYesterDayNum & "人
"
ShowInfo=ShowInfo&"今日访问:" & DayNum & "人次
"
ShowInfo=ShowInfo&"日均访问:" & AveDayNum & "人次
"
If FoundInArr(RegCount_Fill, "IsCountOnline", ",") = True Then
  ShowInfo=ShowInfo&"当前在线:" & OnlineNum & "人"
End If

case "common"
ShowInfo="总访问量:" & AllNum & "人次
"
ShowInfo=ShowInfo&"总浏览量:" & TotalView & "人次
"
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

文章录入:admin    责任编辑:admin 
枣强县董子学校网站
枣强县董子学校 版权所有,未经授权禁止复制或镜像 后台登陆
枣强县董子学校主办 网站备案编号:冀ICP备11008566号
建议使用IE6.0及以上版本 在1024*768及以上分辨率下浏览
回到顶部