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

Posted by Fred Atkinson on 09/20/05 21:45

I have a script that gives the public IP address of the client
PC. It appears below:

<?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.

Can anyone tell me how to modify it or where I can get a
script that will do this. I would guess that you need to change
HTTP_CLIENT_IP to HTTP_SERVER_IP or HTTP_HOST_IP. Not sure about the
REMOTE_ADDR or what it might need to be changed to.

I intend to make a PHP page that is customized and use the
above script plus the new script so it gives both the client and host
IP address. It is for some experiments in a Cisco lab. Since there
will be various servers out there, I want to be able to look at the
page and find out what server they have connected to.

Regards,



Fred

 

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

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