<?php
$filename="hosts.txt";
if(!is_file($filename))
{
   echo "$filename not found";
   exit;
}
foreach(file($filename) as $line) {
    $line =trim($line);
    if(strpos($line,":")===false)
        continue;
    list($host,$port)=explode(":",$line);
    $fp = @fsockopen($host, $port, $errno, $errstr, 30);
    $result="GOOD";
    if(!$fp)
    {
        $result="BAD,$errstr($errno)";
    }
    echo  "$line,$result\n";
}

?>