Show Server Status


Show server stats.
Checks FTP, HTTP, POP3
Then Displays If there working or not

Create some images
green-status.gif
red-status.gif
Or use the following
TutorialNinja Image


and read the comments in the script!

PHP Code
  1. <?php
  2.  
  3. $mainsite = "localhost"; // this is the site you wish to check.
  4.  
  5. // Let's check our common ports 80, 21, and 110
  6. $http = fsockopen($mainsite, 80);
  7. $ftp = fsockopen($mainsite, 21);
  8. $pop3 = fsockopen($mainsite, 110);
  9.  
  10.  
  11. // Check To See All Ports Are Working.
  12. if ($http) {
  13. $httpstat .= "<img src='green-status.gif' align='center'><font face='Verdana' size='2'> OK</font>";
  14. }
  15. else {
  16. $httpstat .= "<img src='red-status.gif' align='center'><font face='Verdana' size='2'> N/A</font>";
  17. }
  18.  
  19. if ($ftp) {
  20. $ftpstat .= "<img src='green-status.gif' align='center'><font face='Verdana' size='2'> OK</font>";
  21. }
  22. else {
  23. $ftpstat .= "<img src='red-status.gif' align='center'><font face='Verdana' size='2'> N/A</font>";
  24. }
  25.  
  26. if ($pop3) {
  27. $popstat .= "<img src='green-status.gif' align='center'><font face='Verdana' size='2'> OK</font>";
  28. }
  29. else {
  30. $popstat .= "<img src='red-status.gif' align='center'><font face='Verdana' size='2'> N/A</font>";
  31. }
  32.  
  33. echo "
  34. <table border='1' cellpadding='7' cellspacing='0' style='border-collapse: collapse' bordercolor='#111111' width='25%'>
  35. <tr>
  36. <td width='100%' colspan='2' bgcolor='#F0F0F0'>
  37. <p align='center'><b><font face='Verdana' size='2'>Current Server Stats</font></b></td>
  38. </tr>
  39. <tr>
  40. <td width='100%'><b><font face='Verdana' size='2'>HTTP:</font></b></td>
  41. <td width='41%'>
  42. <p align='center'>$httpstat</td>
  43. </tr>
  44. <tr>
  45. <td width='100%'><b><font face='Verdana' size='2'>FTP:</font></b></td>
  46. <td width='41%'>
  47. <p align='center'>$ftpstat</td>
  48. </tr>
  49. <tr>
  50. <td width='100%'><b><font face='Verdana' size='2'>POP3:</font></b></td>
  51. <td width='41%'>
  52. <p align='center'>$popstat</td>
  53. </tr>
  54. </table>
  55.  
  56. ";
  57. ?>
James's Avatar
Author:
Views:
2,566
Rating:
Posted on Monday 6th August 2007 at 07:54 AM