网站访客统计的代码 不用统计网站的统计,自己实现统计的源代码
- 提问者网友:王者佥
- 2021-08-20 19:58
- 五星知识达人网友:鱼忧
- 2021-08-20 20:52
思路就是这样的,用记事本记录数据,没访问一次自加1,简单方便,且防止了短时间的刷新增加数值的弊端
<%
Dim RefreshTime
RefreshTime = Int((5 * Rnd) + 1)
'if Session("RefreshTime")="" Then
'Session("RefreshTime") = Now()
'Response.Write(Session("RefreshTime"))
'End If
CountFile=Server.MapPath("count.txt")
Set FileObject=Server.CreateObject("Scripting.FileSystemObject")
Set Out=FileObject.OpenTextFile(CountFile,1,FALSE,FALSE)
counter=Out.ReadLine
Out.Close
SET FileObject=Server.CreateObject("Scripting.FileSystemObject")
Set Out=FileObject.CreateTextFile(CountFile,TRUE,FALSE)
Application.lock
If DateDiff("s", Session("RefreshTime"), Now()) > RefreshTime Then
counter= counter + 1
Session("RefreshTime") = Now()
End if
Out.WriteLine(counter)
Application.unlock
Response.Write("<font size=2 color=Olive>")
Response.Write("您是第")
Response.Write("</font>")
Response.Write("<font size=2 color=Fuchsia> ")
Response.Write(counter)
Response.Write(" </font>")
Response.Write("<font size=2 color=Olive>")
Response.Write("位访问者")
Response.Write("</font>")
Out.Close
%>