I’m getting Notice: Undefined index: HTTP_X_FORWARDED_FOR in the Function below:
function _ip( )
{
return ( preg_match( "/^([d]{1,3}).([d]{1,3}).([d]{1,3}).([d]{1,3})$/", $_SERVER['HTTP_X_FORWARDED_FOR'] ) ? $_SERVER['HTTP_X_FORWARDED_FOR'] : $_SERVER['REMOTE_ADDR'] );
}
You should be using the getenv() method instead of $_SERVER.
Also, I would stick with just
$ip = getenv('REMOTE_ADDR')as spammers can set theHTTP_X_FORWARDED_FORheader themselves to anything they want while they can’t change the remote_addr. The problem is that “good” proxies tell the truth aboutHTTP_X_FORWARDED_FORso you would miss that.