watch_logger.php 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. <script type="text/javascript" src="js/modules/administration.js"></script>
  2. <?php
  3. /*
  4. *
  5. * OGP - Open Game Panel
  6. * Copyright (C) 2008 - 2017 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"] && !hasValue($_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. if( isset( $_POST['empty_logger'] ) )
  76. $db->empty_logger();
  77. if($logs)
  78. {
  79. foreach($logs as $log)
  80. {
  81. $user = $db->getUserById($log['user_id']);
  82. $when = $log['date'];
  83. $who = $user['users_login'];
  84. $where = $log['ip'];
  85. $what = $log['message'];
  86. $log_id = $log['log_id'];
  87. // Template
  88. echo "<tr class='maintr'>\n".
  89. "<td class='collapsible'>\n".
  90. "<center>\n".
  91. "<form method=POST>\n".
  92. "<input type='hidden' name='log_id' value='$log_id' />\n".
  93. "<input type='image' name='remove_log' onclick=\"this.form.submit();\" src='modules/administration/images/remove.gif' />\n".
  94. "</form>\n".
  95. "</center>\n".
  96. "</td>\n".
  97. "<td class='collapsible'>$when</td>\n".
  98. "<td class='collapsible'>$who</td>\n".
  99. "<td class='collapsible'>$where</td>\n".
  100. "<td class='collapsible'>$what</td>\n".
  101. "</tr>\n";
  102. echo "<tr class='expand-child'>\n".
  103. "<td colspan='5' >\n".
  104. "<table>\n";
  105. $show_values = array( "users_login", "users_lang", "users_role", "users_email", "user_expires");
  106. foreach($user as $key => $value)
  107. {
  108. if( in_array( $key, $show_values ) )
  109. echo "<tr><td>".str_replace("_", "", substr($key,5))."</td><td>$value</td></tr>\n";
  110. }
  111. echo "</tr>\n".
  112. "</td>\n".
  113. "</table>\n";
  114. }
  115. }
  116. echo "</tbody>\n";
  117. echo "<tfoot style='border:1px solid grey;'></tfoot>\n";
  118. echo "</table>\n";
  119. $count_logs = $db->get_logger_count($search_field);
  120. if (isset($_GET['search']) && !empty($_GET['search'])) {
  121. $uri = '?m=administration&p=watch_logger&search='.$_GET['search'].'&limit='.$l.'&page=';
  122. } else {
  123. $uri = '?m=administration&p=watch_logger&limit='.$l.'&page=';
  124. }
  125. echo paginationPages($count_logs[0]['total'], $p, $l, $uri, 3, 'watchLogger');
  126. }
  127. ?>