Account and permission manager and security log viewer. https://netsyms.biz/apps/managepanel
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

getlogtable.php 2.1KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. <?php
  2. /* This Source Code Form is subject to the terms of the Mozilla Public
  3. * License, v. 2.0. If a copy of the MPL was not distributed with this
  4. * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
  5. require __DIR__ . '/../required.php';
  6. dieifnotloggedin();
  7. header("Content-Type: application/json");
  8. $out = [];
  9. $out['draw'] = intval($VARS['draw']);
  10. $out['recordsTotal'] = $database->count('authlog');
  11. $filter = false;
  12. // sort
  13. $order = null;
  14. $sortby = "DESC";
  15. if ($VARS['order'][0]['dir'] == 'asc') {
  16. $sortby = "ASC";
  17. }
  18. switch ($VARS['order'][0]['column']) {
  19. case 1:
  20. $order = ["logtime" => $sortby];
  21. break;
  22. case 2:
  23. $order = ["typename" => $sortby];
  24. break;
  25. case 3:
  26. $order = ["username" => $sortby];
  27. break;
  28. case 4:
  29. $order = ["ip" => $sortby];
  30. break;
  31. case 5:
  32. $order = ["otherdata" => $sortby];
  33. break;
  34. }
  35. // search
  36. if (!empty($VARS['search']['value'])) {
  37. $filter = true;
  38. $wherenolimit = [
  39. "OR" => [
  40. "logtime[~]" => $VARS['search']['value'],
  41. "typename[~]" => $VARS['search']['value'],
  42. "username[~]" => $VARS['search']['value'],
  43. "ip[~]" => $VARS['search']['value'],
  44. "otherdata[~]" => $VARS['search']['value']
  45. ]
  46. ];
  47. $where = $wherenolimit;
  48. $where["LIMIT"] = [$VARS['start'], $VARS['length']];
  49. } else {
  50. $where = ["LIMIT" => [$VARS['start'], $VARS['length']]];
  51. }
  52. if (!is_null($order)) {
  53. $where["ORDER"] = $order;
  54. }
  55. $log = $database->select('authlog', [
  56. "[>]accounts" => ['uid' => 'uid'],
  57. "[>]logtypes" => ['logtype' => 'logtype']
  58. ], [
  59. 'logtime',
  60. 'typename',
  61. 'username',
  62. 'ip',
  63. 'otherdata'
  64. ], $where);
  65. $out['status'] = "OK";
  66. if ($filter) {
  67. $recordsFiltered = $database->count('authlog', [
  68. "[>]accounts" => ['uid' => 'uid'],
  69. "[>]logtypes" => ['logtype' => 'logtype']
  70. ], 'logid', $wherenolimit);
  71. } else {
  72. $recordsFiltered = $out['recordsTotal'];
  73. }
  74. $out['recordsFiltered'] = $recordsFiltered;
  75. $out['log'] = $log;
  76. echo json_encode($out);