Likes: 0
Results 1 to 2 of 2
-
01-12-10, 02:44 AM #1
How to make a simple php script to show server status.
Register to remove this adI'm a noob to php, but I wanted to post my limited knowledge to help others out. If the code is crap, let me know what I did wrong, but I've tested it and it works for me.
How to make a simple php script to show server status if you don't have a ready-made public server website with the server status feature included.
First, make 2 icons showing "offline" and "online" status respectively. It is best to make these icons the exact same dimensions. Example: 20pixels x 20pixels
Name the files "serveron.gif" and "serveroff.gif" (you don't have to use a .gif, you can use a .jpg, .png, etc.)
Create a new folder named "serverstatus" or something similar. Put your 2 icons that you created into the folder. Then, create a file within the folder named "online.php" or something similar.
Copy/paste this code into the file.
Code:$ip = "yoursite.com"; $onlinetext = "Server is On-Line" ; $offlinetext = "Server is Off-Line" ; $port = "80"; if(@fsockopen($ip,$port,$errno,$errstr,1)) { echo"<a href='http://$ip' rel="nofollow" target='_blank'><img src='serveron.gif' width='20' height='20' border='0'></a> $onlinetext"; } else { echo"<img src='serveroff.gif' width='20' height='20' border='0'> $offlinetext"; } ?>
Customize the "Server is On-line" and "Server is Off-line" messages to your liking.
Enter the correct port # (if unsure, leave at "80")
Save the file, and upload the folder to your host. Example: "www.yoursite.com/serverstatus/online.php".
Navigate to the url where you put your "online.php" file ie. "www.yoursite.com/serverstatus/online.php" and see it working!
To link to the php file from your web page, copy/paste the code below where you would like the status to be located in your web page.
Code:<script><script language="JavaScript" type="text/javascript" src="http://yoursite.com/serverstatus/online.php"</script>
Save the file, and upload it.
That's it! You now have a live server status message with cool icons that you made all by yourself!
› See More: How to make a simple php script to show server status.
-
07-05-11, 08:31 AM #2
Register to remove this adYou should link a demo for us, looks good anyway, im not sure if it works cuz i dont know php hehe.
http://www.id820.com - GraphicDesigner