watch_logger.php 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  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, $loggedInUserInfo;
  27. echo "<h2>".get_lang('watch_logger')."</h2>";
  28. ?>
  29. <!-- Search, Empty Logger, and Paging Options Table -->
  30. <table style="width: 100%;">
  31. <tr>
  32. <td style="width: 50%; vertical-align: middle; text-align: left;">
  33. <form action="home.php" method="GET" style="display: inline;">
  34. <input type ="hidden" name="m" value="administration" />
  35. <input type ="hidden" name="p" value="watch_logger" />
  36. <input name="search" type="text" id="search">
  37. <input type="submit" value="<?php echo get_lang('search'); ?>" />
  38. </form>
  39. <form method=POST style="display: inline;">
  40. <input type="submit" name="empty_logger" value="<?php print_lang('empty_logger'); ?>" >
  41. </form>
  42. </td>
  43. <td style="width: 50%; vertical-align: middle; text-align: right;">
  44. <?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'); ?>
  45. </td>
  46. </tr>
  47. </table>
  48. <!-- END Search, Empty Logger, and Paging Options Table -->
  49. <table id="servermonitor" class="tablesorter" data-sortlist="[[1,1]]">
  50. <thead>
  51. <tr>
  52. <th style="width:16px;background-position: center;" class="sorter-false"></th>
  53. <th class="dateFormat-ddmmyyyy"><?php print_lang('when'); ?></th>
  54. <th><?php print_lang('who'); ?></th>
  55. <th><?php print_lang('where'); ?></th>
  56. <th><?php print_lang('what'); ?></th>
  57. </tr>
  58. </thead>
  59. <tbody>
  60. <?php
  61. if( isset( $_POST['log_id'] ) )
  62. $db->del_logger_log($_POST['log_id']);
  63. if( isset( $_POST['empty_logger'] ) )
  64. $db->empty_logger();
  65. $search_field = (isset($_GET['search']) && !empty($_GET['search'])) ? $_GET['search'] : false;
  66. $p = (isset($_GET['page']) && (int)$_GET['page'] > 0) ? (int)$_GET['page'] : 1;
  67. $l = (isset($_GET['limit']) && (int)$_GET['limit'] > 0) ? (int)$_GET['limit'] : 10;
  68. if(hasValue($loggedInUserInfo) && is_array($loggedInUserInfo) && $loggedInUserInfo["users_page_limit"] && !hasValue($_GET['limit'])){
  69. $l = $loggedInUserInfo["users_page_limit"];
  70. }
  71. $logs = $db->read_logger($p,$l,$search_field);
  72. if($logs)
  73. {
  74. foreach($logs as $log)
  75. {
  76. $user = $db->getUserById($log['user_id']);
  77. $when = $log['date'];
  78. $who = $user['users_login'];
  79. $where = $log['ip'];
  80. $what = $log['message'];
  81. $log_id = $log['log_id'];
  82. // Template
  83. echo "<tr class='maintr'>\n".
  84. "<td class='collapsible'>\n".
  85. "<center>\n".
  86. "<form method=POST>\n".
  87. "<input type='hidden' name='log_id' value='$log_id' />\n".
  88. "<input type='image' name='remove_log' onclick=\"this.form.submit();\" src='modules/administration/images/remove.gif' />\n".
  89. "</form>\n".
  90. "</center>\n".
  91. "</td>\n".
  92. "<td class='collapsible'>$when</td>\n".
  93. "<td class='collapsible'>$who</td>\n".
  94. "<td class='collapsible'>$where</td>\n".
  95. "<td class='collapsible'>$what</td>\n".
  96. "</tr>\n";
  97. echo "<tr class='expand-child'>\n".
  98. "<td colspan='5' >\n".
  99. "<table>\n";
  100. $show_values = array( "users_login", "users_lang", "users_role", "users_email", "user_expires");
  101. foreach($user as $key => $value)
  102. {
  103. if( in_array( $key, $show_values ) )
  104. echo "<tr><td>".str_replace("_", "", substr($key,5))."</td><td>$value</td></tr>\n";
  105. }
  106. echo "</tr>\n".
  107. "</td>\n".
  108. "</table>\n";
  109. }
  110. }
  111. echo "</tbody>\n";
  112. echo "<tfoot style='border:1px solid grey;'></tfoot>\n";
  113. echo "</table>\n";
  114. $count_logs = $db->get_logger_count($search_field);
  115. if(isset($_GET['search']) && !empty($_GET['search'])){
  116. $uri = '?m=administration&p=watch_logger&search='.$_GET['search'].'&limit='.$l.'&page=';
  117. }
  118. else{
  119. $uri = '?m=administration&p=watch_logger&limit='.$l.'&page=';
  120. }
  121. echo paginationPages($count_logs[0]['total'], $p, $l, $uri, 3, 'watchLogger');
  122. }
  123. ?>