user_apply.php 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  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"])) {
  8. $_POST["a_enabled"] = 0;
  9. }
  10. if (empty($_POST["a_dhcp"])) {
  11. $_POST["a_dhcp"] = 0;
  12. }
  13. if (empty($_POST["a_queue_id"])) {
  14. $_POST["a_queue_id"] = 0;
  15. }
  16. if (empty($_POST["a_group_id"])) {
  17. $_POST["a_group_id"] = 0;
  18. }
  19. if (empty($_POST["a_traf"])) {
  20. $_POST["a_traf"] = 0;
  21. }
  22. if (empty($_POST["a_day_q"])) {
  23. $_POST["a_day_q"] = 0;
  24. }
  25. if (empty($_POST["a_month_q"])) {
  26. $_POST["a_month_q"] = 0;
  27. }
  28. if (empty($_POST["a_new_ou"])) {
  29. $_POST["a_new_ou"] = 0;
  30. }
  31. $a_enabled = $_POST["a_enabled"] * 1;
  32. $a_dhcp = $_POST["a_dhcp"] * 1;
  33. $a_dhcp_acl = $_POST["a_dhcp_acl"];
  34. $a_queue = $_POST["a_queue_id"] * 1;
  35. $a_group = $_POST["a_group_id"] * 1;
  36. $a_traf = $_POST["a_traf"] * 1;
  37. $a_day = $_POST["a_day_q"] * 1;
  38. $a_month = $_POST["a_month_q"] * 1;
  39. $a_ou_id = $_POST["a_new_ou"] * 1;
  40. $msg = "Massive User change!";
  41. LOG_WARNING($db_link, $msg);
  42. $all_ok = 1;
  43. foreach ($auth_id as $key => $val) {
  44. if ($val) {
  45. unset($auth);
  46. unset($user);
  47. if (isset($_POST["e_enabled"])) {
  48. $auth['enabled'] = $a_enabled;
  49. $user['enabled'] = $a_enabled;
  50. }
  51. if (isset($_POST["e_group_id"])) {
  52. $auth['filter_group_id'] = $a_group;
  53. }
  54. if (isset($_POST["e_queue_id"])) {
  55. $auth['queue_id'] = $a_queue;
  56. }
  57. if (isset($_POST["e_dhcp"])) {
  58. $auth['dhcp'] = $a_dhcp;
  59. }
  60. if (isset($_POST["e_dhcp_acl"])) {
  61. $auth['dhcp_acl'] = $a_dhcp_acl;
  62. }
  63. if (isset($_POST["e_traf"])) {
  64. $auth['save_traf'] = $a_traf;
  65. }
  66. if (isset($_POST["e_day_q"])) {
  67. $user['day_quota'] = $a_day;
  68. }
  69. if (isset($_POST["e_month_q"])) {
  70. $user['month_quota'] = $a_month;
  71. }
  72. if (isset($_POST["e_new_ou"])) {
  73. $user['ou_id'] = $a_ou_id;
  74. $auth['ou_id'] = $a_ou_id;
  75. }
  76. $login = get_record($db_link, "User_list", "id='$val'");
  77. $msg .= " For all ip user id: " . $val . " login: " . $login['login'] . " set: ";
  78. $msg .= get_diff_rec($db_link, "User_list", "id='$val'", $user, 1);
  79. $ret = update_record($db_link, "User_list", "id='" . $val . "'", $user);
  80. if (!$ret) {
  81. $all_ok = 0;
  82. }
  83. $auth_list = get_records_sql($db_link, "SELECT id FROM User_auth WHERE deleted=0 AND user_id=" . $val);
  84. if (!empty($auth)) {
  85. foreach ($auth_list as $row) {
  86. if (empty($row)) {
  87. continue;
  88. }
  89. $ret = update_record($db_link, "User_auth", "id='" . $row["id"] . "'", $auth);
  90. if (!$ret) {
  91. $all_ok = 0;
  92. }
  93. }
  94. }
  95. }
  96. }
  97. if ($all_ok) {
  98. print "Success!";
  99. } else {
  100. print "Fail!";
  101. }
  102. }