edit_rules.php 3.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  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. $msg_error = "";
  6. $sSQL = "SELECT * FROM User_list WHERE id=$id";
  7. $auth_info = get_record_sql($db_link, $sSQL);
  8. if (isset($_POST["s_remove"])) {
  9. $s_id = $_POST["s_id"];
  10. foreach ($s_id as $key => $val) {
  11. if (isset($val)) {
  12. LOG_INFO($db_link, "Remove rule id: $val ".dump_record($db_link,'auth_rules','id='.$val));
  13. delete_record($db_link, "auth_rules", "id=" . $val);
  14. }
  15. }
  16. header("Location: " . $_SERVER["REQUEST_URI"]);
  17. exit;
  18. }
  19. if (isset($_POST['s_save'])) {
  20. $len = is_array($_POST['s_save']) ? count($_POST['s_save']) : 0;
  21. for ($i = 0; $i < $len; $i ++) {
  22. $save_id = intval($_POST['s_save'][$i]);
  23. $len_all = is_array($_POST['n_id']) ? count($_POST['n_id']) : 0;
  24. for ($j = 0; $j < $len_all; $j ++) {
  25. if (intval($_POST['n_id'][$j]) != $save_id) { continue; }
  26. $new['type'] = $_POST['s_type'][$j]*1;
  27. $new['rule'] = trim($_POST['s_rule'][$j]);
  28. if ($new['type'] ==2) {
  29. $new['rule'] = mac_dotted($new['rule']);
  30. }
  31. update_auth_rule($db_link,$new['rule'],$new['type'],$save_id);
  32. }
  33. }
  34. header("Location: " . $_SERVER["REQUEST_URI"]);
  35. exit;
  36. }
  37. if (isset($_POST["s_create"])) {
  38. $new_rule = $_POST["s_new_rule"];
  39. if (isset($new_rule)) {
  40. add_auth_rule($db_link,$new_rule,$_POST["s_new_type"],$id);
  41. }
  42. header("Location: " . $_SERVER["REQUEST_URI"]);
  43. exit;
  44. }
  45. unset($_POST);
  46. fix_auth_rules($db_link);
  47. require_once ($_SERVER['DOCUMENT_ROOT']."/inc/header.php");
  48. ?>
  49. <div id="cont">
  50. <br>
  51. <form name="def" action="edit_rules.php?id=<?php echo $id; ?>" method="post">
  52. <b><?php print WEB_ou_rules_for_autoassigning."&nbsp"; print_url($auth_info['login'],"/admin/users/edituser.php?id=$id"); ?></b>
  53. <br>
  54. <?php echo WEB_ou_rules_order; ?>: hotspot => subnet => mac => hostname => default user
  55. <br><br>
  56. <table class="data">
  57. <tr align="center">
  58. <td></td>
  59. <td width=30><b>id</b></td>
  60. <td><b><?php echo WEB_cell_type; ?></b></td>
  61. <td><b><?php echo WEB_ou_rule; ?></b></td>
  62. <td><input type="submit" onclick="return confirm('<?php echo WEB_msg_delete; ?>?')" name="s_remove" value="<?php echo WEB_btn_delete; ?>"></td>
  63. </tr>
  64. <?php
  65. $t_auth_rules = get_records($db_link,'auth_rules',"user_id=$id ORDER BY id");
  66. foreach ( $t_auth_rules as $row ) {
  67. print "<tr align=center>\n";
  68. print "<td class=\"data\" style='padding:0'><input type=checkbox name=s_id[] value='{$row['id']}'></td>\n";
  69. print "<td class=\"data\"><input type=\"hidden\" name='n_id[]' value='{$row['id']}'>{$row['id']}</td>\n";
  70. print "<td class=\"data\">"; print_qa_rule_select("s_type[]","{$row['type']}"); print "</td>\n";
  71. print "<td class=\"data\"><input type=\"text\" name='s_rule[]' value='{$row['rule']}'></td>\n";
  72. print "<td class=\"data\"><button name='s_save[]' value='{$row['id']}'>".WEB_btn_save."</button></td>\n";
  73. print "</tr>\n";
  74. }
  75. ?>
  76. </table>
  77. <div>
  78. <?php print WEB_ou_new_rule."&nbsp"; print_qa_rule_select("s_new_type","1");
  79. print "<input type=\"text\" name='s_new_rule' value=''>"; ?>
  80. <input type="submit" name="s_create" value="<?php echo WEB_btn_add; ?>">
  81. </div>
  82. </form>
  83. <?php
  84. require_once ($_SERVER['DOCUMENT_ROOT']."/inc/footer.php");
  85. ?>