Capture IP Address?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts
  • ianhull
    Forum Member
    • Jul 2004
    • 314

    Capture IP Address?

    Can anyone please help me capture the ip address of the connected PC and write it to a html file on my server

    I am trying to auto connect to my dynamic IP by simply creating a html page with the auto redirect script
  • Corey
    Indigo Rose Staff Alumni
    • Aug 2002
    • 9741

    #2
    Hi. Well you could use php to do it but if you write a file you need to CHMOD, here's a way to do it without CHMODing, just save this script to a file on your server, i.e. "echoIP.php" then do an HTTP submit to this script and it will echo back your IP as a result.

    PHP Code:
    <?php
    $ip 
    GetHostByName($REMOTE_ADDR);
    echo 
    $ip;
    ?>
    Hope that helps.

    Comment

    • Worm
      Indigo Rose Customer
      • Jul 2002
      • 3967

      #3
      Why not use the script I sent you before



      then grab the last record written to get the IP address.

      Comment

      • ianhull
        Forum Member
        • Jul 2004
        • 314

        #4
        Thanks for the replies,

        I have been working out how to use the one you sent me before with the Access database but because if is for offline use I am finding it hard.

        <script id=clientEventHandlersJS language=javascript>
        <!--
        function window_onload() {
        window.open('http://000.000.000.000,'redirect_html','scrollbars=yes,re sizable=no,menubar=no,titlebar=no,status=no' );
        window.history.go(-1);
        }
        //-->
        </script>

        -----Corey, Thanks but my server doesn't support PHP. I suppose I will also have to consider upgrading.
        Thanks.

        I really need to place this sort of Javascript into the webpage so it will redirect to the ip

        I will look into having .asp write this on the fly.

        Any other ideas will be much appreciated.

        Thanks in advance.

        Comment

        • Worm
          Indigo Rose Customer
          • Jul 2002
          • 3967

          #5
          I'm sure I can get you pointed in the right direction, but I don't understand what it is you're trying to do.

          All you want is a page set to redirect to an IP address. This page is created by browsing to a page from the dynamically assigned pc and the asp page is to write out the script, correct?
          Last edited by Worm; 01-27-2005, 06:28 AM.

          Comment

          • Corey
            Indigo Rose Staff Alumni
            • Aug 2002
            • 9741

            #6
            Sounds like ian is trying to bind a web site to content on a server with a dynamic IP...

            Comment

            • Worm
              Indigo Rose Customer
              • Jul 2002
              • 3967

              #7
              Ian,

              Give this a try.

              A couple things need to be set.
              1. Make sure your IUSR account has write permission in the folder this script is in
              2. The file you are writing out to must exist, so create a blank one for the first run.
              3. Change the path to the file you are writing out

              Code:
              <html>
              <head>
              <meta **********="Content-Type" content="text/html; charset=windows-1252">
              <title>ReDirect Writer</title>
              <%
              	Dim strIPAddress
              
              		strIPAddress = Request.ServerVariables("HTTP_X_FORWARDED_FOR")
              		if strIPAddress="" Then 
                  		strIPAddress = Request.ServerVariables("REMOTE_ADDR")
              		end if
              	
              	 strIPAddress = "response.redirect (" & chr(34) & "http://" & strIPAddress & chr(34) & ")"
                 set fs = CreateObject("Scripting.FileSystemObject")
                 set file = fs.OpenTextFile("E:\WebSites\wwwroot\Test\redirect.asp", 2)
                 file.WriteLine("<% " & strIPAddress & chr(37) & ">" )
                 file.Close()
              %>
              </head>
              <body>
              Redirect File Created.
              </body>
              </html>

              Comment

              • ianhull
                Forum Member
                • Jul 2004
                • 314

                #8
                That's right Corey,

                This is what I am aiming to achieve.

                Thanks for the script Worm, I will work with this and I will let you know the outcome.

                Thanks Guys!

                :yes

                Comment

                • Worm
                  Indigo Rose Customer
                  • Jul 2002
                  • 3967

                  #9
                  Ian,

                  Have you looked into DynDNS

                  It's a free service for dynamic ip servers. There are several clients available for free also that will autmatically change your host ip when it detects an ip change. I've also noticed that the newer LinkSys broadband routers have a client for DDNS built into them too, and one of the supported sights is DynDNS.

                  I'm not just a fan, I'm a client (er... well at least my pc is) I use it for my home pc, so that when the wife calls me at work having problems with the pc, I can RAdmin in and take care of the problem.

                  Comment

                  • Corey
                    Indigo Rose Staff Alumni
                    • Aug 2002
                    • 9741

                    #10
                    DynDNS.org are fanatastic. I was going to reccomend it but I'm not too up on the whole dynamic IP aspect of what they do. But I can second Worm's testimony, they are great. They've been around for a long time and their free services are superb. I donated to them a couple times, great set of folks... :yes

                    Comment

                    • ianhull
                      Forum Member
                      • Jul 2004
                      • 314

                      #11
                      Thanks Worm, Corey, I have been looking into the dynip service which is also FREE

                      I can download a little app from them and it does everything I wanted to make.

                      I would still like to make my own and if I get there I will post my little app back to share.

                      Thanks for your help.

                      much appreciated.

                      :yes

                      Comment

                      • Corey
                        Indigo Rose Staff Alumni
                        • Aug 2002
                        • 9741

                        #12
                        Ah yes, now I remember it all. That's how I did this once so I could run a test server from my home box. I believe I used DYNDNS.org and like you say I had to download a client which ran in my taskbar. Worked very well.

                        Yes that's definitely the best way to go Ian, can't beat that. Then you can just point a domain or free subdomain at your account and you'll get 100% reliability.

                        Man I forgot all about that. that was back in "the day", but it was a really cool little system for doing what you need. I remember feeling very victorious once I got it running.

                        Comment

                        • goukilord10
                          Forum Member
                          • Mar 2005
                          • 130

                          #13
                          Hi. Well you could use php to do it but if you write a file you need to CHMOD, here's a way to do it without CHMODing, just save this script to a file on your server, i.e. "echoIP.php" then do an HTTP submit to this script and it will echo back your IP as a result.

                          PHP Code:
                          <?php
                          $ip = GetHostByName($REMOTE_ADDR);
                          echo $ip;
                          ?>


                          Hope that helps.
                          and how do i get it in a ams variable ?
                          sorry i dont have much knowledge in PHP or server scripting in general.

                          Comment

                          Working...
                          X