edit_group.php 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. <?php
  2. require_once ($_SERVER['DOCUMENT_ROOT']."/inc/auth.php");
  3. require_once ($_SERVER['DOCUMENT_ROOT']."/inc/languages/" . HTML_LANG . ".php");
  4. require_once ($_SERVER["DOCUMENT_ROOT"]."/inc/idfilter.php");
  5. if (isset($_POST['save'])) {
  6. $new['ou_name'] = $_POST['f_group_name'];
  7. $new['default_users'] = $_POST['f_default']*1;
  8. $new['default_hotspot'] = $_POST['f_default_hotspot']*1;
  9. $new['nagios_dir'] = $_POST['f_nagios'];
  10. $new['nagios_host_use'] = $_POST['f_nagios_host'];
  11. $new['nagios_ping'] = $_POST['f_nagios_ping'];
  12. $new['nagios_default_service'] = $_POST['f_nagios_service'];
  13. $new['queue_id']= $_POST['f_queue_id']*1;
  14. $new['filter_group_id']= $_POST['f_filter_group_id']*1;
  15. $new['enabled']= $_POST['f_enabled']*1;
  16. if ($new['default_users'] == TRUE) { run_sql($db_link,"UPDATE OU set default_users=0 WHERE id!='{$id}'"); }
  17. if ($new['default_hotspot'] == TRUE) { run_sql($db_link,"UPDATE OU set default_hotspot=0 WHERE id!='{$id}'"); }
  18. update_record($db_link, "OU", "id='{$id}'", $new);
  19. header("Location: " . $_SERVER["REQUEST_URI"]);
  20. exit;
  21. }
  22. if (isset($_POST["s_remove"])) {
  23. $s_id = $_POST["s_id"];
  24. foreach ($s_id as $key => $val) {
  25. if (isset($val)) {
  26. LOG_INFO($db_link, "Remove rule id: $val ".dump_record($db_link,'auth_rules','id='.$val));
  27. delete_record($db_link, "auth_rules", "id=" . $val);
  28. }
  29. }
  30. header("Location: " . $_SERVER["REQUEST_URI"]);
  31. exit;
  32. }
  33. if (isset($_POST['s_save'])) {
  34. $len = is_array($_POST['s_save']) ? count($_POST['s_save']) : 0;
  35. for ($i = 0; $i < $len; $i ++) {
  36. $save_id = intval($_POST['s_save'][$i]);
  37. $len_all = is_array($_POST['n_id']) ? count($_POST['n_id']) : 0;
  38. for ($j = 0; $j < $len_all; $j ++) {
  39. if (intval($_POST['n_id'][$j]) != $save_id) { continue; }
  40. $new['type'] = $_POST['s_type'][$j];
  41. $new['rule'] = trim($_POST['s_rule'][$j]);
  42. $new['comment'] = trim($_POST['s_comment'][$j]);
  43. update_record($db_link, "auth_rules", "id='{$save_id}'", $new);
  44. }
  45. }
  46. header("Location: " . $_SERVER["REQUEST_URI"]);
  47. exit;
  48. }
  49. if (isset($_POST["s_create"])) {
  50. $new_rule = $_POST["s_new_rule"];
  51. if (!empty($new_rule)) {
  52. $new['type'] = $_POST["s_new_type"];
  53. $new['rule'] = $new_rule;
  54. $new['ou_id'] = $id;
  55. LOG_INFO($db_link, "Create new rule $new_rule for ou_id: $id");
  56. insert_record($db_link, "auth_rules", $new);
  57. }
  58. header("Location: " . $_SERVER["REQUEST_URI"]);
  59. exit;
  60. }
  61. require_once ($_SERVER['DOCUMENT_ROOT']."/inc/header.php");
  62. fix_auth_rules($db_link);
  63. ?>
  64. <div id="cont">
  65. <form name="def" action="edit_group.php?id=<?php echo $id; ?>" method="post">
  66. <input type="hidden" name="id" value=<?php echo $id; ?>>
  67. <table class="data">
  68. <tr align="center">
  69. <td colspan=2><b><?php echo WEB_cell_name; ?></b></td>
  70. <td><b>Default</b></td>
  71. <td><b>Hotspot</b></td>
  72. </tr>
  73. <?php
  74. $ou_info = get_record_sql($db_link,'SELECT * FROM OU WHERE id='.$id);
  75. print "<tr align=center>\n";
  76. print "<td colspan=2 class=\"data\"><input type=\"text\" name='f_group_name' value='{$ou_info['ou_name']}' style=\"width:95%;\"></td>\n";
  77. if ($ou_info['default_users']) { $cl = "up"; } else { $cl="data"; }
  78. print "<td class=\"$cl\">"; print_qa_select("f_default",$ou_info['default_users']); print "</td>\n";
  79. if ($ou_info['default_hotspot']) { $cl = "up"; } else { $cl="data"; }
  80. print "<td class=\"$cl\">"; print_qa_select("f_default_hotspot",$ou_info['default_hotspot']); print "</td>\n";
  81. ?>
  82. <tr>
  83. <td><b>Nagios directory</b></td>
  84. <td><b>Host template</b></td>
  85. <td><b>Ping</b></td>
  86. <td><b>Host service</b></td>
  87. </tr>
  88. <?php
  89. print "<td class=\"data\"><input type=\"text\" name='f_nagios' value='{$ou_info['nagios_dir']}'></td>\n";
  90. print "<td class=\"data\"><input type=\"text\" name='f_nagios_host' value='{$ou_info['nagios_host_use']}'></td>\n";
  91. print "<td class=\"data\">"; print_qa_select("f_nagios_ping",$ou_info['nagios_ping']); print "</td>\n";
  92. print "<td class=\"data\"><input type=\"text\" name='f_nagios_service' value='{$ou_info['nagios_default_service']}'></td>\n";
  93. ?>
  94. </tr>
  95. <tr><td colspan=4><?php echo WEB_ou_autoclient_rules; ?></td></tr>
  96. <tr>
  97. <td class="data"><?php print WEB_cell_filter."&nbsp"; print_group_select($db_link, 'f_filter_group_id', $ou_info['filter_group_id']); ?></td>
  98. <td class="data"><?php print WEB_cell_shaper."&nbsp"; print_queue_select($db_link, 'f_queue_id', $ou_info['queue_id']); ?></td>
  99. <td class="data"><?php print WEB_cell_enabled."&nbsp"; print_qa_select('f_enabled', $ou_info['enabled']); ?></td>
  100. <?php print "<td align=right class=\"data\"><button name='save' value='{$ou_info['id']}'>".WEB_btn_save."</button></td>\n"; ?>
  101. </tr>
  102. </table>
  103. <br>
  104. <b><?php echo WEB_ou_rules_for_autoassigning."&nbsp"; print $ou_info['ou_name']; ?></b>
  105. <br>
  106. <?php echo WEB_ou_rules_order; ?>: hotspot => subnet => mac => hostname => default user
  107. <br><br>
  108. <table class="data">
  109. <tr align="center">
  110. <td></td>
  111. <td width=30><b>id</b></td>
  112. <td><b><?php echo WEB_cell_type; ?></b></td>
  113. <td><b><?php echo WEB_ou_rule; ?></b></td>
  114. <td><b><?php echo WEB_cell_comment; ?></b></td>
  115. <td><input type="submit" onclick="return confirm('<?php echo WEB_msg_delete; ?>?')" name="s_remove" value="<?php echo WEB_btn_delete; ?>"></td>
  116. </tr>
  117. <?php
  118. $t_auth_rules = get_records($db_link,'auth_rules',"ou_id=$id ORDER BY id");
  119. foreach ( $t_auth_rules as $row ) {
  120. print "<tr align=center>\n";
  121. print "<td class=\"data\" style='padding:0'><input type=checkbox name=s_id[] value='{$row['id']}'></td>\n";
  122. print "<td class=\"data\"><input type=\"hidden\" name='n_id[]' value='{$row['id']}'>{$row['id']}</td>\n";
  123. print "<td class=\"data\">"; print_qa_rule_select("s_type[]","{$row['type']}"); print "</td>\n";
  124. print "<td class=\"data\"><input type=\"text\" name='s_rule[]' value='{$row['rule']}'></td>\n";
  125. print "<td class=\"data\"><input type=\"text\" name='s_comment[]' value='{$row['comment']}'></td>\n";
  126. print "<td class=\"data\"><button name='s_save[]' value='{$row['id']}'>".WEB_btn_save."</button></td>\n";
  127. print "</tr>\n";
  128. }
  129. ?>
  130. </table>
  131. <div>
  132. <?php print WEB_ou_new_rule."&nbsp"; print_qa_rule_select("s_new_type","1");
  133. print "<input type=\"text\" name='s_new_rule' value=''>"; ?>
  134. <input type="submit" name="s_create" value="<?php echo WEB_btn_add; ?>">
  135. </div>
  136. </form>
  137. <?php require_once ($_SERVER['DOCUMENT_ROOT']."/inc/footer.php"); ?>