PageRenderTime 41ms CodeModel.GetById 13ms RepoModel.GetById 0ms app.codeStats 0ms

/trunk/WebSource/jweb/admincp/dashboard.php

#
PHP | 219 lines | 173 code | 20 blank | 26 comment | 16 complexity | 1395661969b811761fbe3b436332ddf0 MD5 | raw file
Possible License(s): GPL-3.0
  1. <?php
  2. /*
  3. * jWeb
  4. * Copyright (C) 2010 Jolt Environment Team
  5. *
  6. * This program is free software: you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation, either version 3 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  18. */
  19. define('ACP_TITLE', 'Dashboard');
  20. define('ACP_TAB', 1);
  21. require_once("adminglobal.php");
  22. check_rights();
  23. require_once("header.php");
  24. $stat['server_version'] = dbevaluate("SELECT server_version FROM versioning;");
  25. $stat['website_version'] = dbevaluate("SELECT website_version FROM versioning;");
  26. $stat['database_version'] = dbevaluate("SELECT database_version FROM versioning;");
  27. $stat['client_version'] = dbevaluate("SELECT client_version FROM versioning;");
  28. $stat['user_count'] = dbevaluate("SELECT COUNT(id) FROM characters;");
  29. $stat['inactive_users'] = dbevaluate("SELECT COUNT(id) FROM characters WHERE active = '0';");
  30. $stat['users_online'] = dbevaluate("SELECT COUNT(id) FROM characters WHERE online = '1';");
  31. $stat['staff_members'] = dbevaluate("SELECT COUNT(id) FROM characters WHERE server_rights >= '1';");
  32. $stat['last_startup'] = dbevaluate("SELECT startup_time FROM worlds ORDER BY startup_time LIMIT 1");
  33. $stat['mysql_version'] = dbevaluate("SELECT version();");
  34. $stat['world_count'] = dbevaluate("SELECT COUNT(world_id) FROM worlds");
  35. $result = dbquery("SHOW TABLE STATUS");
  36. while($row = mysql_fetch_array($result)) {
  37. $db_size += $row["Data_length"] + $row["Index_length"];
  38. }
  39. $db_size = formatsize($db_size);
  40. /**
  41. * Check if any notes are trying to be added.
  42. */
  43. if (isset($_GET['add_note'])) {
  44. $note = filter_for_input($_GET['add_note']);
  45. if (strlen($note) < 3 || strlen($note) > 100) {
  46. acp_error("Unable to add note.");
  47. } else {
  48. dbquery("INSERT INTO web_acp_notes (user,note_date,note_message) VALUES ('" . ACP_NAME . "', NOW(), '" . $note . "')");
  49. add_log(ACP_NAME, USER_IP, "Added a note.");
  50. acp_success("Successfully added note.");
  51. }
  52. }
  53. /**
  54. * Attempts to delete the specified note id.
  55. */
  56. if (isset($_GET['delete_note'])) {
  57. if (ACP_RIGHTS > 2) {
  58. dbquery("DELETE FROM web_acp_notes WHERE id = '" . $_GET['delete_note'] . "'");
  59. add_log(ACP_NAME, USER_IP, "Deleted a note.");
  60. acp_success("Successfully deleted note.");
  61. } else {
  62. acp_error("Moderators cannot delete notes.");
  63. }
  64. }
  65. /**
  66. * Check if access denied error has redirected the user to this page.
  67. */
  68. if (isset($_GET['access_denied'])) {
  69. acp_error("You do not have permissions to view that page.");
  70. }
  71. ?>
  72. <h1>Dashboard</h1><hr>
  73. <p>Welcome to the administration backend. You can find tools for managing the game, server, website, and all the configurations. Depending on your given priviledges, you will only be able to access certain controls within the administration.</p><br />
  74. <?php if (is_int($core->get_config("remote.port"))) {
  75. echo "fail";
  76. } ?>
  77. <h2>Server statistics</h2>
  78. <table cellspacing="1">
  79. <col class="col1" /><col class="col2" /><col class="col1" /><col class="col2" />
  80. <thead>
  81. <tr>
  82. <th>Statistic</th>
  83. <th>Value</th>
  84. <th>Statistic</th>
  85. <th>Value</th>
  86. </tr>
  87. </thead>
  88. <tbody>
  89. <tr>
  90. <td>Registered users: </td>
  91. <td><strong><?php echo $stat['user_count']; ?></strong></td>
  92. <td>Server version: </td>
  93. <td><strong><?php echo $stat['server_version']; ?></strong></td>
  94. </tr>
  95. <tr>
  96. <td>Inactiveusers: </td>
  97. <td><strong><?php echo $stat['inactive_users']; ?></strong></td>
  98. <td>Website version: </td>
  99. <td><strong><?php echo $stat['website_version']; ?></strong></td>
  100. </tr>
  101. <tr>
  102. <td>Users online: </td>
  103. <td><strong><?php echo $stat['users_online']; ?></strong></td>
  104. <td>Database version: </td>
  105. <td><strong><?php echo $stat['database_version']; ?></strong></td>
  106. </tr>
  107. <tr>
  108. <td>Staff members: </td>
  109. <td><strong><?php echo $stat['staff_members']; ?></strong></td>
  110. <td>Client version: </td>
  111. <td><strong><?php echo $stat['client_version']; ?></strong></td>
  112. </tr>
  113. <tr>
  114. <td>Last startup: </td>
  115. <td><strong><?php echo $stat['last_startup']; ?></strong></td>
  116. <td>Database version: </td>
  117. <td><strong><?php echo "MySQL " . $stat['mysql_version']; ?></strong></td>
  118. </tr>
  119. <tr>
  120. <td>Worlds: </td>
  121. <td><strong><?php echo $stat['world_count']; ?></strong></td>
  122. <td>Database size: </td>
  123. <td><strong><?php echo $db_size; ?></strong></td>
  124. </tr>
  125. </tbody>
  126. </table>
  127. <br />
  128. <h2>Administration Notes</h2>
  129. <p>Notes and general chatting between staff can be done with this.</p>
  130. <div style="float: right;"><a href="adminnotes.php?viewall">&raquo; View administration notes</a></div>
  131. <table cellspacing="1">
  132. <thead>
  133. <tr>
  134. <th>Username</th>
  135. <th>Date</th>
  136. <th>Message</th>
  137. </tr>
  138. </thead>
  139. <tbody>
  140. <?php
  141. $notes = dbquery("SELECT * FROM web_acp_notes ORDER BY id DESC LIMIT 10");
  142. $notebool = true;
  143. if (mysql_num_rows($notes) > 0) {
  144. while ($note = mysql_fetch_assoc($notes)) {
  145. echo "
  146. <tr>
  147. <td><a href='dashboard.php?delete_note=" . $note['id'] . "'><img src='./images/icon_delete.gif' /></a> <a href='viewuser.php?name=" . $note['user'] . "'><strong>" . $users->format_name($note['user']) . "</strong></a></td>
  148. <td style='text-align: center;'>" . $note['note_date'] . "</td>
  149. <td>" . filter_for_outout($note['note_message'], true) . "</td>
  150. </tr>
  151. ";
  152. $notebool = !$notebool;
  153. }
  154. } else {
  155. echo "<tr><td colspan='5' style='text-align: center;'>No notes have been created.</td></tr>";
  156. }
  157. ?>
  158. <tr>
  159. <form method="get" action="dashboard.php">
  160. <td colspan='5' style='text-align: center;'>
  161. <input id="note" name="add_note" size="50"/>
  162. <input class="button1" type="submit" id="submit" value="Post Note" />
  163. </td>
  164. </form>
  165. </tr>
  166. </tbody>
  167. </table>
  168. <br />
  169. <h2>Administration Logs</h2>
  170. <p>This gives an overview of the last five actions carried out by staff.</p>
  171. <div style="float: right;"><a href="adminlogs.php?viewall">&raquo; View administration logs</a></div>
  172. <table cellspacing="1">
  173. <thead>
  174. <tr>
  175. <th>Username</th>
  176. <th>User IP</th>
  177. <th>Time</th>
  178. <th>Action</th>
  179. </tr>
  180. </thead>
  181. <tbody>
  182. <?php
  183. $logs = dbquery("SELECT * FROM web_acp_logs ORDER BY id DESC LIMIT 5");
  184. if (mysql_num_rows($logs) > 0) {
  185. while ($log = mysql_fetch_assoc($logs)) {
  186. echo " <tr>
  187. <td><strong><a href='viewuser.php?name=" . $log['user'] . "'>" . $users->format_name($log['user']) ."</a></strong></td>
  188. <td style='text-align: center;'>" . $log['user_ip'] ."</td>
  189. <td style='text-align: center;'>" . $log['log_time'] ."</td>
  190. <td><strong>" . $log['log_message'] ."</strong></td>
  191. </tr>";
  192. }
  193. } else {
  194. echo "<tr><td colspan='5' style='text-align: center;'>No logs have been created.</td></tr>";
  195. }
  196. ?>
  197. </tbody>
  198. </table>
  199. <?php include_once("footer.php"); ?>