[Release]Basic Auto-Show External IP

11/07/2009 08:00 stealarcher#1
Ok, basic and simple PHP script you can add to your website. In any file with the extension .php you can put this script. Basically what it does is show the servers external ip address, even when visited by the server itself. (Typically when a server visits its own server, it will show 127.0.0.1) This comes in handy when you have a dynamic ip especially, this way you dont have to keep your website up to date with your ip everytime it changes :P (if you know a little coding maybe even make an automatic server.dat maker ;) ;))

Script:
PHP Code:
<?php
$page_contents 
file_get_contents("http://www.whatismyip.org/");
//You can use any website you want (that shows your ip) to get an ip address, this is the fastest one because it doesnt have to go threw a lot of page content before the page loads
$regex "([0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3})";
preg_match($regex $page_contents$matches);

echo 
'Your External IP: <strong>' $matches[0] . '</strong>';
?>
11/07/2009 08:20 ~Yuki~#2
a server.dat maker would be easier as a EXE but anyway nice lol
11/07/2009 08:47 stealarcher#3
Lol true, but some people post theirs on the website etc to download. Could easily change the file their downloading (if its on ur server to download) to the current IP.
11/07/2009 09:24 ChingChong23#4
no need for the regular expressions, whatsmyip do offer a page somewhere with just the plain text of your IP. find it
11/07/2009 14:56 stealarcher#5
thats what im using. [Only registered and activated users can see links. Click Here To Register...] plain text to display your ip. No other content being gathered, simply your ip. Saves a lot of load time.