Advertisement
Guest User

Untitled

a guest
Apr 14th, 2015
2,045
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.41 KB | None | 0 0
  1. <?php
  2. ini_set("display_errors", 1);
  3. ini_set("track_errors", 1);
  4. ini_set("html_errors", 1);
  5. error_reporting(E_ALL);
  6.  
  7. //The following script is tested only with servers running on Minecraft 1.7.
  8.  
  9. #$SERVER_IP = "85.216.114.72"; //Insert the IP of the server you want to query.
  10. $SERVER_IP = "176.31.104.74"; //Insert the IP of the server you want to query.
  11. $SERVER_PORT = "25565"; //Insert the PORT of the server you want to ping. Needed to get the favicon, motd, players online and players max. etc
  12. $QUERY_PORT = "25569"; //Port of query.port="" in your server.properties. Needed for the playerlist! Can be the same like the port or different. Query must be enabled in your server.properties file!
  13.  
  14. $HEADS = "3D"; //"normal" / "3D"
  15. $show_max = "unlimited"; // how much playerheads should we display? "unlimited" / "10" / "53"/ ...
  16. $SHOW_FAVICON = "on"; //"off" / "on"
  17.  
  18. $TITLE = "My fancy Serverpage";
  19. $TITLE_BLOCK_ONE = "General Information";
  20. $TITLE_BLOCK_TWO = "Players";
  21.  
  22. ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  23.  
  24. $ping = json_decode(file_get_contents('http://api.minetools.eu/ping/' . $SERVER_IP . '/' . $SERVER_PORT . ''), true);
  25. $query = json_decode(file_get_contents('http://api.minetools.eu/query/' . $SERVER_IP . '/' . $QUERY_PORT . ''), true);
  26.  
  27. //Put the collected player information into an array for later use.
  28. if(empty($ping['error'])) {
  29. $version = $ping['version']['name'];
  30. $online = $ping['players']['online'];
  31. $max = $ping['players']['max'];
  32. $motd = $ping['description'];
  33. $favicon = $ping['favicon'];
  34. }
  35.  
  36. echo $query['error'];
  37.  
  38. if(empty($query['error'])) {
  39. $playerlist = $query['Playerlist'];
  40. }
  41.  
  42. ?>
  43. <!DOCTYPE html>
  44. <html>
  45. <head>
  46. <meta charset="utf-8">
  47. <title><?php echo htmlspecialchars($TITLE); ?></title>
  48. <link href="//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css" rel="stylesheet">
  49. <link href='http://fonts.googleapis.com/css?family=Lato:300,400' rel='stylesheet' type='text/css'>
  50. <link href="//maxcdn.bootstrapcdn.com/font-awesome/4.2.0/css/font-awesome.min.css" rel="stylesheet">
  51. <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/2.0.3/jquery.min.js"></script>
  52. <script src="//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/js/bootstrap.min.js"></script>
  53. <script language="javascript">
  54. jQuery(document).ready(function(){
  55. $("[rel='tooltip']").tooltip();
  56. });
  57. </script>
  58. <style>
  59. /*Custom CSS Overrides*/
  60. body {
  61. font-family: 'Lato', sans-serif !important;
  62. }
  63. </style>
  64. </head>
  65. <body>
  66. <div class="container">
  67. <h1><?php echo htmlspecialchars($TITLE); ?></h1><hr>
  68. <div class="row">
  69. <div class="col-md-4">
  70. <h3><?php echo htmlspecialchars($TITLE_BLOCK_ONE); ?></h3>
  71. <table class="table table-striped">
  72. <tbody>
  73. <tr>
  74. <td><b>IP</b></td>
  75. <td><?php echo $SERVER_IP; ?></td>
  76. </tr>
  77. <?php if(empty($ping['error'])) { ?>
  78. <tr>
  79. <td><b>Version</b></td>
  80. <td><?php echo $version; ?></td>
  81. </tr>
  82. <?php } ?>
  83. <?php if(empty($ping['error'])) { ?>
  84. <tr>
  85. <td><b>Players</b></td>
  86. <td><?php echo "".$online." / ".$max."";?></td>
  87. </tr>
  88. <?php } ?>
  89. <tr>
  90. <td><b>Status</b></td>
  91. <td><?php if(empty($ping['error'])) { echo "<i class=\"fa fa-check-circle\"></i> Server is online"; } else { echo "<i class=\"fa fa-times-circle\"></i> Server is offline";}?></td>
  92. </tr>
  93. <?php if(empty($ping['error'])) { ?>
  94. <?php if(!empty($favicon)) { ?>
  95. <?php if ($SHOW_FAVICON == "on") { ?>
  96. <tr>
  97. <td><b>Favicon</b></td>
  98. <td><img src='<?php echo $favicon; ?>' width="64px" height="64px" style="float:left;"/></td>
  99. </tr>
  100. <?php } ?>
  101. <?php } ?>
  102. <?php } ?>
  103. </tbody>
  104. </table>
  105. </div>
  106. <div class="col-md-8" style="font-size:0px;">
  107. <h3><?php echo htmlspecialchars($TITLE_BLOCK_TWO); ?></h3>
  108. <?php
  109. if($HEADS == "3D") {
  110. $url = "https://cravatar.eu/helmhead/";
  111. } else {
  112. $url = "https://cravatar.eu/helmavatar/";
  113. }
  114.  
  115. if(empty($query['error'])) {
  116. if($playerlist != "null") { //is at least one player online? Then display it!
  117. $shown = "0";
  118. foreach ($playerlist as $player) {
  119. $shown++;
  120. if($shown < $show_max + 1 || $show_max == "unlimited") {
  121. ?>
  122. <a data-placement="top" rel="tooltip" style="display: inline-block;" title="<?php echo $player;?>">
  123. <img src="<?php echo $url.$player;?>/50" size="40" width="40" height="40" style="width: 40px; height: 40px; margin-bottom: 5px; margin-right: 5px; border-radius: 3px; "/></a>
  124. <?php }
  125. }
  126. if($shown > $show_max && $show_max != "unlimited") {
  127. echo '<div class="col-md-8" style="font-size:16px; margin-left: 0px;">';
  128. echo "and " . (count($playerlist) - $show_max) . " more ...";
  129. echo '</div>';
  130. }
  131. } else {
  132. echo "<div class=\"alert alert-info\" style=\"font-size:16px;\"> There are no players online at the moment! <i class=\"fa fa-frown-o\"></i></div>";
  133. }
  134. } else {
  135. echo "<div class=\"alert alert-danger\" style=\"font-size:16px;\"> Query must be enabled in your server.properties file! <i class=\"fa fa-meh-o\"></i></div>";
  136. } ?>
  137. </div>
  138. </div>
  139. </div>
  140. </body>
  141. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement