Reputation: 13
This is what I currently have. It doesn't work, what needs to be done to fix it?
<?php
$status = GetServerStatus('http://domain.com',80)
?>
<?php
function GetServerStatus($site, $port)
{
$status = array("OFFLINE", "ONLINE");
$fp = @fsockopen($site, $port, $errno, $errstr, 2);
if (!$fp) {
return $status[0];
} else {
return $status[1];
}
}
?>
Upvotes: 0
Views: 1583
Reputation: 15044
You don't put in the http:// part.
echo GetServerStatus('www.domain.com', 80);
function GetServerStatus($site, $port)
{
$fp = @ fsockopen($site, $port, $errno, $errstr, 2);
return ($fp)
? 'ONLINE'
: 'OFFLINE';
}
Fist parameter should be a hostname not a URL.
Upvotes: 1