//$fp = fopen($file, "rw");
The mode "rw" doesn't exist (http://www.php3.de/manual/en/function.fopen.php) You only can use 'r', 'r+', 'w', 'w+', 'a' or 'a+'
If safe_mode is off you can ping to the target:
<?
$ip = "www.lin.ux";
$online=exec("ping $ip -c 1"); // linux
// $online=exec("ping $ip -n 1"); // only WINDOZ
if (eregi("unbekannter host", $online) || eregi("unknown host", $online)) {
print "NO ping to $ip<br>\n";
} else {
print "ping to $ip successfully<br>\n";
}
?>
Another posibility (without safe_mode)
$socket = fsockopen($host, $port, &$errno, &$errstr);
if ($socket) {
echo "Reaction on Port $host : $port";
}