Help? Working minecraft server status script for php?

Discussion in 'Bukkit Help' started by Kazzababe, Nov 18, 2012.

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


    Isn't there a setting in the file to enable / disable a response to this kind of query?
  2. Offline



    I believe it allows you to fetch some information from your server such as; player list, amount of players online, amount of slots, motd and so on.
  3. Offline


    That's what I thought.

    Kazzababe check that you don't have this feature disabled in your
  4. Offline


    The code I posted is not using the query server, it uses the server list ping.

    Nope, its on all the time.
  5. Offline


    I have query enabled but it still doesn't work.
  6. Offline


    Make sure your server provider allows external connections. I had the same problem.
  7. Offline


    You are getting this wrong. My script does not use the query server, it uses the server list ping (the same thing the game uses to show the list of servers). There is no way to disable it on the server as that would prevent clients from connecting.
  8. Offline


    Oops. Didn't see your code in there. I assume you're Polish, by your name so, siema, co tam? :)
  9. Offline


    Nope :p My granddad was from the Ukraine but I was born in the UK.
  10. Offline


    Ah, I see haha, well, pretty much same here, my granddad was from Ukraine, I was born in Poland and moved to UK when I was little :p haha
  11. Offline


    So, I went into the code and removed 'motd' => $data[0] and 'motd' => $data[1]
    and it's printed out the array which is GREAT

    Array ( [version] => 1.4.5 [players] => 45 [max_players] => 150 ) 
    This is the result. I love it. :)

    (For those who are wondering an array is the output and this is showing parts of the result, these Array and [] tags can be removed :) )
  12. Offline


    I use PHP-Minecraft-Query code.

    Using the code supplied I was able to pull out the current players online from $aryPlayers with the following code:

      if (!(empty(
    $aryPlayers))) {
    "<h2 class=\"online\">Who's Online:</h2><br />";
        for (
    $i=0$i $intPlayerCount$i++) {
    "<img src=\"images/avatar_" strtolower($aryPlayers[$i]) . ".png\" width=\"16\" height=\"16\" /> " $aryPlayers[$i] . "<br />";
  13. Offline


    Apparantly all of these should work. Is there something wrong with the host TreeWired? It appears these php scripts work for everyone but me, and I'd love to know why that is :(
  14. Offline


    Would you mind sharing the whole code.
  15. Offline


    Sorry, yes I could have provided a little more information. I used the 'Example' code on the link I gave as a starting point. From there I expanded it a little to get what I wanted.

    print_r$Query->GetInfo( ) );
    print_r$Query->GetPlayers( ) );
    $aryInfo = ($Query->GetInfo());
    $aryPlayers = ($Query->GetPlayers());
    $intPlayerCount count($aryPlayers);
    Then you need to use some HTML to format it nicely.
  16. Offline


    I am trying to use this PHP-Minecraft-Query code and was wondering how to get rid of the Array output.

    Array ( [Version] => 1.4.4 [Players] => 0 [MaxPlayers] => 60 )
    Also how can I make it echo if the server is actually online or not.

    I just want it to simply output,

    Status - Online
    Players - 0/60
    Version - 1.4.4

    Thank you.
  17. Offline


    I'm working on it lol. So far, I managed to do this;
    This fetched info from my current server. I could host it for you if you want.
  18. Offline


    I created a script to update the user avatar based on the user's current skin.

    I have my 'players.txt' file populated with my white-list players, but case-sensitive as it won't work with the actual white-list because all usernames are in lower-case. There might be a better way to do this.

    In my example, my website resides in a folder '/domains/' and the URL is, so update this to suit your setup. The OS is CentOS, and you will need the ImageMagick package installed.

    Firstly I download all the skins:
    #refresh all avatars regardless of modify date
    cd /domains/
    for i in `cat /domains/`; do
      wget -4 -m -nd$i.png
      convert $i.png -crop 8x8+8+8 +repage -scale 200% /domains/${i,,}.png
      chown apache:apache /domains/${i,,}.png
    Then I check once a day, and only download if the skin has changed:
    #check for new avatars
    cd /domains/
    for i in `cat /domains/`; do
      wget -4 -m -nd$i.png
      if [ ! $(find /domains/$i.png -mtime -1 | wc -l) -eq 0 ]; then
        convert $i.png -crop 8x8+8+8 +repage -scale 200% /domains/${i,,}.png
        chown apache:apache /domains/${i,,}.png
  19. Offline


    I write a little php code which checks the server status, the count of the online players and the Slots.
    Here is the link:
    In the is a tutorial how to use it.
    I hope I could help you
  20. Offline


    omg Hi Adrian XD
    MinopolisMc likes this.
  21. Offline


    PHP is a server side language, mainly website, but it is still a server side language
  22. Offline


    Um what lol
  23. Offline


    Nothing is working for me either :(
    I keep getting a connection refused error
  24. Offline


    I dont see any authentication through mojang servers. Thats probably the issue
  25. Offline


    How would I get the results to be on an image?
  26. Offline


    Heres the script i use for my website. Works fine for me.

    class MCServerStatus {
    $error "OK";
    __construct($url$port '25565') {
    $this->server = array(
    "url" => $url,
    "port" => $port
            if ( 
    $sock = @stream_socket_client('tcp://'.$url.':'.$port$errno$errstr1) ) {
    $this->online true;
    $h fread($sock2048);
    $h str_replace("\x00"''$h);
    $h substr($h2);
    $data explode("\xa7"$h);
                if (
    sizeof($data) == 3) {
    $this->motd $data[0];
    $this->online_players = (int) $data[1];
    $this->max_players = (int) $data[2];
                else {
    $this->error "Cannot retrieve server info.";
            else {
    $this->online false;
    $this->error "Cannot connect to server.";
    Usage would be like this.

    include "MCServerStatus.php";
    $server = new MCServerStatus("Server IP Here"25565); //The second argument is optional in this case[/COLOR]
    $var $server->online//$server->online returns true if the server is online, and false otherwise
    echo $server->motd//Outputs the Message of the Day
    echo $server->online_players//Outputs the number of players online
    echo $server->max_players//Outputs the maximum number of players the server allows
    print_r($server); //Shows an overview of the object and its contents. (For debugging.)
  27. Offline


    The reason why you aren't getting an error is because the error is being suppressed in Jacek's code. You need to remove the @ symbol in front of fsockopen() to show the error that fsockopen() is throwing. Alternatively, you can leave the @ symbol, but echo $errno and $errstr to show the error:

    $socket = @fsockopen( $this->address, $this->port, $errno, $errstr, 10 );
    if ( $socket === false ){
        printf( "Socket Error #%d: %s<br />", $errno, $errstr );
  28. Offline

    Super User

    People who are using the avatar thing, use minotar. I've provided a sample script below.

    function preventSQLinject() {
    //Insert escape function here if you have a sql server

    $user = $_GET[username];

    print '<img src="' . $user . '/100"';


    Also you want to add the escape keys at print.
  29. Offline


    Hey, I'm very new to html and php and all that.I really have no idea had to implement this into my website, no idea, cant find anything online on this. If anyone knows how, that would be great. Thanks
  30. Offline


Thread Status:
Not open for further replies.

Share This Page