After searching like mad I finally found a script that, after a little modification, will do exactly what I need it to do. It pings a site and simply generates output stating whether that site is up or down. It works beautifully will practically any DNS name.
Here's the problem. If the name does not use "http://" the script will show that the site is down. Here's what I mean:
I'm trying to ping a game server with the name, "lakesuperior.owo.com". If you ping this from a command line it works fine. If you try pinging it as "http://lakesuperior.owo.com" from a command line you will see that the host is unknown. This is what happens when you run the script. There is a very long delay and then it tells you that the server is down.
I'm including the code here. I've commented out some lines and added the static variable for the URL at the top. You can change that to "ibm.com" or whatever and you'll see that the script works just fine.
Here's the code:
<?php
$link="lakesuperior.owo.com";
function chkurl($link){
$churl = @fopen("http://".$link,'r');
if (!$churl) {
$meldung="site link <b>http://$link <font color=\"red\"> is down!!</font></b><br><br>\n";
}else{
$meldung="site link <a href=\"http://$link\" target=_blank><b>http://$link</b></a> OK!<br>";
}
return $meldung;
}
function ping($link){
$packs=5;
for ($tt=0;$tt<=$packs;$tt++){
$a=getmstime();
$churl = @fsockopen(server($link), 80, &$errno, &$errstr, 20);
$b=getmstime();
if (!$churl){
$zeit="down!!"; break;
}
$zeit=$zeit+round(($b-$a)*1000);
@fclose($churl);
}
if ($zeit=="down!!"){}else{if(($zeit/$packs)<3){$zeit="<3 ms";}else{$zeit=($zeit/$packs)." ms";}}
return $zeit;
}
function server($link){
if(strstr($link,"/")){$link = substr($link, 0, strpos($link, "/"));}
return $link;
}
function getmstime(){
return (substr(microtime(),11,9)+substr(microtime(),0,10));
}
function correcturl($link){
return str_replace("http://","",strtolower($link));
}
function selfnam(){
global $PHP_SELF;
return basename($PHP_SELF);
}
$link=correcturl($link);
echo "ping server <b>http://".server($link)." (".ping($link).")</b><br>";
echo chkurl($link);
//echo "<form action=".selfnam()." method=get>";
//echo "http://<input type=input name=link value=\"$link\" size=60>";
//echo "<input type=submit name=check value=check>";
//echo "</form>";
?>
Any workaround for this would be very much appreciated!!!