Return to Snippet

Revision: 47558
at June 10, 2011 03:19 by michaJlS


Initial Code
$ip=NULL; $host = '';
if( isset($_SERVER["HTTP_X_FORWARDED_FOR"]) ) $ip=$_SERVER["HTTP_X_FORWARDED_FOR"];
if( $ip==NULL && isset($_SERVER["REMOTE_ADDR"]) ) $ip = $_SERVER["REMOTE_ADDR"];
else
{
	$ip_tab = explode(".", $ip);
	if($ip_tab[0]=="192" && $ip_tab[1]=="168") $ip = $_SERVER["REMOTE_ADDR"];
}
if($ip!=null) $host = gethostbyaddr($ip);
else $ip = false;

Initial URL


Initial Description
This piece of code is at least ten years old and I don't remember exactly, where I have found it. Probably it had been stolen from my friend VeZyR;)

Initial Title
Obtaining IP and host of visitor

Initial Tags
ip

Initial Language
PHP