Last Updated: February 25, 2016
·
1.534K
· xanza

Simple Website Online Script

I use this script quite a bit to establish if services are working correctly or not. For example I've used it to display the online status of Minecraft servers. (http://m.wonderproject.net)

<?php
//Icons (C) 2012 @designkindle http://www.designkindle.com

function siteCheck($site, $port){
$check = @fsockopen($site, $port, $errno, $errstr, 30);

if($check){
    echo "<img alt='Online!' src='http://i.imgur.com.nyud.net/QXgTw.png' />";
} else {
    echo "<img alt='Offline!' src='http://i.imgur.com.nyud.net/9PHoh.png' />";
    }
}

return siteCheck('http://google.com/',80); //usage
?>

can be included:

<?php
include('sitecheck.php');

return siteCheck('google.com', 80);
?>