Post a comment
You can use the following code to retrieve your client's external address.
$ nano myip.php
<?php
function getVisitorIp()
{
// Recogemos la IP de la cabecera de la conexión
if (!empty($_SERVER['HTTP_CLIENT_IP']))
{
$ipAdress = $_SERVER['HTTP_CLIENT_IP'];
}
// Caso en que la IP llega a través de un Proxy
elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR']))
{
$ipAdress = $_SERVER['HTTP_X_FORWARDED_FOR'];
}
// Caso en que la IP lleva a través de la cabecera de conexión remota
else
{
$ipAdress = $_SERVER['REMOTE_ADDR'];
}
return $ipAdress;
}
echo getVisitorIp();
?>
You may want to try out the TrueIP Basic tool. With no parameters, it will show the public IP in your taskbar. You can minimize the window that pops up, and it will just keep your taskbar up to date with the current public IP address. You may need to use the --checkurl parameter with a different provider, as the default myip.dnsomatic.com seems to be a bit flaky these days (see the FAQ section on this page).
-Joey