watch_logger.php 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  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 onsubmit="event.preventDefault();" style="display: inline;">
  34. <b><?php print_lang('search'); ?>:</b>
  35. <input type="text" id="search">
  36. </form>
  37. <form method=POST style="display: inline;">
  38. <input type="submit" name="empty_logger" value="<?php print_lang('empty_logger'); ?>" >
  39. </form>
  40. </td>
  41. <td style="width: 50%; vertical-align: middle; text-align: right;">
  42. <?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'); ?>
  43. </td>
  44. </tr>
  45. </table>
  46. <!-- END Search, Empty Logger, and Paging Options Table -->
  47. <table id="servermonitor" class="tablesorter" data-sortlist="[[1,1]]">
  48. <thead>
  49. <tr>
  50. <th style="width:16px;background-position: center;" class="sorter-false"></th>
  51. <th class="dateFormat-ddmmyyyy"><?php print_lang('when'); ?></th>
  52. <th><?php print_lang('who'); ?></th>
  53. <th><?php print_lang('where'); ?></th>
  54. <th><?php print_lang('what'); ?></th>
  55. </tr>
  56. </thead>
  57. <tbody>
  58. <?php
  59. if( isset( $_POST['log_id'] ) )
  60. $db->del_logger_log($_POST['log_id']);
  61. if( isset( $_POST['empty_logger'] ) )
  62. $db->empty_logger();
  63. $p = (isset($_GET['page']) && (int)$_GET['page'] > 0) ? (int)$_GET['page'] : 1;
  64. $l = (isset($_GET['limit']) && (int)$_GET['limit'] > 0) ? (int)$_GET['limit'] : 10;
  65. if(hasValue($loggedInUserInfo) && is_array($loggedInUserInfo) && $loggedInUserInfo["users_page_limit"] && !hasValue($_GET['limit'])){
  66. $l = $loggedInUserInfo["users_page_limit"];
  67. }
  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'>$when</td>\n".
  90. "<td class='collapsible'>$who</td>\n".
  91. "<td class='collapsible'>$where</td>\n".
  92. "<td class='collapsible'>$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. $uri = '?m=administration&p=watch_logger&limit='.$l.'&page=';
  113. echo paginationPages($count_logs[0]['total'], $p, $l, $uri, 3, 'watchLogger');
  114. }
  115. ?>