logbrowser.php 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. <?php
  2. /**
  3. * Elgg log browser admin page
  4. *
  5. * @note The ElggObject this creates for each entry is temporary
  6. *
  7. * @package ElggLogBrowser
  8. */
  9. $limit = get_input('limit', 20);
  10. $offset = get_input('offset');
  11. $search_username = get_input('search_username');
  12. if ($search_username) {
  13. $user = get_user_by_username($search_username);
  14. if ($user) {
  15. $user_guid = $user->guid;
  16. } else {
  17. $user_guid = null;
  18. }
  19. } else {
  20. $user_guid = get_input('user_guid', null);
  21. if ($user_guid) {
  22. $user_guid = (int) $user_guid;
  23. $user = get_entity($user_guid);
  24. if ($user) {
  25. $search_username = $user->username;
  26. }
  27. } else {
  28. $user_guid = null;
  29. }
  30. }
  31. $timelower = get_input('timelower');
  32. if ($timelower) {
  33. $timelower = strtotime($timelower);
  34. }
  35. $timeupper = get_input('timeupper');
  36. if ($timeupper) {
  37. $timeupper = strtotime($timeupper);
  38. }
  39. $ip_address = get_input('ip_address');
  40. $refine = elgg_view('logbrowser/refine', array(
  41. 'timeupper' => $timeupper,
  42. 'timelower' => $timelower,
  43. 'ip_address' => $ip_address,
  44. 'username' => $search_username,
  45. ));
  46. // Get log entries
  47. $log = get_system_log($user_guid, "", "", "","", $limit, $offset, false, $timeupper, $timelower,
  48. 0, $ip_address);
  49. $count = get_system_log($user_guid, "", "", "","", $limit, $offset, true, $timeupper, $timelower,
  50. 0, $ip_address);
  51. // if user does not exist, we have no results
  52. if ($search_username && is_null($user_guid)) {
  53. $log = false;
  54. $count = 0;
  55. }
  56. $table = elgg_view('logbrowser/table', array('log_entries' => $log));
  57. $nav = elgg_view('navigation/pagination',array(
  58. 'offset' => $offset,
  59. 'count' => $count,
  60. 'limit' => $limit,
  61. ));
  62. // display admin body
  63. $body = <<<__HTML
  64. $refine
  65. $nav
  66. $table
  67. $nav
  68. __HTML;
  69. echo $body;