2 回答
TA贡献1825条经验 获得超6个赞
可以参考一下。
<script language="vbscript" runat="server">
Sub Application_OnStart
Application("visitors")=0
Application("views")=0
Dim fs, file, count
Set fs = Server.CreateObject("Scripting.FileSystemObject")
Set file = fs.OpenTextFile(Server.MapPath("statistics.dat"), 1)
If (not file.AtEndOfStream) Then
count = file.ReadLine
End If
If (isnumeric(count)) Then
Application("views") = count
End If
End Sub
Sub Session_OnStart
Application.Lock
Application("visitors")=Application("visitors")+1
Application("views")=Application("views")+1
Set fs = Server.CreateObject("Scripting.FileSystemObject")
Set file = fs.OpenTextFile(Server.MapPath("statistics.dat"), 2)
file.WriteLine Application("views")
Application.UnLock
End Sub
Sub Session_OnEnd
Application.Lock
Application("visitors")=Application("visitors")-1
Application.UnLock
End Sub
</script>
添加回答
举报