"SSH", "80"=>"HTTP", "8711"=>"aMule"); //Function to check given serivce function check_port($port) { $conn = @fsockopen("127.0.0.1", $port, $errno, $errstr, 0.2); if ($conn) { fclose($conn); return true; } } //Function to check all the services stored in scvs and generate report function server_report($svcs) { $report = array(); foreach ($svcs as $port=>$service) { $report[$service] = check_port($port); } return $report; } //Generated report $report = server_report($svcs); ?>