Forum Moderators: coopster
function getrealip()
{
if (isset($_SERVER)){
if(isset($_SERVER["HTTP_X_FORWARDED_FOR"])){
$ip = $_SERVER["HTTP_X_FORWARDED_FOR"];
if(strpos($ip,",")){
$exp_ip = explode(",",$ip);
$ip = $exp_ip[0];
}
}else if(isset($_SERVER["HTTP_CLIENT_IP"])){
$ip = $_SERVER["HTTP_CLIENT_IP"];
}else{
$ip = $_SERVER["REMOTE_ADDR"];
}
}else{
if(getenv('HTTP_X_FORWARDED_FOR')){
$ip = getenv('HTTP_X_FORWARDED_FOR');
if(strpos($ip,",")){
$exp_ip=explode(",",$ip);
$ip = $exp_ip[0];
}
}else if(getenv('HTTP_CLIENT_IP')){
$ip = getenv('HTTP_CLIENT_IP');
}else {
$ip = getenv('REMOTE_ADDR');
}
}
return $ip;
}
$MyipAddress = getrealip();
echo $MyipAddress;
AFAIK you can only retrieve the IP address sent to the server.Some law-abiding proxies--if that isn't an oxymoron--include an X-Forwarded-For header. (But what are the commas doing? Or is that a decimal-separator mixup and it was supposed to be . period?)
include an X-Forwarded-For header. (But what are the commas doing?
can contain multiple IP addresses, comma separatedWhoops! Forgot about those. Admittedly the more IP addresses there are, the more suspicious I get. Especially when one or more of them is "unknown" or "127.0.0.1"
the session must keep real user info somewhereI think that was keyplyr's point about "sent to the server". You can only know what they choose to tell you.