[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

    lemmymet
    It looks like there is an issue with your host's installation of PHP.

    Contact your host, they should be able to help you.
     
  2. Offline

    bobacadodl

    Any chance of a caching system? To reduce bandwidth :)
     
  3. Offline

    tyzoid

    bobacadodl
    I'm working on it. The problem is any caching system would reduce the time resolution to be anywhere near effective.
     
    bobacadodl likes this.
  4. Offline

    Squawkers13

  5. Offline

    tyzoid

    Squawkers13
    Glad it fixed itself :)

    The font is needed because the code uses it, it will return an error if the font is not present.
     
  6. Offline

    Squawkers13

    Wait- where does the code use it?
     
  7. Offline

    tyzoid

    Squawkers13
    Code:java
    1.  
    2. } else {
    3. $name = "./online.png";
    4. $image = ImageCreateFromPNG($name);
    5. imagesavealpha($image, true);
    6. $color = imagecolorallocate($image, 64, 64, 64); // #444
    7. imagettftext($image, 24, 0, 33, 86, $color, 'newscycle.ttf', sprintf("%02d", $players).'/16');
    8. header("Content-Type: image/png");
    9. imagepng($image);
    10. }
    11.  


    Imagettftext uses it.
     
  8. Offline

    bhallowitz

    tyzoid Seems your koding account was closed :/
     
  9. Offline

    tyzoid

    Yeah, I'm working on it.

    They migrated to a new domain, and I'm still trying to get through the transition, as I'm on vacation right now.
     
  10. Offline

    tyzoid

    bhallowitz

    URL Change:

    http://tyzoid.koding.com/ has been removed, and so mctools.tyzoid.com now replaces it.

    Minor data loss occurred, however most people should be able to seamlessly transition their status images assuming they were using the http://mclist.me/b/ urls.
     
  11. Offline

    cookieman768

    tyzoid Does this support SRV records? Because when I try with play.simplecraft.us it says "This Server is Offline"
    Also with the original post does that support SRV records?
     
  12. Offline

    tyzoid

    It supports SRV correctly:
    [​IMG]

    It correctly detected port 30241.

    Here is the debug info of what the script does:

    _______________________________________________________________
    bool(false)
    Requested query address: play.simplecraft.us at port 25565
    Actually querying dc-1a0a743f-serverbox2.simplecraft.us at port 30241

    Current timestamp: 1376187838. Last Queried:1376187794.

    From cache:
    Dump of info: string(121) "ÿ;§1741.6.2§6§kPOPO §3Simple Craft §2- §41.6 §6§kPOPO056"
    Dump of decoded info: string(67) "§1741.6.2§6§kPOPO §3Simple Craft §2- §41.6 §6§kPOPO056"
    Trimming data:
    string(67) "§1741.6.2§6§kPOPO §3Simple Craft §2- §41.6 §6§kPOPO056"
    Array ( [0] => §1 [1] => 74 [2] => 1.6.2 [3] => §6§kPOPO §3Simple Craft §2- §41.6 §6§kPOPO [4] => 0 [5] => 56 )

    Dump of info:array(2) { ["players"]=> int(0) ["maxplayers"]=> int(56) }
    Dump of info:array(2) { ["players"]=> int(0) ["maxplayers"]=> int(56) }

    Current information:
    • Online: online
    • Players: 0
    • Max players: 56
    • Online text: Play at SimpleCraft!
    • Offline text: We're offline :(
    • Theme: banner2
     
  13. Offline

    cookieman768

    tyzoid
    Oh, I was talking about the download version so I could mess around with the graphics.

    This is my test image http://simplecraft.us/status/ (No SRV)
    My second test image http://simplecraft.us/status/srv/ (With SRV)

    On the one that worked for the online status it did not show that a player was online. I also remember reading that I would have to change the slot count automatically.

    The one with SRV has the port set to 25565 and the IP to play.simplecraft.us

    PHP File with SRV (open)

    PHP:
    <?php
    //Variables:
    $server "play.simplecraft.us";
    $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);
    }
    ?>

    Without SRV Record (open)

    PHP:
    <?php
    //Variables:
    $server "142.4.36.74";
    $serverport  "30241";
     
    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);
    }
    ?>

    This is what I want to aim towards http://quadrantal.com/status.png (or something close)

    P.S. It would be awesome if there was a way to have my pvp server player count and my vanilla servers player count combine and say "X amount of players are on the Simple Craft Network"

    Thanks for the speedy reply, Cookieman768
     
  14. Offline

    tyzoid

    cookieman768
    I see what you are saying now.

    I haven't updated the standalone version, as my hosted version is something more people could benefit from.

    It would be trivial to implement something like you wanted ( http://quadrantal.com/status.png ) on my hosted version as I intend on rolling out custom images in the near future.

    If you still would like me to add SRV records to the standalone, let me know and I'll gladly implement it.
     
  15. Offline

    cookieman768


    I would appreciate you adding support for that very much. I am not in a big hurry to get this setup but it would be nice to have soon.
     
  16. Offline

    lol768

    IMO
    Code:
    header h1, header h2, header h3, header h4, header h5, header h6 {
        font-family: sans-serif;
    }
    looks nicer
     
  17. Offline

    tyzoid

    lol768 cookieman768 Dang alerts not working. I'll take a look at both when I get home from work.
     
    cookieman768 and lol768 like this.
  18. Offline

    tyzoid

  19. Offline

    cookieman768

    Looks good, I will test it out and reply with my results. :)
     
  20. Offline

    Smiggledoink

    Greetings Tyzoid
    First off, I would like to say this is a wonderful idea. I hope you keep this up

    It appears your hosting application is not working, or it won't work for my geographical location (Ontario, Canada).
    It's not a rush to figure out what's wrong, as I don't have my server ready for banners or advertisement just yet.

    I will keep an eye on this string for a reply.
    *Smiggledoink*
     
Thread Status:
Not open for further replies.

Share This Page