PHP код:
<?php
if(!$_POST['IP']) exit ("Games: Читаем документацию по использованию сервиса!");
if($_POST['IP'] == '127.0.0.1') $text = file_get_contents('http://ip-whois.net/ip_geo.php?ip=' . $_SERVER['REMOTE_ADDR'] . "");
else $text = file_get_contents('http://ip-whois.net/ip_geo.php?ip=' . $_POST['IP'] . "");
if($_POST['Search'] == 0) ResponseGeoInfo('Страна', 'txt', 8, 55, $text);
else if($_POST['Search'] == 1) ResponseGeoInfo('Регион', 'Город', 8, 6, $text);
else if($_POST['Search'] == 2) ResponseGeoInfo('Город', 'txt', 7, 14, $text);
else if($_POST['Search'] == 3)
{
echo 'Страна: ';
ResponseGeoInfo('Страна', 'txt', 8, 55, $text);
echo ' Регион: ';
ResponseGeoInfo('Регион', 'Город', 8, 6, $text);
echo ' Город: ';
ResponseGeoInfo('Город', 'txt', 7, 14, $text);
}
function ResponseGeoInfo($SWord, $EWord, $SIndex, $EIndex, $text)
{
$start = strpos($text, $SWord);
$end = strpos($text, $EWord, $start);
echo substr ($text , $start + $SIndex, ($end - $EIndex) - ($start + $SIndex));
}
?>