Код
<?php
$client = @$_SERVER['HTTP_CLIENT_IP'];
$forward = @$_SERVER['HTTP_X_FORWARDED_FOR'];
$remote = @$_SERVER['REMOTE_ADDR'];
$result = array('city'=>'');
$results = array('county'=>'');
if(filter_var($client, FILTER_VALIDATE_IP)) $ip = $client;
elseif(filter_var($forward, FILTER_VALIDATE_IP)) $ip = $forward;
else $ip = $remote;
$ip_data = @json_decode(file_get_contents("http://www.geoplugin.net/json.gp?ip=".$ip));
if($ip_data && $ip_data->geoplugin_countryName != null)
{
$result = $ip_data->geoplugin_countryName;
$resultsss = $ip_data->geoplugin_region;
$resultss = $ip_data->geoplugin_city;
$data = date('Y-m-d H:i:s');
}
$h=fopen("test.txt","at");
// fwrite($h,$_SERVER['REMOTE_ADDR']."\r\n");
// fwrite($h,$_SERVER['SERVER_NAME']."-".$_SERVER['SERVER_SOFTWARE']."\r\n");;
fwrite($h,"Дата и Время: ".$data."\r\n");;
fwrite($h,"Страна: ".$result."\r\n");;
fwrite($h,"Регион: ".$resultsss."\r\n");;
fwrite($h,"Город: ".$resultss."\r\n");;
fwrite($h,"IP адрес: ".$ip."\r\n");;
fwrite($h,"________________________\r\n");;
fclose($h);
echo "Страна: ".$result;
echo "Регион: ".$resultsss;
echo "Город ".$resultss;
echo "IP: ".$ip;
echo "Время: ".$data;
?>
Возможно поможет, но это на PHP