watch_logger.php 5.2 KB

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