This a pretty simple script that will check the status of your server, or it can be used so that anyone can enter the IP or domain of there server and it will check all the common ports.
Here is an example:
<?php $up = @fsockopen("$ip", 80, $errno, $errstr, 30);
ok well simple all this does is open a connection to "$ip" on port 80, and then if $up (if the connection was successful) it will echo Online if not it will echo Offline.
If you wanted to use the code for just one server you can replace $ip with either the domain name or the IP. If using the domain name you do not include http://
you would just type domainname.com
The $errno and $errstr are both standard error parameters. The last number "30" is how long the connection should stay open until it is classed as timed out.
If you wanted to make it so that anyone can check the status of there site all you would do is at the top of the page add:
echo "Server Status Report For $ip";
What this does is retrieve the posted variable "$ip" and checks if the variable is empty if nothing was entered the script will terminate if something is entered the script will simply carry on what it is meant to be doing.
Now all that needs to be done is too add a form at the top of the page. The form needs a textbox field and a submit button.
<form name="form1" method="post" action="<?php echo $_SERVER['PHP_SELF'] ?>">
<input name="ip" type="text" value="">
<input type="submit" name="Submit" value="Submit">
This form will show a text box where anyone can enter any the domain or IP and then when the Submit button is click it will post the data into its self using the command:
action="<?php echp $_SERVER['PHP_SELF'] ?>"
Then the posted information will replace the variable $ip. You could use the code to show more than one port. By simply using the same "fsockopen" command but changing the Port number.
Heres a list of command ports:
HTTP - 80
FTP - 21
SSH - 22
MYSQL - 3306
CPANEL - 2082
WHM - 2086
POP3 - 110
SMTP - 25
Im sure this code will come in handy for someone.