Просмотр исходного кода

fix algoritm autorules for user

Roman Dmitriev 2 лет назад
Родитель
Сommit
854e5bc64e
1 измененных файлов с 12 добавлено и 14 удалено
  1. 12 14
      html/utils/user_apply.php

+ 12 - 14
html/utils/user_apply.php

@@ -114,25 +114,23 @@ if (isset($_POST["ApplyForAll"])) {
             }
 
             //bind mac rule
-            if (isset($_POST["e_bind_mac"]) and !empty($b_mac)) {
-                if ($a_bind_mac) {
+            if (isset($_POST["e_bind_mac"])) {
+                if ($a_bind_mac and !empty($b_mac)) {
                     $auth_rules_user = get_record_sql($db_link, "SELECT * FROM auth_rules WHERE user_id=" . $val . " AND type=2");
                     $auth_rules_mac = get_record_sql($db_link, "SELECT * FROM auth_rules WHERE rule='" . $b_mac . "' AND type=2");
                     if (empty($auth_rules_user) and empty($auth_rules_mac)) {
-                        $new['user_id'] = $val;
-                        $new['type'] = 2;
-                        $new['rule'] = $b_mac;
-                        insert_record($db_link, "auth_rules", $new);
-                        LOG_INFO($db_link, "Created auto rule for user_id: " . $val . " and mac " . $b_mac);
+                            $new['user_id'] = $val;
+                            $new['type'] = 2;
+                            $new['rule'] = $b_mac;
+                            insert_record($db_link, "auth_rules", $new);
+                            LOG_INFO($db_link, "Created auto rule for user_id: " . $val . " and mac " . $b_mac);
+                        } else {
+                            LOG_INFO($db_link, "Auto rule for user_id: " . $val . " and mac " . $mac . " already exists");
+                        }
                     } else {
-                        LOG_INFO($db_link, "Auto rule for user_id: " . $val . " and mac " . $mac . " already exists");
-                    }
-                } else {
-                    run_sql($db_link, "DELETE FROM auth_rules WHERE user_id=" . $val . " AND type=2");
-                    LOG_INFO($db_link, "Remove auto rule for user_id: " . $val . " and mac " . $b_mac);
+                        run_sql($db_link, "DELETE FROM auth_rules WHERE user_id=" . $val . " AND type=2");
+                        LOG_INFO($db_link, "Remove auto rule for user_id: " . $val . " and mac " . $b_mac);
                 }
-            } else {
-                LOG_ERROR($db_link, "Auto rule for user_id: " . $first_auth['user_id'] . " not created. Record not found or empty mac.");
             }
         }
     }