You are here: Re: php script for host IP address « All PHP « IT news, forums, messages
Re: php script for host IP address

Posted by Sander on 09/20/05 22:38

"Fred Atkinson" <fatkinson@mishmash.com> schreef in bericht
news:3rl0j1tksltv29vbsll4uoi0c495b78f3o@4ax.com...
> <?php
> echo "Current IP Address: ";
> $ipx = getenv("HTTP_CLIENT_IP") ? getenv("HTTP_CLIENT_IP") : 0
> ;
> $ipx = !$ipx && getenv("HTTP_X_FORWARDED_FOR") ?
> getenv("HTTP_X_FORWARDED_FOR") : 0 ;
> $ipx = !$ipx && getenv("REMOTE_ADDR") ? getenv("REMOTE_ADDR") :
> 0 ;
> echo !$ipx ? "UNKNOWN" : $ipx;
> ?>
>
> I want to modify it to return the host address of the server
> it is running on.

Do you mean this:
<?php
echo "Current IP Address: ";
$ipx = getenv("HTTP_CLIENT_IP") ? getenv("HTTP_CLIENT_IP") : 0;
$ipx = !$ipx && getenv("HTTP_X_FORWARDED_FOR") ?
getenv("HTTP_X_FORWARDED_FOR") : 0 ;
$ipx = !$ipx && getenv("REMOTE_ADDR") ? getenv("REMOTE_ADDR") : 0 ;
echo !$ipx ? "UNKNOWN" : $ipx;

echo "<br>";

echo "Server IP Address: ";
$ipx = getenv("SERVER_ADDR") ? getenv("SERVER_ADDR") : 0;
echo !$ipx ? "UNKNOWN" : $ipx;


?>


Sander Swuste

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация