Проверка IP адресов по Who-Is сервису.Проблема!

X-Dracula

Guest
Проверка IP адресов по Who-Is сервису.Проблема!

Hello all.
Столкнулся с такой проблемой:
Есть список IP-адресов в файле.
Скрипт должен проверить каждый IP-адрес по Who-Is сервису и занести страну в таблицу.
Но почему-то нижеприведеный скрипт этого не делает :(
Я лишь смог добиться того,что скрипт проверяет только 1 IP-адрес заменив переменную $target на REMOTE_ADDR
А мне нужно чтобы он проверил каждый Ip в файле.
Помогите пожалуйста !!!!
Вот скрипт:

PHP:
<?
// Country Stats

echo "<html><body bgcolor=black>";
echo "<center><font color=orange><b><tt>Country Statistic</b></font><br><br>";
echo "<table align=center cols=4 border=1>";
echo "<tr><td width=40% height=20%><tt><font color=pink>Country</td><td><tt><font color=pink>Total</td><td><tt><font color=pink>Flag</td></tt><td><tt><font color=pink>IP</td></tt>";

$file=file("ips.txt");
foreach ($file as $ips =>$target)
{
$nextServer = "whois.ripe.net";
   if($nextServer){
     $buffer = "";
     if(! $sock = fsockopen($nextServer, 43, &$num, &$error, 10)){
       unset($sock);
       }
     else{
       @fputs($sock, "$target$extra\n");
       while (!feof($sock))
         $buffer .= fgets($sock, 10240);
       fclose($sock);
       }
     }
  $buffer = str_replace(" ", "&nbsp;", $buffer);
  $msg = nl2br($buffer);
$posun = strpos ($msg, "0.0.0.0&nbsp;-&nbsp;255.255.255.255");
if ($posun>0){
$rest="unknown";
$msg=" ";}
$posus = strpos ($msg, "Florida");
if ($posus>0){
$rest="US";
$msg="US";}
else{
$pos = strpos ($msg, "country:");
if ($pos>0){$rest = substr ($msg, $pos+44, 2);}
 $rest=str_replace(" ", "", $rest);
}
strtolower($rest);
}
}


echo "<tr><td><tt><font color=whitegreen><font color=yellow><strong>$rest<br></strong></font></tt></td><td><tt><font color=whitegreen></tt></td><td><tt><font color=whitegreen><img src=flags/$rest.gif></tt></td><td><tt><font color=whitegreen>$target</tt></td><td><tt><font color=whitegreen></tt></td><td><tt><font color=whitegreen></tt></td>";
?>
Заранее благодарен!
 

Фанат

oncle terrible
Команда форума
никогда не понимал, зачем лазить сокетом, если можно пользоваться локальным сервисом
 
Сверху