PDA

Click to See Complete Forum and Search --> : Some Script


Help
Feb 20th, 2001, 01:59 AM
Hello,

Is there a way to grab everyperson hostname/ip address that visits my site and store them into a txt file for later viewing ?

Thanks

:)

Jerry Grant
Feb 20th, 2001, 04:24 AM
The following can be used in server side script (ASP)
Request.Servervariables("HTTP_REFERER") Where your page was linked from.
Request.ServerVariables("REMOTE_USER") The IP address of the Client PC. This is as their ISP has assigned them for the current session.
To save the IP address and visit time would be as follows:
<%
Sub SaveIPaddress()
Const ForReading = 1, ForWriting = 2, ForAppending = 8
Dim fso, f
Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.OpenTextFile("c:\mySiteVisitors.txt", ForAppending, True)
f.Write Request.ServerVariables("REMOTE_USER") & ", " Now()
f.Close
End Sub
%>
Hope this helps :cool:

Mark Sreeves
Feb 20th, 2001, 04:47 AM
Jerry Grant beat me to it!
the only difference here though is that I used Server.MapPath and filename so the file can be easily viewed through a browser if required if you are using someone else's server.


<html><BODY>
<%@ Language=VBScript%>
<%
dim ip
ip = Request.ServerVariables("REMOTE_ADDR")

Const ForReading = 1, ForWriting = 2, ForAppending = 8

Set fso = CreateObject("Scripting.FileSystemObject")
Set MyFile = fso.OpenTextFile(Server.MapPath(".\iplog.html"), ForAppending, True)
MyFile.Write now() & " " & ip
MyFile.Close
'response.write ip
%>



</BODY>
</HTML>