如何在统计中加上昨日访问量的输出统计?-动易CMS教程
有的朋友想在统计中加上昨日访问量的输出统计,可以用以下方法(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)
评论加载中....
- 昵称: 验证:







