watch_logger.php 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. <script type="text/javascript" src="js/jquery/plugins/jquery.tablesorter.collapsible.js"></script>
  2. <script type="text/javascript" src="js/jquery/plugins/jquery.tablesorter.mod.js"></script>
  3. <script type="text/javascript" src="js/jquery/plugins/jquery.quicksearch.js"></script>
  4. <script type="text/javascript" src="js/modules/administration.js"></script>
  5. <?php
  6. /*
  7. *
  8. * OGP - Open Game Panel
  9. * Copyright (C) Copyright (C) 2008 - 2013 The OGP Development Team
  10. *
  11. * http://www.opengamepanel.org/
  12. *
  13. * This program is free software; you can redistribute it and/or
  14. * modify it under the terms of the GNU General Public License
  15. * as published by the Free Software Foundation; either version 2
  16. * of the License, or any later version.
  17. *
  18. * This program is distributed in the hope that it will be useful,
  19. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  20. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  21. * GNU General Public License for more details.
  22. *
  23. * You should have received a copy of the GNU General Public License
  24. * along with this program; if not, write to the Free Software
  25. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  26. *
  27. */
  28. function exec_ogp_module() {
  29. global $db;
  30. echo "<h2>".get_lang('watch_logger')."</h2>";
  31. ?>
  32. <!-- Search, Empty Logger, and Paging Options Table -->
  33. <table style="width: 100%;">
  34. <tr>
  35. <td style="width: 50%; vertical-align: middle; text-align: left;">
  36. <form onsubmit="event.preventDefault();" style="display: inline;">
  37. <b><?php print_lang('search'); ?>:</b>
  38. <input type="text" id="search">
  39. </form>
  40. <form method=POST style="display: inline;">
  41. <input type="submit" name="empty_logger" value="<?php print_lang('empty_logger'); ?>" >
  42. </form>
  43. </td>
  44. <td style="width: 50%; vertical-align: middle; text-align: right;">
  45. <?php echo print_lang('view'); ?> <a href='?m=administration&p=watch_logger&limit=10'>10</a> / <a href='?m=administration&p=watch_logger&limit=20'>20</a> / <a href='?m=administration&p=watch_logger&limit=50'>50</a> / <a href='?m=administration&p=watch_logger&limit=100'>100</a> <?php echo print_lang('per_page'); ?>
  46. </td>
  47. </tr>
  48. </table>
  49. <!-- END Search, Empty Logger, and Paging Options Table -->
  50. <table id="servermonitor" class="tablesorter">
  51. <thead>
  52. <tr>
  53. <th style="width:16px;background-position: center;"></th>
  54. <th><?php print_lang('when'); ?></th>
  55. <th><?php print_lang('who'); ?></th>
  56. <th><?php print_lang('where'); ?></th>
  57. <th><?php print_lang('what'); ?></th>
  58. </tr>
  59. </thead>
  60. <tbody>
  61. <?php
  62. if( isset( $_POST['log_id'] ) )
  63. $db->del_logger_log($_POST['log_id']);
  64. if( isset( $_POST['empty_logger'] ) )
  65. $db->empty_logger();
  66. $p = isset($_GET['page']) ? $_GET['page'] : 1;
  67. $l = isset($_GET['limit']) ? $_GET['limit'] : 10;
  68. $logs = $db->read_logger($p,$l);
  69. if($logs)
  70. {
  71. foreach($logs as $log)
  72. {
  73. $user = $db->getUserById($log['user_id']);
  74. $when = $log['date'];
  75. $who = $user['users_login'];
  76. $where = $log['ip'];
  77. $what = $log['message'];
  78. $log_id = $log['log_id'];
  79. // Template
  80. echo "<tr class='maintr'>\n".
  81. "<td class='collapsible'>\n".
  82. "<center>\n".
  83. "<form method=POST>\n".
  84. "<input type='hidden' name='log_id' value='$log_id' />\n".
  85. "<input type='image' name='remove_log' onclick=\"this.form.submit();\" src='modules/administration/images/remove.gif' />\n".
  86. "</form>\n".
  87. "</center>\n".
  88. "</td>\n".
  89. "<td class='collapsible'><span class='hidden' >$log_id</span><a></a>$when</td>\n".
  90. "<td class='collapsible'><a></a>$who</td>\n".
  91. "<td class='collapsible'><a></a>$where</td>\n".
  92. "<td class='collapsible'><a></a>$what</td>\n".
  93. "</tr>\n";
  94. echo "<tr class='expand-child'>\n".
  95. "<td colspan='5' >\n".
  96. "<table>\n";
  97. $show_values = array( "users_login", "users_lang", "users_role", "users_email", "user_expires");
  98. foreach($user as $key => $value)
  99. {
  100. if( in_array( $key, $show_values ) )
  101. echo "<tr><td>".str_replace("_", "", substr($key,5))."</td><td>$value</td></tr>\n";
  102. }
  103. echo "</tr>\n".
  104. "</td>\n".
  105. "</table>\n";
  106. }
  107. }
  108. echo "</tbody>\n";
  109. echo "<tfoot style='border:1px solid grey;'></tfoot>\n";
  110. echo "</table>\n";
  111. $count_logs = $db->get_logger_count();
  112. if($count_logs > $l)
  113. {
  114. $total_pages = $count_logs[0]['total'] / $l;
  115. $pagination = "";
  116. for($page=1; $page <= $total_pages+1; $page++)
  117. {
  118. if($page == $p){
  119. $pagination .= " <b>$page</b>,";
  120. }else{
  121. if(isset($_GET['limit'])){
  122. $limits = $_GET['limit'];
  123. $pagination .= "<a href='?m=administration&p=watch_logger&page=$page&limit=$limits'>$page</a>,";
  124. }else{
  125. $pagination .= " <a href='?m=administration&p=watch_logger&page=$page' >$page</a>,";
  126. }
  127. }
  128. }
  129. echo rtrim($pagination, ",");
  130. }
  131. }
  132. ?>