[WEB][PHP] Minecraft Server Query with Avatars // EASY!

Discussion in 'Bukkit Tools' started by iPhwnU, Jan 16, 2014.

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

    iPhwnU

    [​IMG]

    This script was designed to be as easy as possible and is probably the easiest way to query your Minecraft server with avatars. It works with any web host and doesn't require any extra privileges to run.
    Github: https://github.com/Markkus1337/MinecraftAvatarQuery

    This script features:
    • Minecraft avatars from Minotar
    • Twitter Bootstrap framework
    • Minecraft 1.7 support
    How to use:

    1) Download the avatarquery.php file.
    2) Edit the $SERVER_IP variable to match your desired IP.
    3) Upload the file to your webserver.
    4) Done!
     
    GrandmaJam, htmlman1 and Wizehh like this.
  2. Offline

    LCastr0

    Wow! It's awesome!!!
     
  3. Offline

    IanSzot

  4. Offline

    TNTUP


    Query is disabled I guess, cause I tried my server and it works. (Shows player names on the server.) I tried querying your server, query must be disabled. Try it?
     
  5. Offline

    iPhwnU

    IanSzot Make sure your query is enabled and query port is set as TNTUP already mentioned, unless you are using BungeeCord. In case you are using BungeeCord, then you must enable query in BungeeCord config.yml file.

    If you want to query each Bungee server separately with this script, then you must apply a few workarounds.
     
  6. Offline

    Airsoft742

    I'm having a bit of trouble, being as I am new to PHP. When trying to run the file on a popular server, this error came back. "Notice: Undefined variable: users in C:\xampp\htdocs\boot\test.php on line 74" which is the beginning line of the loop. What should I do to resolve this problem?
    PHP:
    <?php
                    
    //Take the username values from the array & grab the avatars from Minotar.               
                    
    foreach($array_list as $key => $value){$users .= "<a data-placement=\"top\" rel=\"tooltip\" style=\"display: inline-block;\" title=\"".$value."\">
                    <img src=\"https://minotar.net/avatar/"
    .$value."/50\" size=\"40\" width=\"40\" height=\"40\" style=\"width: 40px; height: 40px; margin-bottom: 5px; margin-left: 5px; border-radius: 3px;\"/></a>";}
                    
    //Display the avatars only when there are players online.
                    
    if($data_general['players'] > 0) {
                        
    print_r($users);
                        }
                    
    //If no avatars can be shown, display an error.
                    
    else {
                        echo 
    "<div class=\"alert\"> There are no players online at the moment!</div>";
                        }               
                    
    ?>
     
  7. Offline

    iPhwnU

    Airsoft742 Have you made any changes prior to the loop? I suggest you to pastebin the code if you've made any changes, otherwise it's hard to tell what's wrong. :)
     
  8. Offline

    ItsLeoFTW

    Small error that can be a bit bad:

    PHP:
    <td><? if($data_general['status'] == 'true') { echo "<i class=\"icon-ok-sign\"></i> Status: Online"; } else { echo "<i class=\"icon-remove-sign\"></i> Status: Offline";}?></td>
    should be:
    PHP:
    <td><?php if($data_general['status'] == 'true') { echo "<i class=\"icon-ok-sign\"></i> Status: Online"; } else { echo "<i class=\"icon-remove-sign\"></i> Status: Offline";}?></td>
    At least that's what I found
     
  9. Offline

    Cwtch22


    This is because $users doesn't exist, to fix this, simple paste this code
    Code:
    $users = "";
    before the foreach
    Code:
    foreach($array_list as $key => $value...
     
  10. Offline

    Plumeex

    It's beautiful! :D
    I tweaked it a little bit, you can see it here.

    Also, I don't think it is possible since the script grabs the data directly from the server, but... Any way to hide vanished players with the script only?

    If it's not possible, how can I modify the script to grab the data from a plugin (that will exclude vanished players) instead of the server itself?

    Anyway, thanks for the script!
     
  11. Offline

    almazio1

    Doesn't seem to work very well with bungeecord, players online, version and latency works but the player list and head's don't show up.Only a message saying to enable query but i have.
    Edit: Everything works now that i updated to a newer build of bungeecord, Awesome script. Edit 2: Getting the same error again :( Only works sometimes:
    Code:
    03:00:35 [SEVERE] Apr 19, 2014 3:00:35 AM io.netty.channel.DefaultChannelPipeline$TailHandler exceptionCaught
     
    WARNING: An exceptionCaught() event was fired, and it reached at the tail of the pipeline. It usually means the last handler in the pipeline did not handle the exception.
     
    java.lang.IllegalStateException: No session!
     
        at net.md_5.bungee.query.QueryHandler.channelRead0(QueryHandler.java:82)
     
        at net.md_5.bungee.query.QueryHandler.channelRead0(QueryHandler.java:20)
     
        at io.netty.channel.SimpleChannelInboundHandler.channelRead(SimpleChannelInboundHandler.java:103)
     
        at io.netty.channel.DefaultChannelHandlerContext.invokeChannelRead(DefaultChannelHandlerContext.java:340)
     
        at io.netty.channel.DefaultChannelHandlerContext.fireChannelRead(DefaultChannelHandlerContext.java:326)
     
        at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:785)
     
        at io.netty.channel.nio.AbstractNioMessageChannel$NioMessageUnsafe.read(AbstractNioMessageChannel.java:87)
     
        at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:494)
     
        at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:461)
     
        at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:378)
     
        at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:350)
     
        at io.netty.util.concurrent.SingleThreadEventExecutor$2.run(SingleThreadEventExecutor.java:101)
     
        at java.lang.Thread.run(Thread.java:744)
     
     
     
    
     
  12. Offline

    Squawkers13

    When I access the page (changed nothing but IP, have
    HTML:
    <!DOCTYPE html>
    <html>
        <head>
            <meta charset="utf-8">
            <title>MC PHP Query 2</title>
            <link rel="stylesheet" href="https://netdna.bootstrapcdn.com/twitter-bootstrap/2.3.2/css/bootstrap-combined.no-icons.min.css">
            <link href='http://fonts.googleapis.com/css?family=Lato:300,400' rel='stylesheet' type='text/css'>
            <link href="https://netdna.bootstrapcdn.com/font-awesome/3.2.1/css/font-awesome.css" rel="stylesheet">
            <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/2.0.3/jquery.min.js"></script>
            <script type="text/javascript" src="https://netdna.bootstrapcdn.com/twitter-bootstrap/2.3.2/js/bootstrap.min.js"></script>
            <script language="javascript">
              jQuery(document).ready(function(){
                $("[rel='tooltip']").tooltip();
            });
            </script>
            <style>
            /*Custom CSS Overrides*/
            body {
                  font-family: 'Lato', sans-serif !important;
            }
            </style>
        </head>
        <body>
        <div class="container">
            <h1>MC PHP Query</h1><hr>     
            <div class="row">
                <div class="span4">
                    <h3>General Information</h3>
                    <table class="table table-striped">
                        <tbody>
                        <tr>
                        <td><b>IP</b></td>
                        <td>mc.pekkit.net</td>
                        </tr>
                        <br />
    <font size='1'><table class='xdebug-error xe-notice' dir='ltr' border='1' cellspacing='0' cellpadding='1'>
    <tr><th align='left' bgcolor='#f57900' colspan="5"><span style='background-color: #cc0000; color: #fce94f; font-size: x-large;'>( ! )</span> Notice: Undefined index: error in C:\wamp\www\minequery.php on line <i>70</i></th></tr>
    <tr><th align='left' bgcolor='#e9b96e' colspan='5'>Call Stack</th></tr>
    <tr><th align='center' bgcolor='#eeeeec'>#</th><th align='left' bgcolor='#eeeeec'>Time</th><th align='left' bgcolor='#eeeeec'>Memory</th><th align='left' bgcolor='#eeeeec'>Function</th><th align='left' bgcolor='#eeeeec'>Location</th></tr>
    <tr><td bgcolor='#eeeeec' align='center'>1</td><td bgcolor='#eeeeec' align='center'>0.0010</td><td bgcolor='#eeeeec' align='right'>256832</td><td bgcolor='#eeeeec'>{main}(  )</td><td title='C:\wamp\www\minequery.php' bgcolor='#eeeeec'>..\minequery.php<b>:</b>0</td></tr>
    </table></font>
                        <tr>
                        <td><b>Version</b></td>
                        <td>1.7.9</td>
                        </tr>
                                            <br />
    <font size='1'><table class='xdebug-error xe-notice' dir='ltr' border='1' cellspacing='0' cellpadding='1'>
    <tr><th align='left' bgcolor='#f57900' colspan="5"><span style='background-color: #cc0000; color: #fce94f; font-size: x-large;'>( ! )</span> Notice: Undefined index: error in C:\wamp\www\minequery.php on line <i>76</i></th></tr>
    <tr><th align='left' bgcolor='#e9b96e' colspan='5'>Call Stack</th></tr>
    <tr><th align='center' bgcolor='#eeeeec'>#</th><th align='left' bgcolor='#eeeeec'>Time</th><th align='left' bgcolor='#eeeeec'>Memory</th><th align='left' bgcolor='#eeeeec'>Function</th><th align='left' bgcolor='#eeeeec'>Location</th></tr>
    <tr><td bgcolor='#eeeeec' align='center'>1</td><td bgcolor='#eeeeec' align='center'>0.0010</td><td bgcolor='#eeeeec' align='right'>256832</td><td bgcolor='#eeeeec'>{main}(  )</td><td title='C:\wamp\www\minequery.php' bgcolor='#eeeeec'>..\minequery.php<b>:</b>0</td></tr>
    </table></font>
                        <tr>
                        <td><b>Players</b></td>
                        <td>1 / 100</td>
                        </tr>
                                            <tr>
                        <td><b>Status</b></td>
                        <td><? if($data_general['status'] == 'true') { echo "<i class=\"icon-ok-sign\"></i> Server is online"; } else { echo "<i class=\"icon-remove-sign\"></i> Server is offline";}?></td>
                        </tr>
                        <br />
    <font size='1'><table class='xdebug-error xe-notice' dir='ltr' border='1' cellspacing='0' cellpadding='1'>
    <tr><th align='left' bgcolor='#f57900' colspan="5"><span style='background-color: #cc0000; color: #fce94f; font-size: x-large;'>( ! )</span> Notice: Undefined index: error in C:\wamp\www\minequery.php on line <i>86</i></th></tr>
    <tr><th align='left' bgcolor='#e9b96e' colspan='5'>Call Stack</th></tr>
    <tr><th align='center' bgcolor='#eeeeec'>#</th><th align='left' bgcolor='#eeeeec'>Time</th><th align='left' bgcolor='#eeeeec'>Memory</th><th align='left' bgcolor='#eeeeec'>Function</th><th align='left' bgcolor='#eeeeec'>Location</th></tr>
    <tr><td bgcolor='#eeeeec' align='center'>1</td><td bgcolor='#eeeeec' align='center'>0.0010</td><td bgcolor='#eeeeec' align='right'>256832</td><td bgcolor='#eeeeec'>{main}(  )</td><td title='C:\wamp\www\minequery.php' bgcolor='#eeeeec'>..\minequery.php<b>:</b>0</td></tr>
    </table></font>
                        <tr>
                        <td><b>Latency</b></td>
                        <td>0ms</td>
                        </tr>
                                            </tbody>
                    </table>
                </div>
                <div class="span8">
                    <h3>Players</h3>
                    <br />
    <font size='1'><table class='xdebug-error xe-notice' dir='ltr' border='1' cellspacing='0' cellpadding='1'>
    <tr><th align='left' bgcolor='#f57900' colspan="5"><span style='background-color: #cc0000; color: #fce94f; font-size: x-large;'>( ! )</span> Notice: Undefined index: error in C:\wamp\www\minequery.php on line <i>98</i></th></tr>
    <tr><th align='left' bgcolor='#e9b96e' colspan='5'>Call Stack</th></tr>
    
    query enabled) I get this back:
     
  13. Offline

    The_Punkster

    Is there a way I can use this in an iFrame where the background is transparent or i can put a bg on it>
     
  14. Offline

    Plumeex

    Sure, just add background: <stuff> in body {.
     
  15. Offline

    NoHoPeLess

    This wont work for me... i use Craftbukkit 1.7.2 Beta and Query is set to true port is 25565 and it results in nothing... any help or ideas would be great. Thx
     
  16. Offline

    NoHoPeLess

    I think i found the bug?!

    In the Script:

    PHP:
    $userlistserver get_data("http://api.iamphoenix.me/list/?server_ip=" $SERVER_IP "");
    $serverdata get_data("http://minecraft-api.com/v1/get/?server=" $SERVER_IP "");
    results in:

    http://api.iamphoenix.me/list/?server_ip= : Hey, this file doesn't exists!
    http://minecraft-api.com/v1/get/?server= : Error 502 Ray ID: 13983ba749fe046d Bad gateway


    I dont know if it is this error?!?!?! Please Help :(
     
  17. Offline

    McLive

    Yonas and NoHoPeLess like this.
  18. Offline

    NoHoPeLess

    Thx McLive, this helps a little bit.

    Soo im not sooo very nice in this.

    I dont understand how can i "grab" the avatars and names from the api into the code?
     
  19. Offline

    McLive

    I'll look for this later and edit it to use the other API.
     
    NoHoPeLess likes this.
  20. Offline

    NoHoPeLess

    Thx you so much!
     
  21. Offline

    McLive

    It's now working with the mcapi.sweetcode.de API.
    You can find it here: https://github.com/McLive/MinecraftAvatarQuery/tree/master

    While I did this I fixed some other issues in this script and added two new functions:
    - 3D Avatars from cravatar.eu
    - Display servers favicon

    You can disable both in the "config" if you don't want them.

    Note: The script may have some bugs with an other port than 25565 :/ try it^^
     
  22. Offline

    Plumeex

    Thank you so much *u*
     
  23. Offline

    NoHoPeLess

    Thanks! It works great! 1 little thing...?! :D

    On my site: Warning: Invalid argument supplied for foreach() in /var/customers/webs/ni103312_3/bclist/bclistv1.php on line 136

    This is the line:

    PHP:
    foreach($array_list as $key => $value) {
    ? :D
     
  24. Offline

    NoHoPeLess

    This is only when nobody is on the server
     
  25. Offline

    McLive

  26. Offline

    NoHoPeLess

  27. Offline

    Doc94

    Nice.
    Hopefully the public code is finished for this script to work locally and not from an external web dependending ...
     
  28. Offline

    iPhwnU

    The aim of this script is to be as minimalistic as possible.

    McLive
    Haven't checked on the forums for a while, but I like the modifications you did on the forked branch. Kudos to you for updating it with new API :p
     
  29. Offline

    Plumeex

    McLive I uptated the file with your new commit but now I have this when no players are online:
    Warning: Invalid argument supplied for foreach() in /[...]/avatarquery.php on line 156

    However the "nobody online" message is shown.
    (I tweaked the file but the I have the bug even with the default one, line 149).
    Could you take a look? Thanks. :)
     
  30. Offline

    jdf2

    iPhwnU McLive Plumeex That's normally shown when it's not an array being given to foreach.
    Just check if its an array:
    PHP:
    if (is_array($values))
    {
        foreach (
    $values as $value)
        {
            ...
        }
    }
    If its not it must mean no players are online right? I might be horribly wrong as I haven't fully read through the code. (Just kinda looked at it you know...) Any ways: I'll edit this if I find out i'm wrong...


    EDIT: Looks like the Query has been Deprecated on the API: http://prntscr.com/3wnew
     
Thread Status:
Not open for further replies.

Share This Page