index.php 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. <?php
  2. require_once ($_SERVER['DOCUMENT_ROOT']."/inc/auth.php");
  3. require_once ($_SERVER['DOCUMENT_ROOT']."/inc/languages/" . HTML_LANG . ".php");
  4. // Удаление OU
  5. if (getPOST("remove") !== null) {
  6. $fid = getPOST("f_id", null, []);
  7. if (!empty($fid) && is_array($fid)) {
  8. foreach ($fid as $val) {
  9. $val = (int)$val;
  10. if ($val <= 0) continue;
  11. // Обнуляем привязки в user_list
  12. update_records($db_link, "user_list", "ou_id = ?", ['ou_id' => 0], [$val]);
  13. // Обнуляем привязки в user_auth
  14. update_records($db_link, "user_auth", "ou_id = ?", ['ou_id' => 0], [$val]);
  15. // Удаляем правила авторизации
  16. delete_records($db_link, "auth_rules", "ou_id = ?", [$val]);
  17. // Удаляем сам OU
  18. delete_record($db_link, "ou", "id = ?", [$val]);
  19. }
  20. }
  21. header("Location: " . $_SERVER["REQUEST_URI"]);
  22. exit;
  23. }
  24. // Создание нового OU
  25. if (getPOST("create") !== null) {
  26. $ou_name = trim(getPOST("new_ou", null, ''));
  27. if ($ou_name !== '') {
  28. insert_record($db_link, "ou", ['ou_name' => $ou_name]);
  29. }
  30. header("Location: " . $_SERVER["REQUEST_URI"]);
  31. exit;
  32. }
  33. unset($_POST);
  34. require_once ($_SERVER['DOCUMENT_ROOT']."/inc/header.php");
  35. ?>
  36. <div id="cont">
  37. <b><?php echo WEB_list_ou; ?></b><br>
  38. <form name="def" action="index.php" method="post">
  39. <table class="data">
  40. <tr align="center">
  41. <td><input type="checkbox" onClick="checkAll(this.checked);"></td>
  42. <td><b>Id</b></td>
  43. <td><b><?php echo WEB_cell_flags; ?></b></td>
  44. <td><b><?php echo WEB_cell_name; ?></b></td>
  45. <td><b><?php echo WEB_cell_dynamic; ?></b></td>
  46. <td>
  47. <input type="submit" onclick="return confirm('<?php echo WEB_msg_delete; ?>?')" name="remove" value="<?php echo WEB_btn_delete; ?>">
  48. </td>
  49. </tr>
  50. <?php
  51. $t_ou = get_records_sql($db_link,'SELECT * FROM ou ORDER BY ou_name');
  52. foreach ($t_ou as $row) {
  53. print "<tr align=center>\n";
  54. print "<td class=\"data\" style='padding:0'><input type=checkbox name=f_id[] value='{$row['id']}'></td>\n";
  55. print "<td class=\"data\"><input type=\"hidden\" name='r_id[]' value='{$row['id']}'>{$row['id']}</td>\n";
  56. $flag='';
  57. if ($row['default_users'] == 1) { $flag='D'; }
  58. if ($row['default_hotspot'] == 1) { $flag='H'; }
  59. print "<td class=\"data\">$flag</td>\n";
  60. print "<td class=\"data\">"; print_url($row['ou_name'],"/admin/groups/edit_group.php?id=".$row['id']); print "</td>\n";
  61. print_yes_no($row['dynamic'],'custom','data');
  62. print "<td class=\"data\"></td>\n";
  63. print "</tr>\n";
  64. }
  65. ?>
  66. </table>
  67. <div>
  68. <input type=text name=new_ou value="Unknown"></td>
  69. <input type="submit" name="create" value="<?php echo WEB_btn_add; ?>">
  70. </div>
  71. </form>
  72. <?php
  73. require_once ($_SERVER['DOCUMENT_ROOT']."/inc/footer.php");
  74. ?>