Advanced Site Status


Hello this is a repost of my server status image here on RMB.

First off you will want to make a new file named img.php and in that file code something like:
PHP Code
  1. <?php
  2. Header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); //Expiration Date
  3. Header("Content-type: image/png"); //image type
  4. $width=300; //change this if you must
  5. $height=20; //change if you want but id leave
  6. $ip = "IPHERE"; //change to yourip
  7. $port = "PORT HERE"; //change to server port
  8. $connectXD = @fsockopen($ip, $port, $errno, $errstr, 2); //connection through fsock
  9. if($connectXD){ //if its available
  10. //background color is white
  11. $c2r=255;
  12. $c2g=255;
  13. $c2b=255;
  14. //text is green
  15. $c1r=0; //red
  16. $c1g=125; //green
  17. $c1b=0; //blue
  18. $string = "Online"; //Online text :D
  19. }else{ //uh ohs!!!
  20. //background is white
  21. $c2r=255; //red
  22. $c2g=255; //green
  23. $c2b=255; //blue
  24. //text is red
  25. $c1r=255; //red
  26. $c1g=0; //green
  27. $c1b=0; //blue
  28. $string = "Offline Check Back Soon!"; //Offline text
  29. } //end else if for checking
  30.  
  31. //Border color is greenish
  32. $c3r=0; //red
  33. $c3g=128; //green
  34. $c3b=0; //blue
  35.  
  36. $pic=ImageCreate($width,$height); //create the image
  37. $col1=ImageColorAllocate($pic,$c1r,$c1g,$c1b); //text
  38. $col2=ImageColorAllocate($pic,$c2r,$c2g,$c2b); //background
  39. $col3=ImageColorAllocate($pic,$c3r,$c3g,$c3b); //border
  40. ImageFilledRectangle($pic, 0, 0, $width, 20, $col3); //create rectangle
  41. ImageFilledRectangle($pic, 1, 1, $width-2, 18, $col2); //Create teh rectangle for the text and stuff
  42. ImageString($pic, 3, 5, 2, $string, $col1); //this is text
  43. ImagePNG($pic); //show image
  44. ImageDestroy($pic); //desolate it
  45. ?>


Next open your .htaccess file and in there put:

PHP Code
  1. RewriteEngine on
  2. RewriteRule ^stats.png$ img.php


That should work for a demo you can see:
ShadowMage's Avatar
Author:
Views:
3,874
Rating:
There are currently no comments for this tutorial, login or register to leave one.