Difference between revisions of "Serverstatus script"

From Nitradopedia EN
Jump to: navigation, search
(Created page with "This article will shwo you how to create a serverstatus script.<br> What is needed?: 1. A Gameserver(this article will use a Minecraftserver as an example) 2. A Webspace whi...")
 
 
Line 1: Line 1:
This article will shwo you how to create a serverstatus script.<br>
+
This article will show you how to create a serverstatus script.<br>
 
What is needed?:
 
What is needed?:
 
  1. A Gameserver(this article will use a Minecraftserver as an example)
 
  1. A Gameserver(this article will use a Minecraftserver as an example)

Latest revision as of 10:36, 22 May 2015

This article will show you how to create a serverstatus script.
What is needed?:

1. A Gameserver(this article will use a Minecraftserver as an example)
2. A Webspace which lets you use PHP.
3. The following code

Code

<?php
 $server = "85.131.146.70";
 $port = "25565";
 $timeout = "10";
 if ($server and $port and $timeout) 
 {
 $minecraft = @fsockopen("$server", $port, $timeout);
 }
 if($minecraft) 
 {
 echo "The Minecraft-Server is Online";
 }
 else 
 {
 echo "The Minecraft-Server is Offline";
 }
 ?>

This code can now be used on your website.

Explanation

<?php   - Anfang des Scripts
    $server = "85.131.146.70";     - IP of the server, in this case 85.131.146.70
    $port = "25565";  - Port of the server, in this case 25565
    $timeout = "10";  - Validation of your online status(in seconds).
    if ($server and $port and $timeout)
    {
    $minecraft= @fsockopen("$server",$port,$timeout);      - Define $minecraft from $server, $port und $timeout
    }
    if($minecraft)  - "Wenn $minecraft erreichbar ist, dann..."
    { 
    echo "The Minecraft-Server is Online";   - ...shows "The Minecraft-Server is Online"
    }
    else        - andernfalls...
    {
    echo "The Minecraft-Server is Offline";   -...shows "The Minecraft-Server is Offline"
    }
    ?>       - End of the script