I created this small PHP script to show online status of my various game, minecraft, etc.. servers. The PHP script is easy, the only sucky part is that there are quite a few webhosts that prevent PHP from using the port functions.
Here's the code you'd use. It has a 5 second timeout. Use the below link as a direct image.
Which will produce the following.
IP = 209.159.212.203 : Port = 25566

Here's the PHP code.
Here's the code you'd use. It has a 5 second timeout. Use the below link as a direct image.
Expand to see the code.
Which will produce the following.
IP = 209.159.212.203 : Port = 25566
Here's the PHP code.
- <?php
- header("Content-Type: image/png");
- $im = @imagecreate(70, 20) or die("Cannot Initialize new GD image stream");
- $site = $_GET['host'];
- $port = $_GET['port'];
- $background_color = imagecolorallocate($im, 0, 0, 0);
- $online = imagecolorallocate($im, 0, 255, 0);
- $offline = imagecolorallocate($im, 255, 0, 0);
- $fp = fsockopen($site,$port,$errno,$errstr,5);
- if(!$fp)
- imagestring($im, 5, 5, 5, "Offline", $offline);
- else{
- imagestring($im, 5, 5, 5, "Online", $online);
- fclose($fp);
- }
- imagepng($im);
- imagedestroy($im);
- ?>
Expand to see the code.