Web

Here are some codes you can use to display information from DBStatus.
The Class: Call it DBStatus.class.php
<?php /* * @author PROSPY78 & Stuntguy3000 * @since 24/08/2012, 10:17:49 PM * @link http://www.MineClub.org * @copyright MineClub 2012 * @DO NOT REMOVE THIS INFO! * @PLEASE DO NOT EDIT THIS CLASS! */ /* * How To Use * $DBServer = array( 'ip' => 'serverip', 'port' => '25565' ); */ try { $db = new PDO("mysql:host={$connect['host']};dbname={$connect['dbname']}", $connect['username'], $connect['password']); } catch (PDOException $e) { echo $e->getMessage(); } $DBStatus = $db->query("SELECT * FROM DBStatus"); $DBStatus->setFetchMode(PDO::FETCH_OBJ); while ($row = $DBStatus->fetch()) { $onlinePlayers = $row->onlinePlayers; $maxPlayers = $row->maxPlayers; $motd = $row->motd; } $serverIP = $DBServer['ip']; $serverPort = $DBServer['port']; if (empty($serverPort)) { $serverPort = '25565'; } function Status($serverIP, $serverPort) { $fp = @fsockopen($serverIP, $serverPort, $errno, $errstr, 2); if (!$fp) { $serverStatus = false; $onlinePlayers = '0'; $playerList = ''; } else { $serverStatus = true; } } ?>
Here's an example page:
<?php /* * @author PROSPY78 & Stuntguy3000 * @since 25/08/2012, 11:47:35 AM * @link http://www.MineClub.org * @copyright MineClub 2012 * @Please do not remove this. */ // Connect to your server's database $connect = array( 'host' => 'db_host', // Usally "localhost" unless you are connecting to your server's built in database. 'dbname' => 'db_name', // Your Database Name 'username' => 'db_user', // Your Database Username 'password' => 'db_pass' // Your Database Password ); // Connect to the server $DBServer = array( 'ip' => 'serverip', // Your server's ip. 'port' => '25565' // Default port is 25565 ); // Include the Class require_once('lib/DBStatus.class.php'); /* ---- Variables you can use ---- * $onlinePlayers - Returns the amount of players online. * $maxPlayers - Returns the maximum amount of players the server can hold. * $motd - Returns the MOTD that you have set in your server's properties file. * $eco - Returns the name of your economy that you have set in the config file of the plugin. * $serverIP - Returns the IP of the server. * $serverPort - Returns the port of the server. * */ if ($serverStatus) { echo'<font color="green"><strong>Online</strong></font><br />'; } else { echo'<font color="red"><strong>Offline</strong></font><br />'; } echo'<strong>'.$serverIP.':'.$serverPort.'</strong>'; echo'<strong>'.$motd.'</strong><br />'; echo'<strong>Players Online:</strong> '.$onlinePlayers.'/'.$maxPlayers; /* Player Variables * $row['player'] - Returns the player's username. * $row['bal'] - Returns the player's ingame money. * $row['group'] - Returns the player's group. * $row['helmet'] - Returns the player's helmet (id). - Will be set to 0 if user has nothing on * $row['chestplate'] - Returns the player's chestplate (id). - Will be set to 0 if user has nothing on * $row['leggings'] - Returns the player's leggings (id). - Will be set to 0 if user has nothing on * $row['boots'] - Returns the player's boots (id). - Will be set to 0 if user has nothing on */ // Get Player List if ($serverStatus) { echo'<br /><strong>Players Online:</strong><br />'; $DBStatusPlayers = $db->query("SELECT * FROM DBStatus-Players"); foreach ($DBStatusPlayers as $row) { echo'<strong>'.$row['player'].'</strong> - '.$row['bal'].' '.$eco.' - Group: '.$row['group']; } } ?>
Comments