<?php
function site_is_up($site,$port=80,$timeout=1){
$port = $port === NULL ? 80 : $port;
$fp = @fsockopen(str_replace('http://','',$site), $port, $errno, $errstr, $timeout);
if($fp === false){
return false;
}
fclose($fp);
return true;
}
?>
<?php
if(site_is_up('siteismi')){
echo 'Site is up!!';
}else{
echo 'Site is down.';
}
// self explanitory I hope
if(site_is_up('siteismi',NULL,5)){ echo 'UP!'; }
// check siteismi with a 5 second timeout (still on port 80)
if(site_is_up('siteismi',2082)){ echo 'UP!'; }
// check siteismi on port 2082
?>