user_apply.php 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. <?php
  2. require_once ($_SERVER['DOCUMENT_ROOT']."/inc/auth.php");
  3. require_once ($_SERVER['DOCUMENT_ROOT']."/inc/languages/" . HTML_LANG . ".php");
  4. if (! defined("CONFIG")) die("Not defined");
  5. if (isset($_POST["ApplyForAll"])) {
  6. $auth_id = $_POST["fid"];
  7. if (empty($_POST["a_enabled"])) { $_POST["a_enabled"]=0; }
  8. if (empty($_POST["a_dhcp"])) { $_POST["a_dhcp"]=0; }
  9. if (empty($_POST["a_queue_id"])) { $_POST["a_queue_id"]=0; }
  10. if (empty($_POST["a_group_id"])) { $_POST["a_group_id"]=0; }
  11. if (empty($_POST["a_traf"])) { $_POST["a_traf"]=0; }
  12. if (empty($_POST["a_day_q"])) { $_POST["a_day_q"]=0; }
  13. if (empty($_POST["a_month_q"])) { $_POST["a_month_q"]=0; }
  14. if (empty($_POST["a_new_ou"])) { $_POST["a_new_ou"]=0; }
  15. $a_enabled = $_POST["a_enabled"] * 1;
  16. $a_dhcp = $_POST["a_dhcp"] * 1;
  17. $a_dhcp_acl = $_POST["a_dhcp_acl"];
  18. $a_queue = $_POST["a_queue_id"] * 1;
  19. $a_group = $_POST["a_group_id"] * 1;
  20. $a_traf = $_POST["a_traf"] * 1;
  21. $a_day = $_POST["a_day_q"] * 1;
  22. $a_month = $_POST["a_month_q"] * 1;
  23. $a_ou_id = $_POST["a_new_ou"] * 1;
  24. $msg="Massive User change!";
  25. LOG_WARNING($db_link,$msg);
  26. $all_ok=1;
  27. foreach ($auth_id as $key => $val) {
  28. if ($val) {
  29. unset($auth);
  30. unset($user);
  31. if (isset($_POST["e_enabled"])) { $auth['enabled'] = $a_enabled; $user['enabled'] = $a_enabled; }
  32. if (isset($_POST["e_group_id"])) { $auth['filter_group_id'] = $a_group; }
  33. if (isset($_POST["e_queue_id"])) { $auth['queue_id'] = $a_queue; }
  34. if (isset($_POST["e_dhcp"])) { $auth['dhcp'] = $a_dhcp; }
  35. if (isset($_POST["e_dhcp_acl"])) { $auth['dhcp_acl'] = $a_dhcp_acl; }
  36. if (isset($_POST["e_traf"])) { $auth['save_traf'] = $a_traf; }
  37. if (isset($_POST["e_day_q"])) { $user['day_quota'] = $a_day; }
  38. if (isset($_POST["e_month_q"])) { $user['month_quota'] = $a_month; }
  39. if (isset($_POST["e_new_ou"])) { $user['ou_id'] = $a_ou_id; $auth['ou_id'] = $a_ou_id; }
  40. $login = get_record($db_link,"User_list","id='$val'");
  41. $msg.=" For all ip user id: ".$val." login: ".$login['login']." set: ";
  42. $msg.= get_diff_rec($db_link,"User_list","id='$val'", $user, 1);
  43. $ret = update_record($db_link, "User_list", "id='" . $val . "'", $user);
  44. if (!$ret) { $all_ok = 0; }
  45. $auth_list = get_records_sql($db_link,"SELECT id FROM User_auth WHERE deleted=0 AND user_id=".$val);
  46. if (!empty($auth)) {
  47. foreach ($auth_list as $row) {
  48. if (empty($row)) { continue; }
  49. $ret = update_record($db_link, "User_auth", "id='" . $row["id"] . "'", $auth);
  50. if (!$ret) { $all_ok = 0; }
  51. }
  52. }
  53. }
  54. }
  55. if ($all_ok) { print "Success!"; } else { print "Fail!"; }
  56. }