Her

Home Web Programming PHP Get Hostname Behind Proxies

Get Hostname Behind Proxies

Author: Andrew Makowsky Author's URL: http://www.bloogrape.co.uk More by this author

Get Hostname Behind Proxies This is a very simple code and works for anybody who is behind proxies and people who are not. This might be usfull if your have cable users visiting your site.

<?php $ip = getenv('REMOTE_HOST');
if(!$ip) {
$ip = getenv('HTTP_X_FORWARDED_FOR');
}
if(!$ip) {
$ip = $HTTP_X_FORWARDED_FOR;
}
if(!$ip) {
$ip = getenv('REMOTE_ADDR');
}
if(!$ip) {
$ip = $REMOTE_ADDR;
}
$ip = @GetHostByAddr($ip);
echo $ip;
?>