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.

getpermtable.php 2.1KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  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('assigned_permissions');
  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 2:
  20. $order = ["realname" => $sortby];
  21. break;
  22. case 3:
  23. $order = ["permcode" => $sortby];
  24. break;
  25. }
  26. // search
  27. if (!empty($VARS['search']['value'])) {
  28. $filter = true;
  29. $wherenolimit = [
  30. "OR" => [
  31. "username[~]" => $VARS['search']['value'],
  32. "realname[~]" => $VARS['search']['value'],
  33. "permcode[~]" => $VARS['search']['value']
  34. ]
  35. ];
  36. $where = $wherenolimit;
  37. $where["LIMIT"] = [$VARS['start'], $VARS['length']];
  38. } else {
  39. $where = ["LIMIT" => [$VARS['start'], $VARS['length']]];
  40. }
  41. if (!is_null($order)) {
  42. $where["ORDER"] = $order;
  43. }
  44. $data = $database->select('assigned_permissions', [
  45. "[>]accounts" => ['uid' => 'uid'],
  46. "[>]permissions" => ['permid' => 'permid']
  47. ], [
  48. 'username',
  49. 'realname',
  50. 'assigned_permissions.uid',
  51. 'permissions.permid',
  52. 'permcode'
  53. ], $where);
  54. $out['status'] = "OK";
  55. if ($filter) {
  56. $recordsFiltered = $database->count('assigned_permissions', [
  57. "[>]accounts" => ['uid' => 'uid'],
  58. "[>]permissions" => ['permid' => 'permid']
  59. ], 'assigned_permissions.uid', $wherenolimit);
  60. } else {
  61. $recordsFiltered = $out['recordsTotal'];
  62. }
  63. $out['recordsFiltered'] = $recordsFiltered;
  64. for ($i = 0; $i < count($data); $i++) {
  65. $data[$i]["delbtn"] = '<a class="btn btn-danger btn-xs" href="app.php?page=delpermission&uid=' . $data[$i]['uid'] . '&pid=' . $data[$i]['permid'] . '"><i class="fa fa-trash"></i> ' . $Strings->get("delete", false) . '</a>';
  66. }
  67. $out['perms'] = $data;
  68. echo json_encode($out);