Please upgrade here. These earlier versions are no longer being updated and have security issues.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.

Issues with simple side panel plugin

Hey, I am trying to update an old plugin of mine for someone. Basically it is a simple box in the side panel that gives information on the status of a minecraft server. The old one seemed to no longer work.

I have managed to fix the issue of the actual server query part no longer working however now when the plugin is enabled visiting any of the sites pages results in a plain white page. Viewing this with inspect element there is nothing inside the body tags at all.

I can comment out everything in public function ToString() which is part of my class MinecraftServerQuery extends Gdn_Module and the page loads fine, I can also just put a simple echo "hello"; which echos hello as it should.

The code I am using for the server query can be found on github. I've even tried completely copying someone elses plugin which simply adds content to the side panel and just replacing what is in the ToString() function and it doesn't work which leads me to believe it is something wrong with that. I can, however, get it working as a standalone out of vanilla.

Oh yes I am on 2.1.8p2


  • Options

    What code do you have in the public function ToString()?

    Add Pages to Vanilla with the Basic Pages app

  • Options

    I tried with two different server query classes, both didn't work first one:

    include_once 'MinecraftServerStatus/status.class.php'; $status = new MinecraftServerStatus(); $response = $status->getStatus(''); if(!$response) { echo"The Server is offline!"; } else { echo"<img width=\"64\" height=\"64\" src=\"".$response['favicon']."\" /> <br> The Server ".$response['hostname']." is running on ".$response['version']." and is online, currently are ".$response['players']." players online of a maximum of ".$response['maxplayers'].". The motd of the server is '".$response['motd']."'. The server has a ping of ".$response['ping']." milliseconds."; }

    second one:

    use xPaw\MinecraftQuery; use xPaw\MinecraftQueryException; // Edit this -> define( 'MQ_SERVER_ADDR', 'localhost' ); define( 'MQ_SERVER_PORT', 25565 ); define( 'MQ_TIMEOUT', 1 ); // Edit this <- // Display everything in browser, because some people can't look in logs for errors Error_Reporting( E_ALL | E_STRICT ); Ini_Set( 'display_errors', true ); require __DIR__ . '/src/MinecraftQuery.php'; require __DIR__ . '/src/MinecraftQueryException.php'; $Timer = MicroTime( true ); $Query = new MinecraftQuery( ); try { $Query->Connect( MQ_SERVER_ADDR, MQ_SERVER_PORT, MQ_TIMEOUT ); } catch( MinecraftQueryException $e ) { $Exception = $e; } $Timer = Number_Format( MicroTime( true ) - $Timer, 4, '.', '' );
    that one goes on more, but is just the html and basically just comes down to

    <?php if( ( $Info = $Query->GetInfo( ) ) !== false ): ?> <?php foreach( $Info as $InfoKey => $InfoValue ): ?> <tr> <td><?php echo htmlspecialchars( $InfoKey ); ?></td> <td><?php if( Is_Array( $InfoValue ) ) { echo "<pre>"; print_r( $InfoValue ); echo "</pre>"; } else { echo htmlspecialchars( $InfoValue ); } ?></td> </tr> <?php endforeach; ?> <?php else: ?> <tr> <td colspan="2">No information received</td> </tr> <?php endif; ?>

    I won't be surprised if there is some PHP issue that I don't know about, I don't exactly know how PHP works just it's syntax

  • Options
    ShadowdareShadowdare r_j MVP
    edited January 2015

    Try the first code, add $Configuration['Debug'] = TRUE; to your /conf/config.php file, and refresh the page that's showing up as a plain white page. I wonder if there are some errors that aren't being displayed for the MinecraftServerStatus class.

    Add Pages to Vanilla with the Basic Pages app

  • Options

    Okay added the debug and ended up getting both solutions working, thanks heaps. The issues with the first was I was just pointing to the wrong directory -.- and the issue with the second was the use had to be in global space not in a class.

Sign In or Register to comment.