如何获知用户的IP?
来源:asp之家 时间:2009-11-24 20:52:00
如何获知用户的IP?
<%
Dim ValidLog
' 日志变量
ValidEntry = True
If not IsEmpty(Session("LogIn")) then ValidEntry = False
' 如果LogIn不为空,则表明用户信息已经写入
If Left(Request.ServerVariables("HTTP_REFERER"), 19)=http://aspxhome.com Then
ValidEntry = False
' 如果访问同一个URL,则不要写进Foryoufile.txt
End if
If Left(Request.ServerVariables("HTTP_REFERER"), 23)=http://www.aspxhome.com Then
ValidEntry = False
End If
If ValidEntry Then
Const ForAppending = 8
Const Create = true
' 如果ValidEntry为真,则写到Foryoufile.txt
Dim FSO
DIM TS
DIM MyFileName
Dim strLog
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 ""
' 写到Foryoufile.txt
Session("LogIn") = "yes"
' 创建session变量,好检查下次ValidEntry的值
Set TS = Nothing
Set FSO = Nothing
End If
%>