if ( ! empty( $_SERVER['HTTP_X_FORWARDED_FOR'] )
&& preg_match( '/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/',
$_SERVER['HTTP_X_FORWARDED_FOR'] ) )
$_SERVER['REMOTE_ADDR'] = $_SERVER['HTTP_X_FORWARDED_FOR'];
if ( ! empty( $_SERVER['HTTP_X_FORWARDED_FOR'] )
&& preg_match( '/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/',
$_SERVER['HTTP_X_FORWARDED_FOR'] ) )
$_SERVER['REMOTE_ADDR'] = $_SERVER['HTTP_X_FORWARDED_FOR'];