[Web] AwesomeStatus - a free server status image (now with hosting and themes)

Discussion in 'Bukkit Tools' started by tyzoid, Feb 2, 2013.

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

    tyzoid

    This was derailing another, similar thread, so I forked the discussion over here.

    Freely hosted version:
    [​IMG]
    [​IMG]
    (Image by muffinjello - Thanks!)

    [​IMG]

    Self-hosted version (you can customize your own image with an image editor):
    [​IMG]

    AwesomeStatus v0.0.4

    This project is now on git!
    (warning, experimental version):
    https://github.com/tyzoid/AwesomeStatus
    resources and code (open)

    PHP:
    <?php
    //Variables:
    $server "server.tyzoid.com";
    $serverport  "25565";
     
    ignore_user_abort(true);
    function 
    query($ip$port){
        @
    $f fsockopen($ip$port$errorno$errordesc2);
        if(
    $f === false) return false//connection failed
        
    stream_set_timeout($f2);
        
    fwrite($f"\xfe\x01");
        
    $data fread($f256);
        if(
    substr($data01) != "\xff") return false//Not a minecraft server
        
    $data2 mb_convert_encoding(substr($data3), 'UTF8''UCS-2');
        if(
    strpos($data2"\0") !== false$data explode("\0"$data2); //1.5.1 servers
        
    else $data explode("ยง"mb_convert_encoding(substr($data3), 'UTF8''UCS-2'));
        return array(
            
    "players" => intval($data[count($data)-2]),
            
    "maxplayers" => intval($data[count($data)-1])
        );
    }
     
    $expired true;
    $online false;
    $file fopen("check.txt""r");
    if(!
    feof($file)) {
        
    $line fgets($file);
        
    $online = (substr($line,0,1) === "t");
        
    $players intval(substr($line,1,3));
        
    $expired = (intval(substr($line,4))+60*time());
        
    $waituntilafter = (intval(substr($line,4))+60*time());
    }
    fclose($file);
     
    if(
    $expired === true && $waituntilafter === false){
        
    $info query($server,$serverport);
        
    $file fopen("check.txt""w");
        
    fwrite($file,(($info !== false)?"t":"f"));
        
    fwrite($file,sprintf("%03d", (($info !== false)?$info['players']:0)));
        
    fwrite($file,(string)time());
        
    fclose($file);
     
        
    $players = (($info !== false)?$info['players']:0);
    } else {
        
    $info $online;
    }
     
    if(
    $info === false){
        
    $name './offline.png';
        
    $fp fopen($name'rb');
     
        
    header("Content-Type: image/png");
        
    header("Content-Length: " filesize($name));
     
        
    fpassthru($fp);
    } else {
        
    $name "./online.png";
        
    $image ImageCreateFromPNG($name);
        
    imagesavealpha($imagetrue);
        
    $color imagecolorallocate($image646464); // #444
        
    imagettftext($image2403386$color'newscycle.ttf'sprintf("%02d"$players).'/16');
        
    header("Content-Type: image/png");
        
    imagepng($image);
    }
     
    fastcgi_finish_request();
     
    if(
    $expired === true && $waituntilafter === true){
        
    $info query($server,$serverport);
        
    $file fopen("check.txt""w");
        
    fwrite($file,(($info !== false)?"t":"f"));
        
    fwrite($file,sprintf("%03d", (($info !== false)?$info['players']:0)));
        
    fwrite($file,(string)time());
        
    fclose($file);
    }
    ?>
    Images:
    Feel free to edit the below files to your heart's content:

    If you aren't great with graphics, I'd be happy to put your server's name on it.

    Online:
    online.png
    Offline:
    offline.png

    Font:
    http://openfontlibrary.org/en/font/news-cycle
    Download, extract, rename as "newscycle.ttf" and place it in the same folder as the image and php file.


    Get started right away with free hosting:
    For those who want to have this hosted for free, you can use http://mctools.tyzoid.com/mcb/ to generate one.
    Previews of these banners are above under "Freely hosted version."

    Just fill in your information, it will automatically cache and update the listing as necessary.

    Also note, I haven't been able to test this with very many servers, so if there are any glitches/bugs, don't hesitate to let me know.
     
    MrBluebear3 and muffinjello like this.
  2. Offline

    LaxWasHere

    Must be fsock disabled on my server?[​IMG]

    Could you try lazlecraft.net on your webserver?
     
  3. Offline

    tyzoid

    Mine is showing eight...

    I see what the problem is...
    I'll see if I can't fix that.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 31, 2016
  4. Offline

    LaxWasHere

    So my server is saying that I have 8 ppl on? Lol

    :D
     
  5. Offline

    tyzoid

    Problem solved
    Edit 3: Check the OP for updated code.
     
  6. Offline

    LaxWasHere

    I can confirm it's working! :D
     
  7. Offline

    tyzoid

    I updated the source in the OP again. It includes a performance improvement, as well as nearly-realtime (next refresh) data.
     
    LaxWasHere likes this.
  8. Offline

    Ignorex

    Can I download this script?
     
  9. Offline

    tyzoid

    Of course. I'm going to create some template images to use soon, so once I get those made, I'll make some docs too.
     
    Ignorex likes this.
  10. Offline

    Double0negative

  11. Offline

    tyzoid

    That's because the number of max players is hardcoded.
     
  12. Offline

    devilquak

    0.o Are you sure? I've been on servers with 999+ slots...
     
  13. Offline

    tyzoid

    See the /25o there? I don't automatically grab the max players, I will do that in a later version.

    Change the /250 to whatever you have on your server.
     
    Ignorex likes this.
  14. Offline

    Double0negative

    The packet returns both the players online and max players
     
  15. Offline

    tyzoid

    I'm aware. I just don't make use of it. I will fix that in a later version, but for now, just change 250 to whatever your max players are.
     
  16. Offline

    LaxWasHere

    I suck at photoshop :p

    [​IMG]
     
    Double0negative likes this.
  17. Offline

    tyzoid

    I think it looks awesome :p
     
  18. Offline

    LaxWasHere

    Image load is slow for huge pics :|
     
  19. Offline

    tyzoid

    Right, my script does no compression, as it modifies the image on the fly.
     
  20. Offline

    TheFluffey

    No text shows up on mine. PHP installed. Folder looks like this. http://puu.sh/1XDlc
     
  21. Offline

    tyzoid

    Try running phpinfo() and check if the GD library is enabled.
     
  22. Offline

    jigga_jones

  23. Offline

    tyzoid

    imagettftext($image, $fontsize, $slant, $x, $y, $color, $fontfile, $string);
    Change whatever parameters you need.
     
    jorisk322 likes this.
  24. Offline

    jorisk322

    I guess it's not a good idea to put this on the shared web-hosting I got for free with my Minecraft server? It seems quite resource/bandwidth-heavy.
     
  25. Offline

    tyzoid

    I can host it for you. (for free)
     
  26. Offline

    jorisk322

    Oooh, thanks! I will look into making a nice banner for it.
     
  27. Offline

    tyzoid

  28. Offline

    jorisk322

  29. Offline

    CichusekPL

    does not show the text on the picture, I checked in phpinfo my GD version and status, and shows 2.0, enabled.
     
  30. Offline

    tyzoid

    Is the font in your folder?

    If so, you may need to add this piece of code to your php file:
    PHP:
    putenv('GDFONTPATH=' realpath('.'));
     
Thread Status:
Not open for further replies.

Share This Page