I am working on a really simple stats / logging script for my network of new sites. I am stuck at the moment trying to get the user's IP for my statistics db table and reporting.
There are quite a few possible 'variables' containing this information and this is a list I compiled so far by searching for this info over the last few days:
Code:<?php
// list of possible variables containing user's IP
$_SERVER['HTTP_X_FORWARDED_FOR'];
$_SERVER['HTTP_X_FORWARDED'];
$_SERVER['HTTP_FORWARDED_FOR'];
$_SERVER['HTTP_FORWARDED'];
$_SERVER['HTTP_X_COMING_FROM'];
$_SERVER['HTTP_COMING_FROM'];
$_SERVER['HTTP_CLIENT_IP'];
$_SERVER['HTTP_VIA'];
$_SERVER['REMOTE_ADDR'];
?>
Do you know of any others for this list? Or how many of those on this list are even still valid?
Besides the variable $_SERVER['REMOTE_ADDR'], which is nearly always set, why and when are the others available to a script?