MMOCoin

Likes Likes:  0
Results 1 to 2 of 2

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Beginner

    Join Date
    Dec 2010
    Posts
    1
    Post Thanks / Like
    Rep Power
    16
    Reputation
    1

    Cool How to make a simple php script to show server status.

    I'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";
    }
    ?>
    Replace "yoursite.com" with the url or ip address of the server.

    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>
    Replace "http://yoursite.com/serverstatus/online.php" with the location of the server status php file you created.

    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!



  2. Related Threads - Scroll Down after related threads if you are only interested to view replies for above post/thread

  3. #2
    Grunt
    id820's Avatar
    Join Date
    Sep 2009
    Location
    Brazil
    Posts
    42
    Post Thanks / Like
    Rep Power
    17
    Reputation
    36
    You 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

 

 

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •