<?php
include("geoipcity.inc");
include("geoipregionvars.php");
function getip(){ 
if (getenv("HTTP_CLIENT_IP") && strcasecmp(getenv("HTTP_CLIENT_IP"), "unknown")) 
$insrtip = getenv("HTTP_CLIENT_IP"); 
else if (getenv("HTTP_X_FORWARDED_FOR") && strcasecmp(getenv("HTTP_X_FORWARDED_FOR"), "unknown")) 
$insrtip = getenv("HTTP_X_FORWARDED_FOR"); 
else if (getenv("REMOTE_ADDR") && strcasecmp(getenv("REMOTE_ADDR"), "unknown")) 
$insrtip = getenv("REMOTE_ADDR"); 
else if (isset($_SERVER["REMOTE_ADDR"]) && $_SERVER["REMOTE_ADDR"] && strcasecmp($_SERVER["REMOTE_ADDR"], "unknown")) 
$insrtip = $_SERVER["REMOTE_ADDR"]; 
else 
$insrtip = "unknown"; 
return($insrtip); 
} 
$insrtip = getip();
$gi = geoip_open("./GeoLiteCity.dat",GEOIP_STANDARD);
$record = GeoIP_record_by_addr($gi,$insrtip);
geoip_close($gi);

if($record) {
$visite_address=$record->country_code.",".$record->country_name.",".$GEOIP_REGION_NAME[$record->country_code][$record->region].",".$record->city;
} else {
$visite_address="Unkown address";
}
$location=$visite_address;
 ?>
