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) Copyright (C) 2008 - 2013 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. <b><?php print_lang('search'); ?>:</b>
  35. <input type ="hidden" name="m" value="administration" />
  36. <input type ="hidden" name="p" value="watch_logger" />
  37. <input name="search" type="text" id="search">
  38. <input type="submit" value="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" data-sortlist="[[1,1]]">
  51. <thead>
  52. <tr>
  53. <th style="width:16px;background-position: center;" class="sorter-false"></th>
  54. <th class="dateFormat-ddmmyyyy"><?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. $search_field = (isset($_GET['search']) && !empty($_GET['search'])) ? $_GET['search'] : false;
  67. $p = (isset($_GET['page']) && (int)$_GET['page'] > 0) ? (int)$_GET['page'] : 1;
  68. $l = (isset($_GET['limit']) && (int)$_GET['limit'] > 0) ? (int)$_GET['limit'] : 10;
  69. if(hasValue($loggedInUserInfo) && is_array($loggedInUserInfo) && $loggedInUserInfo["users_page_limit"] && !hasValue($_GET['limit'])){
  70. $l = $loggedInUserInfo["users_page_limit"];
  71. }
  72. $logs = $db->read_logger($p,$l,$search_field);
  73. if($logs)
  74. {
  75. foreach($logs as $log)
  76. {
  77. $user = $db->getUserById($log['user_id']);
  78. $when = $log['date'];
  79. $who = $user['users_login'];
  80. $where = $log['ip'];
  81. $what = $log['message'];
  82. $log_id = $log['log_id'];
  83. // Template
  84. echo "<tr class='maintr'>\n".
  85. "<td class='collapsible'>\n".
  86. "<center>\n".
  87. "<form method=POST>\n".
  88. "<input type='hidden' name='log_id' value='$log_id' />\n".
  89. "<input type='image' name='remove_log' onclick=\"this.form.submit();\" src='modules/administration/images/remove.gif' />\n".
  90. "</form>\n".
  91. "</center>\n".
  92. "</td>\n".
  93. "<td class='collapsible'>$when</td>\n".
  94. "<td class='collapsible'>$who</td>\n".
  95. "<td class='collapsible'>$where</td>\n".
  96. "<td class='collapsible'>$what</td>\n".
  97. "</tr>\n";
  98. echo "<tr class='expand-child'>\n".
  99. "<td colspan='5' >\n".
  100. "<table>\n";
  101. $show_values = array( "users_login", "users_lang", "users_role", "users_email", "user_expires");
  102. foreach($user as $key => $value)
  103. {
  104. if( in_array( $key, $show_values ) )
  105. echo "<tr><td>".str_replace("_", "", substr($key,5))."</td><td>$value</td></tr>\n";
  106. }
  107. echo "</tr>\n".
  108. "</td>\n".
  109. "</table>\n";
  110. }
  111. }
  112. echo "</tbody>\n";
  113. echo "<tfoot style='border:1px solid grey;'></tfoot>\n";
  114. echo "</table>\n";
  115. $count_logs = $db->get_logger_count($search_field);
  116. if(isset($_GET['search']) && !empty($_GET['search'])){
  117. $uri = '?m=administration&p=watch_logger&search='.$_GET['search'].'&limit='.$l.'&page=';
  118. }
  119. else{
  120. $uri = '?m=administration&p=watch_logger&limit='.$l.'&page=';
  121. }
  122. echo paginationPages($count_logs[0]['total'], $p, $l, $uri, 3, 'watchLogger');
  123. }
  124. ?>