你是否有时想知道什么人访问你的站点,什么时间,IP地址等。下面我就这个问题向
大家来阐述一下。这个例子使用文本文件来写入用户的信息创建一个logfile.a 放
在每一个a 的页面的顶端<!--#Include File="LogFile.a quot;-->当有人来访问你
的站点logfile.a 自动把他的信息写入LogFile.txt,如果相关的URl一样的话则不
写入文件
File: LogFile.a
<%
Dim ValidEntry ' Log variable
' First set that this log is valid
ValidEntry = True
' If Se ion Variable "LogI quot; is not empty
' that mean this person has already been logged
' then set ValidLog to False
If not IsEmpty(Se ion("LogI quot;)) then ValidEntry = False
' Here you can add different restriction
' If the refering url is from same site
' don't write to log file
If Left(Request.ServerVariables("HTTP_REFERER"), 17)
="http://deva .com" Then
ValidEntry = False
End if
If Left(Request.ServerVariables("HTTP_REFERER"), 21)
="http://www.deva .com" Then
ValidEntry = False
End If
' Now if ValidEntry is True then enter to log file
If ValidEntry Then
Co t ForA ending = 8
Co t Create = true
Dim FSO
DIM TS
DIM MyFileName
Dim strLog
MyFileName = Server.Ma ath("MyLogFile.txt")
Set FSO = Server.CreateObject(" cripting.FileSystemObject")
Set TS = FSO.OpenTextFile(MyFileName, ForA ending, Create)
' Store all required values in strLog
strLog = " lt r> lt gt lt gt quot; &am now &am " lt;/ gt; "
strLog = strLog &am Request.ServerVariables("REMOTE_ADDR") &am " "
strLog = strLog &am Request.ServerVariables("HTTP_REFERER") &am " "
strLog = strLog &am Request.ServerVariables("HTTP_USER_AGENT") &am " lt R> quot;
' Write current information to Log Text File.
TS.write strLog
TS.Writeline " quot;
' Create a se ion varialbe to check next time for ValidEntry
Se ion("LogI quot;) = "ye quot;
Set TS = Nothing
Set FSO = Nothing
End If
%>
an>


