网络编程
位置:首页>> 网络编程>> Asp编程>> asp如何准确获知对方来访问的时间和URL?

asp如何准确获知对方来访问的时间和URL?

  发布时间:2010-07-07 12:25:00 

标签:url,来源,asp

如何准确获知对方来访问的时间和URL?

代码如下:

logfile.asp

<%
Dim ValidLog 
' 设置日志变量
ValidEntry = True
If not IsEmpty(Session("LogIn")) then ValidEntry = False
' 如果 LogIn 不为空,表明用户信息已经写进
If Left(Request.ServerVariables("HTTP_REFERER"), 17)="http://aspxhome.com" Then 
  ValidEntry = False
End if
If Left(Request.ServerVariables("HTTP_REFERER"), 21)="http://www.aspxhome.com" Then
  ValidEntry = False
' 如果访问的是同一个URL,则不写进日志文件
End If
If ValidEntry Then  
  Const ForAppending = 8
  Const Create = true
  Dim FSO
  DIM TS
  DIM MyFileName
  Dim strLog
' 如果ValidEntry为真,则写进日志文件
  Set FSO = Server.CreateObject("Scripting.FileSystemObject")
  Set TS = FSO.OpenTextFile(MyFileName, ForAppending, Create)
   
  strLog = "<br><P><B>" & now & "</B> "
  strLog = strLog & Request.ServerVariables("REMOTE_ADDR") & " "
  strLog = strLog & Request.ServerVariables("HTTP_REFERER") & " "
  strLog = strLog & Request.ServerVariables("HTTP_USER_AGENT") 
  ' 保存信息
& "<BR>"
  TS.write strLog
  TS.Writeline ""
' 把当前的信息写进文本文件里面
  Session("LogIn") = "yes"
' 创建一个session变量,用于检查下次ValidEntry的值
  Set TS = Nothing
  Set FSO = Nothing
End If
%>

0
投稿

猜你喜欢

手机版 网络编程 asp之家 www.aspxhome.com