Hi there everyone!
I'm trying to modify my code to record the actual IP of users using things like the Google data saver proxies, etc. I did the following:
//Get the forwarded IP if it exists
IF(array_key_exists('X-Forwarded-For', $_SERVER) && filter_var($_SERVER['X-Forwarded-For'], FILTER_VALIDATE_IP, FILTER_FLAG_IPV4)){
$ip = $headers['X-Forwarded-For'];
$proxy = $_SERVER['REMOTE_ADDR'];
}ELSEIF(array_key_exists('HTTP_X_FORWARDED_FOR', $_SERVER) && filter_var($_SERVER['HTTP_X_FORWARDED_FOR'], FILTER_VALIDATE_IP, FILTER_FLAG_IPV4)){
$ip = $headers['HTTP_X_FORWARDED_FOR'];
$proxy = $_SERVER['REMOTE_ADDR'];
}ELSE{
$ip = filter_var($_SERVER['REMOTE_ADDR'], FILTER_VALIDATE_IP, FILTER_FLAG_IPV4);
$proxy = 'NULL';
}
but I'm reading through my searches that I should also look for "via". If I add the view else, would this be an ok method of determining and logging a transparent proxy or should I be handling it in a different way?
Thanks for your time!