PageRenderTime 51ms CodeModel.GetById 23ms RepoModel.GetById 1ms app.codeStats 0ms

/trunk/WebSource/jweb/admincp/adminnotes.php

#
PHP | 186 lines | 151 code | 18 blank | 17 comment | 27 complexity | 14c9aa84f711d10b03b62f3be50595b4 MD5 | raw file
Possible License(s): GPL-3.0
  1. <?php
  2. /*
  3. * jWeb
  4. * Copyright (C) 2010 Jolt Environment Team
  5. *
  6. * This program is free software: you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation, either version 3 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  18. */
  19. define('ACP_TITLE', 'Admin Notes');
  20. define('ACP_TAB', 1);
  21. require_once("adminglobal.php");
  22. check_rights();
  23. $show = 50;
  24. if (isset($_GET['page'])) {
  25. $page = $_GET['page'];
  26. } else {
  27. $page = 1;
  28. }
  29. if (isset($_GET['viewall'])) {
  30. $total_logs = dbevaluate("SELECT COUNT(id) FROM web_acp_notes;");
  31. $total_pages = ceil($total_logs / $show);
  32. $tmp_key = $_POST['key'];
  33. $sp = "<span>";
  34. for ($i = 1; $i <= $total_pages; $i++) {
  35. if ($i == $page) {
  36. $sp .= "<strong>$page</strong><span class='page-sep'>,</span>";
  37. } else {
  38. $sp .= "<a href='adminnotes.php?viewall&page=$i'>$i</a>";
  39. }
  40. }
  41. if ($page > $total_pages) {
  42. $page = 1;
  43. }
  44. $next_page = $page + 1;
  45. if ($next_page > $total_pages) {
  46. $next_page = $total_pages;
  47. }
  48. $sp .= "&nbsp;&nbsp;<a href='adminnotes.php?viewall&page=" . $next_page . "'>Next</a></span>";
  49. } else if (isset($_GET['key'])) {
  50. $key = $_GET['key'];
  51. $key = str_replace(' ', '_', strtolower(trim($key)));
  52. if ($key == "") {
  53. header("Location: adminlogs.php?viewall");
  54. }
  55. $total_logs = dbevaluate("SELECT COUNT(id) FROM web_acp_notes WHERE user = '$key';");
  56. $total_pages = ceil($total_logs / $show);
  57. $tmp_key = $_POST['key'];
  58. $sp = "<span>";
  59. for ($i = 1; $i <= $total_pages; $i++) {
  60. if ($i == $page) {
  61. $sp .= "<strong>$page</strong><span class='page-sep'>,</span>";
  62. } else {
  63. $sp .= "<a href='adminnotes.php?key=$key&page=$i'>$i</a>";
  64. }
  65. }
  66. $next_page = $page + 1;
  67. if ($next_page > $total_pages) {
  68. $next_page = $total_pages;
  69. }
  70. $sp .= "&nbsp;&nbsp;<a href='adminnotes.php?key=$key&page=" . $next_page . "'>Next</a></span>";
  71. }
  72. require_once("header.php");
  73. ?>
  74. <h1>Admin Logs</h1><hr>
  75. <p>Staff activity is always logged in the AdminCP. You can see all logged activity here.</p><br />
  76. <?php if (isset($_GET['viewall'])) { ?>
  77. <form method="get">
  78. <fieldset class="display-options" style="float: left">
  79. Search by name:
  80. <input type="text" name="key" value="" />&nbsp;
  81. <input type="submit" class="button2" value="Search" />
  82. </fieldset>
  83. </form>
  84. <div class="pagination" style="float: right; margin: 15px 0 2px 0">
  85. <?php echo "Page " . $page . " of " . $total_pages; ?>
  86. &bull;
  87. <?php echo $sp; ?>
  88. </div>
  89. <table cellspacing="1">
  90. <thead>
  91. <tr>
  92. <th>Username</th>
  93. <th>Date</th>
  94. <th>Message</th>
  95. </tr>
  96. </thead>
  97. <tbody>
  98. <?php
  99. $start_from = ($page - 1) * $show;
  100. $logs = dbquery("SELECT * FROM web_acp_notes ORDER BY id DESC LIMIT $start_from, $show");
  101. if (mysql_num_rows($logs) > 0) {
  102. while ($log = mysql_fetch_assoc($logs)) {
  103. echo "<tr>
  104. <td><a href='dashboard.php?delete_note=" . $note['id'] . "'><img src='./images/icon_delete.gif' /></a> " . $users->format_name($log['user']) . "</td>
  105. <td>" . $log['note_date'] . "</td>
  106. <td>" . filter_for_outout($log['note_message'], true) . "</td>
  107. </tr>";
  108. }
  109. } else {
  110. echo "<tr><td colspan='5' style='text-align: center;'>No logs found.</td></tr>";
  111. }
  112. ?>
  113. <form method="get" action="dashboard.php">
  114. <td colspan='5' style='text-align: center;'>
  115. <input id="note" name="add_note" size="50"/>
  116. <input class="button1" type="submit" id="submit" value="Post Note" />
  117. </td>
  118. </form>
  119. </tbody>
  120. </table>
  121. <?php } else if (isset($_GET['key'])) { ?>
  122. <form method="get">
  123. <fieldset class="display-options" style="float: left">
  124. Search by name:
  125. <input type="text" name="key" value="<?php echo $key ?>" />&nbsp;
  126. <input type="submit" class="button2" value="Search" />
  127. </fieldset>
  128. </form>
  129. <div class="pagination" style="float: right; margin: 15px 0 2px 0">
  130. <?php echo "Page " . $page . " of " . $total_pages; ?>
  131. &bull;
  132. <?php echo $sp; ?>
  133. </div>
  134. <table cellspacing="1">
  135. <thead>
  136. <tr>
  137. <th>Username</th>
  138. <th>User IP</th>
  139. <th>Time</th>
  140. <th>Action</th>
  141. </tr>
  142. </thead>
  143. <tbody>
  144. <?php
  145. $start_from = ($page - 1) * $show;
  146. $logs = dbquery("SELECT * FROM web_acp_notes WHERE user = '$key' ORDER BY id DESC LIMIT $start_from, $show");
  147. if (mysql_num_rows($logs) > 0) {
  148. while ($log = mysql_fetch_assoc($logs)) {
  149. echo "<tr>
  150. <td><a href='dashboard.php?delete_note=" . $note['id'] . "'><img src='./images/icon_delete.gif' /></a> " . $users->format_name($log['user']) . "</td>
  151. <td>" . $log['note_date'] . "</td>
  152. <td>" . filter_for_outout($log['note_message'], true) . "</td>
  153. </tr>";
  154. }
  155. } else {
  156. echo "<tr><td colspan='5' style='text-align: center;'>No logs found.</td></tr>";
  157. }
  158. ?>
  159. <form method="get" action="dashboard.php">
  160. <td colspan='5' style='text-align: center;'>
  161. <input id="note" name="add_note" size="50"/>
  162. <input class="button1" type="submit" id="submit" value="Post Note" />
  163. </td>
  164. </form>
  165. </tbody>
  166. </table>
  167. <?php } ?>
  168. <?php require_once("footer.php"); ?>