The notify() function only fills in REMOTE_ADDR to the notification emails, which hides the real client if one or more proxys are involved and the HTTP_X_FORWARDED_FOR header is available.
Andreas has already written a clientIP() function in common.php which returns the IP address list, so I have modified the notify() function to use it, and my own function to resolve the comma-separated IP address list.
These changes have been tested both with and without a client proxy.
Firstly, the new function:
/**
* Convert one or more comma separted IPs to hostnames
*
* It returns a comma separated list of hostnames
*
* @author Glen Harris <
astfgl@iamnota.org>
*/
function gethostsbyaddrs($ips){
$host = array();
if (!($ip = explode(",", $ips))) {
return "";
}
foreach($ip as $i){
$host[] = gethostbyaddr($i);
}
return join(',',$host);;
}
Secondly, in the notify() function:
- $text = str_replace('@IPADDRESS@',$_SERVER['REMOTE_ADDR'],$text);
- $text = str_replace('@HOSTNAME@',gethostbyaddr($_SERVER['REMOTE_ADDR']),$text);
+ $ip = clientIP();
+ $text = str_replace('@IPADDRESS@',$ip,$text);
+ $text = str_replace('@HOSTNAME@',gethostsbyaddrs($ip),$text);
glen.