$ipaddress=$_SERVER['HTTP_HOST'];
$license_key="enter your license key";
$query = "http://geoip3.maxmind.com/b?l=" . $license_key . "&i=" . $ipaddress;
$url = parse_url($query);
$host = $url["host"];
$path = $url["path"] . "?" . $url["query"];
$timeout = 1;
$fp = fsockopen ($host, 80, $errno, $errstr, $timeout)
or die('Can not open connection to server.');
if ($fp) {
fputs ($fp, "GET $path HTTP/1.0\nHost: " . $host . "\n\n");
while (!feof($fp)) {
$buf .= fgets($fp, 128);
}
$lines = explode("\n", $buf);
$data_geo = $lines[count($lines)-1];
fclose($fp);
} else {
# enter error handing code here
}
//echo $data;
$geo = explode(",",$data_geo);print_r($geo);enter code here