-::Mr.Dave::-
21-09-2006, 03:50 PM
Today i bring to you my first piece of php work which i find to be quite nice.
It may not be the hardest thing to do but some people will like this
This is an adaption of a simple free existing script but vastly improved and styles so using images instead of words to show online services and offline services and it has had more added to it
Example: http://www.xtremehosts.co.uk/server
First off start by opening up a blank notepad
Then copy and paste this into it:
<style type="text/css">
<!--
.style3 {
font-family: verdana;
font-size: 12px;
}
-->
</style>
<p class="style3"> Use this page to check the status of any system on our server</p>
<p class="style3">Server Status:<br />
</p>
<?php
//You can replace the domain with an IP if you wish
$site = "Your IP Goes here";
$http = fsockopen($site, 80);
$ftp = fsockopen($site, 21);
$pop3 = fsockopen($site, 110);
$cPanel = fsockopen($site, 2082);
$WHM = fsockopen($site, 2086);
if ($http) {
$status .= '<p><font face="Verdana" size="2">Http Status: <img src="/images/ball_green.gif"></p>';
}
else {
$status .= '<p><font face="Verdana" size="2">Http Status: <img src="/images/ball_red.gif"></p>';
}
if ($ftp) {
$status .= '<p><font face="Verdana" size="2">FTP Status: <img src="/images/ball_green.gif"></p>';
}
else {
$status .= '<p><font face="Verdana" size="2">FTP Status: <img src="/images/ball_red.gif"></p>';
}
if ($pop3) {
$status .= '<p><font face="Verdana" size="2">POP3/SMTP Status: <img src="/images/ball_green.gif"></p>';
}
else {
$status .= '<p><font face="Verdana" size="2">POP3/SMTP Status: <img src="/images/ball_red.gif"></p>';
}
if ($cPanel) {
$status .= '<p><font face="Verdana" size="2">cPanel Status: <img src="/images/ball_green.gif"></p>';
}
else {
$status .= '<p><font face="Verdana" size="2">cPanel Status: <img src="/images/ball_red.gif"></p>';
}
if ($WHM) {
$status .= '<p><font face="Verdana" size="2">WHM Status: <img src="/images/ball_green.gif"></p>';
}
else {
$status .= '<p><font face="Verdana" size="2">WHM Status: <img src="/images/ball_red.gif"></p>';
}
echo("$status");
?>
Ok now the breakdown
This code is the IP/Domain of the server we are going to check:
$site = "Your IP Goes here";
This code checks the status of each port. For example we have Port 80 and Port 21 which are http and Ftp. You can have it check any Port on the server but in this it checks:
HTTP
FTP
POP3/SMTP
cPanel
WHM
$http = fsockopen($site, 80);
$ftp = fsockopen($site, 21);
$pop3 = fsockopen($site, 110);
$cPanel = fsockopen($site, 2082);
$WHM = fsockopen($site, 2086);
This part of the code displays the results of the check
if ($http) {
$status .= '<p><font face="Verdana" size="2">Http Status: <img src="/images/ball_green.gif"></p>';
}
else {
$status .= '<p><font face="Verdana" size="2">Http Status: <img src="/images/ball_red.gif"></p>';
}
if ($ftp) {
$status .= '<p><font face="Verdana" size="2">FTP Status: <img src="/images/ball_green.gif"></p>';
}
else {
$status .= '<p><font face="Verdana" size="2">FTP Status: <img src="/images/ball_red.gif"></p>';
}
if ($pop3) {
$status .= '<p><font face="Verdana" size="2">POP3/SMTP Status: <img src="/images/ball_green.gif"></p>';
}
else {
$status .= '<p><font face="Verdana" size="2">POP3/SMTP Status: <img src="/images/ball_red.gif"></p>';
}
if ($cPanel) {
$status .= '<p><font face="Verdana" size="2">cPanel Status: <img src="/images/ball_green.gif"></p>';
}
else {
$status .= '<p><font face="Verdana" size="2">cPanel Status: <img src="/images/ball_red.gif"></p>';
}
if ($WHM) {
$status .= '<p><font face="Verdana" size="2">WHM Status: <img src="/images/ball_green.gif"></p>';
}
else {
$status .= '<p><font face="Verdana" size="2">WHM Status: <img src="/images/ball_red.gif"></p>';
}
And finally this part of the code echo's the output and makes it visible on the PHP page we have created:
echo("$status");
This is my first tutorial on how to make a Server System check page. This is a seriously modified version of a simple PHP code on hostpapers
There is obviously room for expansion and more for what you can do with this and if you do modify do share your changes with people so that we can all update our script to include any new features you may develop. Remember to leave a link to a working Demo
Thanks and Enjoy
(please note replace the path to the online and offline images with your own as the ones i have are the ones i have chosen to use. You may have a different choice as to what you wish to use. Mine are from WHMCS billing system)
J1MI (Forum Moderator) - Thread moved to Website Tutorials. Nice Tut
It may not be the hardest thing to do but some people will like this
This is an adaption of a simple free existing script but vastly improved and styles so using images instead of words to show online services and offline services and it has had more added to it
Example: http://www.xtremehosts.co.uk/server
First off start by opening up a blank notepad
Then copy and paste this into it:
<style type="text/css">
<!--
.style3 {
font-family: verdana;
font-size: 12px;
}
-->
</style>
<p class="style3"> Use this page to check the status of any system on our server</p>
<p class="style3">Server Status:<br />
</p>
<?php
//You can replace the domain with an IP if you wish
$site = "Your IP Goes here";
$http = fsockopen($site, 80);
$ftp = fsockopen($site, 21);
$pop3 = fsockopen($site, 110);
$cPanel = fsockopen($site, 2082);
$WHM = fsockopen($site, 2086);
if ($http) {
$status .= '<p><font face="Verdana" size="2">Http Status: <img src="/images/ball_green.gif"></p>';
}
else {
$status .= '<p><font face="Verdana" size="2">Http Status: <img src="/images/ball_red.gif"></p>';
}
if ($ftp) {
$status .= '<p><font face="Verdana" size="2">FTP Status: <img src="/images/ball_green.gif"></p>';
}
else {
$status .= '<p><font face="Verdana" size="2">FTP Status: <img src="/images/ball_red.gif"></p>';
}
if ($pop3) {
$status .= '<p><font face="Verdana" size="2">POP3/SMTP Status: <img src="/images/ball_green.gif"></p>';
}
else {
$status .= '<p><font face="Verdana" size="2">POP3/SMTP Status: <img src="/images/ball_red.gif"></p>';
}
if ($cPanel) {
$status .= '<p><font face="Verdana" size="2">cPanel Status: <img src="/images/ball_green.gif"></p>';
}
else {
$status .= '<p><font face="Verdana" size="2">cPanel Status: <img src="/images/ball_red.gif"></p>';
}
if ($WHM) {
$status .= '<p><font face="Verdana" size="2">WHM Status: <img src="/images/ball_green.gif"></p>';
}
else {
$status .= '<p><font face="Verdana" size="2">WHM Status: <img src="/images/ball_red.gif"></p>';
}
echo("$status");
?>
Ok now the breakdown
This code is the IP/Domain of the server we are going to check:
$site = "Your IP Goes here";
This code checks the status of each port. For example we have Port 80 and Port 21 which are http and Ftp. You can have it check any Port on the server but in this it checks:
HTTP
FTP
POP3/SMTP
cPanel
WHM
$http = fsockopen($site, 80);
$ftp = fsockopen($site, 21);
$pop3 = fsockopen($site, 110);
$cPanel = fsockopen($site, 2082);
$WHM = fsockopen($site, 2086);
This part of the code displays the results of the check
if ($http) {
$status .= '<p><font face="Verdana" size="2">Http Status: <img src="/images/ball_green.gif"></p>';
}
else {
$status .= '<p><font face="Verdana" size="2">Http Status: <img src="/images/ball_red.gif"></p>';
}
if ($ftp) {
$status .= '<p><font face="Verdana" size="2">FTP Status: <img src="/images/ball_green.gif"></p>';
}
else {
$status .= '<p><font face="Verdana" size="2">FTP Status: <img src="/images/ball_red.gif"></p>';
}
if ($pop3) {
$status .= '<p><font face="Verdana" size="2">POP3/SMTP Status: <img src="/images/ball_green.gif"></p>';
}
else {
$status .= '<p><font face="Verdana" size="2">POP3/SMTP Status: <img src="/images/ball_red.gif"></p>';
}
if ($cPanel) {
$status .= '<p><font face="Verdana" size="2">cPanel Status: <img src="/images/ball_green.gif"></p>';
}
else {
$status .= '<p><font face="Verdana" size="2">cPanel Status: <img src="/images/ball_red.gif"></p>';
}
if ($WHM) {
$status .= '<p><font face="Verdana" size="2">WHM Status: <img src="/images/ball_green.gif"></p>';
}
else {
$status .= '<p><font face="Verdana" size="2">WHM Status: <img src="/images/ball_red.gif"></p>';
}
And finally this part of the code echo's the output and makes it visible on the PHP page we have created:
echo("$status");
This is my first tutorial on how to make a Server System check page. This is a seriously modified version of a simple PHP code on hostpapers
There is obviously room for expansion and more for what you can do with this and if you do modify do share your changes with people so that we can all update our script to include any new features you may develop. Remember to leave a link to a working Demo
Thanks and Enjoy
(please note replace the path to the online and offline images with your own as the ones i have are the ones i have chosen to use. You may have a different choice as to what you wish to use. Mine are from WHMCS billing system)
J1MI (Forum Moderator) - Thread moved to Website Tutorials. Nice Tut