|
-
Feb 20th, 2001, 02:59 AM
#1
Thread Starter
Addicted Member
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
-
Feb 20th, 2001, 05:24 AM
#2
Fanatic Member
Use the Servervariables object
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:
Code:
<%
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
-
Feb 20th, 2001, 05:47 AM
#3
Frenzied Member
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.
Code:
<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>
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|