Return to Snippet

Revision: 32759
at November 6, 2012 08:37 by jprochazka


Updated Code
<?php
function getRealIp()
{
 if (!empty($_SERVER['HTTP_CLIENT_IP'])){
    $ip=$_SERVER['HTTP_CLIENT_IP'];
 }
 elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])){
   $ip=$_SERVER['HTTP_X_FORWARDED_FOR'];
 }
 else{
   $ip=$_SERVER['REMOTE_ADDR'];
 }
 return $ip;
}

?>

Revision: 32758
at October 2, 2010 01:37 by jprochazka


Updated Code
<?php

function getRealIPAddr()
{
 if (!empty($_SERVER['HTTP_CLIENT_IP'])){
    $ip=$_SERVER['HTTP_CLIENT_IP'];
 }
 elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])){
   $ip=$_SERVER['HTTP_X_FORWARDED_FOR'];
 }
 else{
   $ip=$_SERVER['REMOTE_ADDR'];
 }
 return $ip;
}

?>

Revision: 32757
at October 2, 2010 01:37 by jprochazka


Initial Code
<?php

function getRealIPAddr()
{
 if (!empty($_SERVER['HTTP_CLIENT_IP'])){
    $ip=$_SERVER['HTTP_CLIENT_IP'];
 }
 elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])){
   $ip=$_SERVER['HTTP_X_FORWARDED_FOR'];
 }
 else{
   $ip=$_SERVER['REMOTE_ADDR'];
 }
 return $ip;
}

?>

Initial URL

                                

Initial Description
A more reliable way to obtain a visitor's IP address.

Initial Title
Get a visitor\'s real IP address.

Initial Tags

                                

Initial Language
PHP