Need Html code for server state,

Discussion in 'Bukkit Help' started by W&L-Craft, Jul 24, 2012.

Thread Status:
Not open for further replies.
  1. Offline

    W&L-Craft

    I have a little website for my server, on that i want to show the server's state, so, i just want it to display: server is: online or offline
     
  2. First of, you need some Server-Side Scripting,
    I use PHP.

    I made a function, This file is:
    check.php
    2*
    PHP:
    <?php
    function statuscheck($adress$port) {
    $timeout "1";
    if(@
    fsockopen("$adress"$port$errno$errstr$timeout)) {
        echo 
    'Online!'//If the port is USED/Server Reponds then write Online,
      
    } else {
        echo 
    'Offline!'//If it's not respoding, Offline.
      
    }
    }
    ?>
    and Add this to the Webpage you want to show it to:
    3*
    PHP:
    <?php
    include 'check.php'//Where the file is Located
    statuscheck("127.0.0.1""25565"); // (Ip Adress, Port)
    ?>
    If you have more the one server, And the other server runs at Port: 25566
    PHP:
    <?php
    include 'check.php'//Where the file is Located
    statuscheck("127.0.0.1""25565"); // (Ip Adress, Port)
    statuscheck("127.0.0.1""25566");
    ?>
    //Output if server are online: Online!Online!
    You may need to add some CSS formating.

    If you want to format the output:
    PHP:
    echo '<div class="offline">Offline!</div>';
    //Or
    echo '<span class="offline">Offline!</span>';
    //Span is for Textformation.., And if you arent using any
    //external or <style></style>
    echo '<div style="color:red;">Offline!</div>'//color:COLOR/#Hex;
    1: Make a new file Named; check.php, Place it anywhere in the WWW dir.
    2*: Copy the text.
    3*: Add the text anywhere on the webpage, Edit the "include 'check.php', To the correct directory if its not in the same.
    4: The file you put 3* in must have the extension *.php
     
    Thury likes this.
Thread Status:
Not open for further replies.

Share This Page