[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

    Acetone

    Doesnt work. I have GD version 2.0.
     
  2. Offline

    tyzoid

     
  3. Offline

    Acetone

    tyzoid
    Where i must add this?
     
  4. Offline

    tyzoid

    At the top of the php file, but after the <?php opening tag
     
  5. Offline

    Matt - Kerplunc

    We are getting an error for the fastcgi_finish_request() function because we aren't using a web server that is running PHP-FPM, which it looks like that function is only available in. Any suggestions for a way around that?

    Code:
    [17-Feb-2013 14:29:42 America/Chicago] PHP Fatal error:  Call to undefined function fastcgi_finish_request() in public_html/statusimage/statusimage.php on line 64
    
     
  6. Offline

    tyzoid

    Just comment out the line. Your script will run slower, but you can adjust the time parameters to compensate.
     
  7. Offline

    Matt - Kerplunc

  8. Offline

    tyzoid

    Hmm, it appears that you have two problems...
    Problem #1:
    You are using the script incorrectly. The usage shown in the OP only applies to the freely hosted version, not the code that you use.

    Problem #2:
    Whatever server you have in the php file (probably mine) is returning offline, meaning no text will be displayed unless explicitly told to.

    It is basically showing you offline.png. If the server it was querying is reporting as online, it would give you a player count.
     
  9. Offline

    arnie231

    Thanks for this man Great work

    [​IMG]
     
  10. Offline

    tyzoid

    Nice. You could change the color to something else, if you want. It would make more sense in your case:
    PHP:
    <?php
    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($image2401986$color'newscycle.ttf'sprintf("%02d"$players).'/250');
        
    header("Content-Type: image/png");
        
    imagepng($image);
    }
    Change the color, in that case, and also change sprintf("%02d",$players) to $players. It should look nicer, and 0,1,2,3,...,10,11,... instead of 00,01,02,03,...,10,11,... .
     
  11. Offline

    muffinjello

    Wow, thanks for this... Going to try it out later on my server!
     
    tyzoid likes this.
  12. Offline

    muffinjello

    tyzoid Hey, I'm slightly confused.. by your line
    So... Can I edit the image or not? I want to add stuff such as a background, more minecrafty stuff, ect. I do develop a quite a bit in HTML and CSS....
     
  13. Offline

    tyzoid

    Yeah, edit the ones I give you, not the one I use. I should have been more clear.
     
  14. Offline

    muffinjello

    OHHHhhh! Rofl! Haha, no worries.

    Interested in me making a pretty fancy banner for ya(or a template for all)? :)
     
  15. Offline

    tyzoid

    That would be awesome! (for everyone would be nice) Thanks! (no hurry).
     
  16. Offline

    muffinjello

    tyzoid - I'm done! There are three versions, OnlineHD, OfflineHD, and OfflineHD2. I'm putting the OfflineHD2 and OnlineHD versions here for now, and going to private message you a link to the OfflineHD (which has no tags on it.. that way it'll be up to you whether you want to release it or not... after all, if you don't get credit for making something so awesome, I don't see why I should get credit for quickly making a few images XD)

    OnlineHD:
    [​IMG]

    OfflineHD2 (With tags, going to PM you a link to the one without):
    [​IMG]

    For all those ninja people who realize that I'm using imageshack to host these images, I've made the one without tags... private! Mwhaha... now you cant see it! (Unless of course tyzoid makes it available to you)

    On a side note, tyzoid want me to add some more stuff to the 'faded' words? Perhaps for a version for the freely hosted one, giving credit to the hosts?
     
    tyzoid likes this.
  17. Offline

    tyzoid

    muffinjello
    Implemented, just add &theme=muffin to access your theme.
    [​IMG]

    I think that everything should be fine.
    On the other hand, if you prefer that I use an alternate font (must be open source!) I can implement that as well.

    Updated the online script to handle new data formats present in 1.5.1.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 31, 2016
    muffinjello and -_Husky_- like this.
  18. Offline

    tyzoid

    For those who want to use a banner, use the theme banner1:
    Code:
    http://tyzoid.koding.com/mcb/image.php?ip=server.tyzoid.com&port=25565&ontext=Metropolis%20Survival%20-%20server.tyzoid.com&offtext=Metropolis%20Survival%20is%20offline&theme=banner1
    becomes
    [​IMG]
     
  19. Offline

    LiLChris

    Thanks for this! :D
     
    tyzoid likes this.
  20. Offline

    zecheesy

    tyzoid
    for some reason my image is not updating
    banner on my site: http://cheesium.com/banner/infinite.php
    banner on yours: http://tyzoid.koding.com/mcb/image....&ontext=This server is online&offtext=offline

    code:
    Code:
    <?php
    putenv('GDFONTPATH=' . realpath('.'));
    //Variables:
    $server = "infinite.cheesium.com";
    $serverport  = "25565";
     
    ignore_user_abort(true);
    function query($ip, $port){
        @$f = fsockopen($ip, $port, $errorno, $errordesc, 2);
        if($f === false) return false; //connection failed
        fwrite($f, "\xfe");
        $data = fread($f, 256);
        if(substr($data, 0, 1) != "\xff") return false; //Not a minecraft server
        $data2 = mb_convert_encoding(substr($data, 3), 'UTF8', 'UCS-2');
        $data = explode("ยง", mb_convert_encoding(substr($data, 3), 'UTF8', 'UCS-2'));
        return array(
            "players" => intval($data[count($data)-2]),
            "maxplayers" => intval(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*0 < time());
        $waituntilafter = (intval(substr($line,4))+60*4 > 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 = "./online2.png";
        $image = ImageCreateFromPNG($name);
        imagesavealpha($image, true);
        $color = imagecolorallocate($image, 64, 64, 64); // #444
        imagettftext($image, 24, 0, 23, 126, $color, 'newscycle.ttf', sprintf("%02d", $players).'/100');
        // imagettftext($image, $fontsize, $slant, $x, $y, $color, $fontfile, $string);
        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);
    }
    ?>
     
  21. Offline

    tyzoid

    zecheesy likes this.
  22. Offline

    tyzoid

    zecheesy
    Updated. Check for the latest source in the OP.
     
  23. Offline

    tyzoid

    The generator now generates .png links (finally). You can now embed your banners in the MCF and other IPB sites.
     
  24. Offline

    tyzoid

    A few more updates:
    The generator now honors SRV records, i.e. usage without a port. If your IP is an SRV record, leave the port as default and it will automatically obtain the correct port and address.

    If you have no clue what this means, enter the IP that you usually connect with, and the port if you use it. If you don't use a port, leave it as 25565 (default).

    Also: shortened links coming! I have a mathematical system that allows for millions of links under four characters. This should remove annoyingly long URLs such as: http://mclist.me/banner/c3fe46f4f9d.../cf6f9fa047181fbdbe98eca6a15ddc2564b2706b.png
    Code:
    http://mclist.me/banner/c3fe46f4f9d5b441d3d6c08d83f66f19915ad7c6/cf6f9fa047181fbdbe98eca6a15ddc2564b2706b.png
     
  25. Offline

    tyzoid

    Few quick announcements/updates:
    Short URLs now work, and are generated by the generator.
    http://mclist.me/b/6lL.png
    yields
    [​IMG]

    Also, some people may have noticed the server IP appearing on their banners, this was intentional, but was not added until SRV records and port consistencies were squared away. If they appear on your banner and you do not like it, sorry. I will add an option soon to remove it. Remember: only certain themes (banner1 and banner2) support this new feature.

    Also, I'm still taking theme/image submissions (standard 728x90 preferred). If you wish to submit one, be sure to include an "Online" banner, and an "Offline banner (preferably with online or offline printed on it somewhere).

    Edit:
    A few final notes, I am in the process of writing an API to generate these, as well as "branded" images, i.e. status images generated by and for server hosts.

    These would include a "powered by xxx host" or logo of the server host.

    Edit 2:
    Api is online:
    http://tyzoid.koding.com/mcb/index....ropolis+Hardcore+is+offline&theme=banner2&api
    (this generates the image seen at the top of this post)
     
  26. Offline

    muffinjello

    tyzoid great to see that this is coming along! :)
     
    tyzoid likes this.
  27. Offline

    tyzoid

    Here are some examples of branded images. Note, if you are a server host, and are interested in creating branded server banners for your subscribers, send me a PM, I'll give you the details, as there is also a special API for generating them. ( Clinton -_Husky_- )
    [​IMG]

    [​IMG]

    [​IMG]

    [​IMG]
     
    -_Husky_- likes this.
  28. Offline

    muffinjello

    tyzoid
    Will you ever make an explanation of what everything means?
    I am currently looking about doing something similar to this for my servers, but instead of displaying the information on an image, I want to display it in normal HTML.
    (I already am experimenting on getting it to work myself, though :) )

    Thanks!
     
  29. Offline

    tyzoid

    Here it shows only text:
    text only (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;
    $waituntilafter false;
    if(
    file_exists("check.txt")){
        
    $file fopen("check.txt""r");
        if(!
    feof($file)) {
            
    $line fgets($file);
            
    $online = (substr($line,0,1) === "t");
            
    $players intval(substr($line,1,4));
            
    $maxplayers intval(substr($line,5,4));
            
    $expired = (intval(substr($line,8))+60*time());
            
    $waituntilafter = (intval(substr($line,8))+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("%04d", (($info !== false)?$info['players']:0)) . sprintf("%04d", (($info !== false)?$info['maxplayers']:0)));
        
    fwrite($file,(string)time());
        
    fclose($file);
     
        
    $players = (($info !== false)?$info['players']:0);
        
    $maxplayers = (($info !== false)?$info['maxplayers']:0);
    } else {
        
    $info $online;
    }
     
    if(
    $info === false){
        echo 
    "This server is offline";
    } else {
        echo 
    "There are $players/$maxplayers players online.";
    }
     
    if(
    function_exists("fastcgi_finish_request")) 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("%04d", (($info !== false)?$info['players']:0)) . sprintf("%04d", (($info !== false)?$info['maxplayers']:0)));
        
    fwrite($file,(string)time());
        
    fclose($file);
    }
    ?>


    Edit: You should check this out: http://forums.bukkit.org/threads/we...raft-server-status-query.144329/#post-1653410

    It is a PHP server querier intended to be easy to use. (Mine is a bit smaller, but it exposes the internals of what is going on)
     
    muffinjello likes this.
  30. Offline

    lemmymet

    [Sat May 18 15:33:35 2013] [warn] [client 83.84.242.194] mod_fcgid: stderr: PHP Fatal error: Call to undefined function mb_convert_encoding() in /home/corewolf/domains/redfoxgaming.net/public_html/mc.php on line 13
    :<
     
Thread Status:
Not open for further replies.

Share This Page