Here is the combined code to cover using an IP address or a named server.
function ping($host){
$hostconnect = "Ping request could not find host ". $host . ". Please check the name and try again." ;
$ipconnect = " Packets: Sent = 1, Received = 0, Lost = 1 (100% loss)," ;
$rv = exec("ping $host -n 1 -w 1");
if( $ipconnect == $rv ) {
return false;
} else {
if( $hostconnect == $rv ) {
return false;
} else {
return true;
}
}
}
Just replace the whole of the ping function in the original code.