Obtener la IP real del usuario con PHP

Esta función nos permitirá obtener la IP real del usuario el cual lo he encontrado en otro blog pero ya no me acuerdo de la pagina pero quiero compartir con ustedes por que a mi me ha sido de gran utilidad y funciona sin problemas.
La función básicamente nos devuelve la ip o ip's del usuario.

[php]
// Funcion para obtener la ip del usuario
function getRealIP(){
if(isset($_SERVER)){
if(isset($_SERVER["HTTP_X_FORWARDED_FOR"])){
return $_SERVER["HTTP_X_FORWARDED_FOR"];
}

if(isset($_SERVER["HTTP_CLIENT_IP"])){
return $_SERVER["HTTP_CLIENT_IP"];
}

return $_SERVER["REMOTE_ADDR"];
}

if(getenv('HTTP_X_FORWARDED_FOR')){
return getenv('HTTP_X_FORWARDED_FOR');
}

if(getenv('HTTP_CLIENT_IP')){
return getenv('HTTP_CLIENT_IP');
}

return getenv('REMOTE_ADDR');
}

#Ejemplo
//$ip = getRealIP();
//echo 'IP: ' . $ip;
?>
[/php]

Comentarios

  1. These welcome bonuses are sometimes free from any deposit requirement, meaning that you just wouldn't have to place down any cash begin out|to begin} enjoying in}. It is an effective method to get conversant in the positioning examine out|and take a glance at} a few of the the} games without any 온라인카지노 investment. You can place reside bets on an enormous number of sports occasions corresponding to soccer, ice hockey and tennis in our innovative Sportsbook 2.0. Live betting means you can to|you possibly can} place your wager quickly as} the circumstance has already began and is underway. It is an thrilling type of betting that gives you action-packed access to many more markets than in traditional pre-event sports betting. The Sportsbook 2.0 tool may even grant you access to our Bet Assist tool, which can provide you a aggressive edge when you place your bets.

    ResponderBorrar

Publicar un comentario

Entradas más populares de este blog

Obtener el anterior y siguiente registro de una tabla MySQL con PHP