Hi CHris! > has anyone written a script to check if a host is alive - > like a ping script ?
Something like this? BTW, any hints to weak or wrong code are welcome, I'm not this experienced with PHP ;) Cheers, Kiko P.S.: There are some formatting strings and some variables stored in constants.php and a simple error function in functions.php, but that's all, I guess anyone can change this... ;) <html> <head><title>.o0o.linktest.o0o.</title></head> <body bgcolor="#000099"> <?php require("constants.php"); require("functions.php"); echo $f_h1 . "Check your Links" .$f_h1e; if (isset($HTTP_GET_VARS["url"])) { $url = $HTTP_GET_VARS["url"]; $tempName = $url; $tempDesc = ""; $tempPort = 80; $tempUrl = str_replace("http://", "", $url); $tempUrl = str_replace("/", "", $tempUrl); $fp = fsockopen ($tempUrl, $tempPort, &$errno, &$errstr, 30); if (!$fp) { echo "<br>" . $f1 . "Link fehlerhaft: " . $url . $f1_e . "<br>\n"; } else { fputs ($fp, "GET / HTTP/1.0\r\n\r\n"); $code = fgets($fp,1024); $code = str_replace("HTTP/1.1 ", "", $code); $code = (int)$code; if ($code == 200) echo $f1 . "Link okay ($code)<br>" . $f1_e; else { while ($code = fgets($fp, 2048)) { echo $f1 . ">>" . $code . "<br>" . $f1_e; } } fclose($fp); } echo "<a href=\"" . $url . "\">" . $f_link . $tempName . $f_linke . "</a><br>"; } ?> <form action="linktest.php" method="get"> <table cellspacing="0" cellpadding="0" border="0" width="50%"> <tr> <td> <input type="text" name="url"> </td> <td> <input type="submit"> </td> </tr> </table> </form> </body> </html> -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php