Results 1 to 3 of 3

Thread: Some Script

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Nov 2000
    Posts
    143
    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


  2. #2
    Fanatic Member Jerry Grant's Avatar
    Join Date
    Jul 2000
    Location
    Dorset, UK
    Posts
    810

    Smile 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
    Jerry Grant................tnarG yrreJ
    Website: <JG-Design></.net>
    Email: [email protected]
    Working towards a bug free world......
    (Not a Microsoft employee)

  3. #3
    Frenzied Member Mark Sreeves's Avatar
    Join Date
    Nov 1999
    Location
    UK
    Posts
    1,845
    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>
    Mark
    -------------------

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width