Sfoglia il codice sorgente

added blocking of the group operations form at the start of processing

Roman Dmitriev 2 mesi fa
parent
commit
4a5778350b

+ 19 - 5
html/admin/iplist/index.php

@@ -96,9 +96,24 @@ $ip_list_filter = $ou_filter.$cidr_filter.$enabled_filter.$ip_list_type_filter.$
 print_ip_submenu($page_url);
 
 ?>
+
+<script>
+function blockForm(formId) {
+    const form = document.getElementById(formId);
+    if (!form) return;
+    // Меняем текст кнопки отправки
+    const submitBtn = form.querySelector('input[type="submit"], button[type="submit"]');
+    if (submitBtn) {
+        submitBtn.disabled = true;
+        submitBtn.value = '<?php print WEB_msg_processing; ?>';
+        submitBtn.textContent = '<?php print WEB_msg_processing; ?>';
+    }
+}
+</script>
+
 <div id="cont">
 <br>
-<form name="filter" action="index.php" method="post">
+<form id="filter" name="filter" action="index.php" method="post">
 <input type="hidden" name="ip-filter" value="<?php print $ip_list_filter; ?>">
 <input type="hidden" name="ip-sort" value="<?php print $sort_table.".".$sort_field." ".$order; ?>">
 <table>
@@ -145,7 +160,7 @@ print_ip_submenu($page_url);
 <div class="remodal" data-remodal-options="closeOnConfirm: true" data-remodal-id="modal" role="dialog" aria-labelledby="modal1Title" aria-describedby="modal1Desc">
  <div class="remodalBorder">
   <button data-remodal-action="close" class="remodal-close" aria-label="Close"></button>
-      <form id="formAuthApply">
+      <form id="formAuthApply" name="formAuthApply" onsubmit="blockForm('formAuthApply');">
         <h2 id="modal1Title"><?php print WEB_selection_title; ?></h2>
         <input type="hidden" name="ApplyForAll" value="MassChange">
         <table class="data" align=center>
@@ -169,7 +184,7 @@ print_ip_submenu($page_url);
 <div class="remodal" data-remodal-options="closeOnConfirm: true" data-remodal-id="modalDel" role="dialog" aria-labelledby="modal1Title" aria-describedby="modal1Desc">
  <div class="remodalBorder">
   <button data-remodal-action="close" class="remodal-close" aria-label="Close"></button>
-    <form id="formAuthDel">
+    <form id="formAuthDel" name="formAuthDel" onsubmit="blockForm('formAuthDel');">
         <h2 id="modal1Title"><?php print WEB_msg_delete_selected; ?></h2>
         <input type="hidden" name="RemoveAuth" value="MassChange">
         <?php print_qa_select('f_deleted', 0);?><br><br>
@@ -182,7 +197,7 @@ print_ip_submenu($page_url);
 <div class="remodal" data-remodal-options="closeOnConfirm: true" data-remodal-id="modalExport" role="dialog" aria-labelledby="modal1Title" aria-describedby="modal1Desc">
  <div class="remodalBorder">
   <button data-remodal-action="close" class="remodal-close" aria-label="Close"></button>
-    <form id="formAuthExport">
+    <form id="formAuthExport" name="formAuthExport" onsubmit="blockForm('formAuthExport');">
         <h2 id="modal1Title"><?php print WEB_selection_title; ?></h2>
         <input type="hidden" name="ExportAuth" value="MassChange">
         <?php print WEB_msg_export_selected."&nbsp"; print_qa_select('a_selected', 1);?>
@@ -351,7 +366,6 @@ document.getElementById('dynamic_enabled').addEventListener('change', function(e
   buttonApply.click();
 });
 
-
 </script>
 
 <?php

+ 16 - 2
html/admin/users/index.php

@@ -65,6 +65,20 @@ if ($msg_error) {
     }
 ?>
 
+<script>
+function blockForm(formId) {
+    const form = document.getElementById(formId);
+    if (!form) return;
+    // Меняем текст кнопки отправки
+    const submitBtn = form.querySelector('input[type="submit"], button[type="submit"]');
+    if (submitBtn) {
+        submitBtn.disabled = true;
+        submitBtn.value = '<?php print WEB_msg_processing; ?>';
+        submitBtn.textContent = '<?php print WEB_msg_processing; ?>';
+    }
+}
+</script>
+
 <form id="filter" name="filter" action="index.php" method="post">
 <div>
 <b><?php print WEB_cell_ou; ?> - </b>
@@ -83,7 +97,7 @@ if ($msg_error) {
 <div class="remodal" data-remodal-options="closeOnConfirm: true" data-remodal-id="modal" role="dialog" aria-labelledby="modal1Title" aria-describedby="modal1Desc">
  <div class="remodalBorder">
   <button data-remodal-action="close" class="remodal-close" aria-label="Close"></button>
-      <form id="formUserApply">
+      <form id="formUserApply" onsubmit="blockForm('formUserApply');">
         <h2 id="modal1Title"><?php print WEB_selection_title; ?></h2>
         <input type="hidden" name="ApplyForAll" value="MassChange">
         <table class="data" align=center>
@@ -107,7 +121,7 @@ if ($msg_error) {
 <div class="remodal" data-remodal-options="closeOnConfirm: true" data-remodal-id="modalDel" role="dialog" aria-labelledby="modal1Title" aria-describedby="modal1Desc">
  <div class="remodalBorder">
   <button data-remodal-action="close" class="remodal-close" aria-label="Close"></button>
-    <form id="formUserDel">
+    <form id="formUserDel" onsubmit="blockForm('formUserDel');">
         <h2 id="modal1Title"><?php print WEB_msg_delete_selected; ?></h2>
         <input type="hidden" name="RemoveUser" value="MassChange">
         <?php print_qa_select('f_deleted', 0);?><br><br>

+ 39 - 21
html/inc/common.php

@@ -1884,43 +1884,61 @@ function print_dhcp_option_set($db, $qa_name)
 function print_dhcp_acl_list($db, $qa_name, $value = '')
 {
     $dhcp_acl = get_records_sql($db,
-        "SELECT DISTINCT dhcp_acl FROM user_auth 
+        "SELECT DISTINCT dhcp_acl FROM user_auth
          WHERE dhcp_acl IS NOT NULL AND dhcp_acl != '' AND deleted = 0"
     );
-    
+
+    // Всегда добавляем 'hotspot-free'
+    $acl_values = ['hotspot-free'];
+
     if (!empty($dhcp_acl)) {
-        echo "<input list=\"dhcp_acl\" id=\"" . htmlspecialchars($qa_name) . "\" name=\"" . htmlspecialchars($qa_name) . "\" value=\"" . htmlspecialchars($value) . "\" />";
-        echo "<datalist id=\"dhcp_acl\">";
-        echo "<option value=\"\">";
-        
         foreach ($dhcp_acl as $acl) {
-            echo "<option value=\"" . htmlspecialchars($acl['dhcp_acl']) . "\">";
+            $val = trim($acl['dhcp_acl']);
+            if ($val !== '' && $val !== 'hotspot-free') {
+                $acl_values[] = $val;
+            }
         }
-        echo "</datalist>";
-    } else {
-        echo "<input type=\"text\" name=\"" . htmlspecialchars($qa_name) . "\" value=\"\" size=\"10\" />";
     }
+
+    echo "<input list=\"dhcp_acl\" id=\"" . htmlspecialchars($qa_name) . "\" name=\"" . htmlspecialchars($qa_name) . "\" value=\"" . htmlspecialchars($value) . "\" />";
+    echo "<datalist id=\"dhcp_acl\">";
+    echo "<option value=\"\">";
+
+    foreach ($acl_values as $acl) {
+        echo "<option value=\"" . htmlspecialchars($acl) . "\">";
+    }
+
+    echo "</datalist>";
 }
 
 function print_dhcp_option_set_list($db, $qa_name, $value = '')
 {
     $dhcp_option_sets = get_records_sql($db,
-        "SELECT DISTINCT dhcp_option_set FROM user_auth 
+        "SELECT DISTINCT dhcp_option_set FROM user_auth
          WHERE dhcp_option_set IS NOT NULL AND dhcp_option_set != '' AND deleted = 0"
     );
-    
+
+    // Всегда включаем 'hotspot-free'
+    $option_values = ['hotspot-free'];
+
     if (!empty($dhcp_option_sets)) {
-        echo "<input list=\"dhcp_option_set\" id=\"" . htmlspecialchars($qa_name) . "\" name=\"" . htmlspecialchars($qa_name) . "\" value=\"" . htmlspecialchars($value) . "\" />";
-        echo "<datalist id=\"dhcp_option_set\">";
-        echo "<option value=\"\">";
-        
-        foreach ($dhcp_option_sets as $dhcp_option_set) {
-            echo "<option value=\"" . htmlspecialchars($dhcp_option_set['dhcp_option_set']) . "\">";
+        foreach ($dhcp_option_sets as $row) {
+            $val = trim($row['dhcp_option_set']);
+            if ($val !== '' && $val !== 'hotspot-free') {
+                $option_values[] = $val;
+            }
         }
-        echo "</datalist>";
-    } else {
-        echo "<input type=\"text\" name=\"" . htmlspecialchars($qa_name) . "\" value=\"\" size=\"10\" />";
     }
+
+    echo "<input list=\"dhcp_option_set\" id=\"" . htmlspecialchars($qa_name) . "\" name=\"" . htmlspecialchars($qa_name) . "\" value=\"" . htmlspecialchars($value) . "\" />";
+    echo "<datalist id=\"dhcp_option_set\">";
+    echo "<option value=\"\">"; 
+
+    foreach ($option_values as $opt) {
+        echo "<option value=\"" . htmlspecialchars($opt) . "\">";
+    }
+
+    echo "</datalist>";
 }
 
 function print_enabled_select($qa_name, $qa_value)

+ 1 - 0
html/inc/languages/english.php

@@ -49,6 +49,7 @@ define("WEB_msg_login_hint","Please enter login");
 define("WEB_msg_password_hint","Please enter your password");
 define("WEB_msg_delete_selected","Delete selected?");
 define("WEB_msg_export_selected","Export only selected?");
+define("WEB_msg_processing","Processing...");
 
 /* SNMP */
 define("WEB_snmp_version","SNMP version");

+ 1 - 0
html/inc/languages/russian.php

@@ -49,6 +49,7 @@ define("WEB_msg_login_hint","Введите имя пользователя");
 define("WEB_msg_password_hint","Введите пароль");
 define("WEB_msg_delete_selected","Удалить выделенное?");
 define("WEB_msg_export_selected","Экспортировать только выделенное?");
+define("WEB_msg_processing","Идёт обработка...");
 
 /* SNMP */
 define("WEB_snmp_version","SNMP version");

+ 8 - 9
html/utils/auth_apply.php

@@ -6,6 +6,8 @@ if (!defined("CONFIG")) die("Not defined");
 
 $page_url = null;
 
+$all_ok = true;
+
 if (getPOST("ApplyForAll", $page_url)) {
 
     // Получаем массив ID авторизаций
@@ -26,7 +28,6 @@ if (getPOST("ApplyForAll", $page_url)) {
     $n_link = (int)getPOST("n_link", $page_url, 0);
     $n_handler = getPOST("n_handler", $page_url, '');
 
-    $all_ok = true;
 
     foreach ($auth_id as $val) {
         $id = (int)$val;
@@ -99,7 +100,7 @@ if (getPOST("ApplyForAll", $page_url)) {
                 if ($a_bind_mac) {
                     $user_rule = get_record_sql($db_link, "SELECT * FROM auth_rules WHERE user_id = ? AND rule_type = 2", [(int)$cur_auth['user_id']]);
                     $mac_rule = get_record_sql($db_link, "SELECT * FROM auth_rules WHERE rule = ? AND rule_type = 2", [$cur_auth['mac']]);
-                    
+
                     if (!$user_rule && !$mac_rule) {
                         $new_rule = [
                             'user_id' => (int)$cur_auth['user_id'],
@@ -124,7 +125,7 @@ if (getPOST("ApplyForAll", $page_url)) {
                 if ($a_bind_ip) {
                     $user_rule = get_record_sql($db_link, "SELECT * FROM auth_rules WHERE user_id = ? AND rule_type = 1", [(int)$cur_auth['user_id']]);
                     $ip_rule = get_record_sql($db_link, "SELECT * FROM auth_rules WHERE rule = ? AND rule_type = 1", [$cur_auth['ip']]);
-                    
+
                     if (!$user_rule && !$ip_rule) {
                         $new_rule = [
                             'user_id' => (int)$cur_auth['user_id'],
@@ -143,11 +144,9 @@ if (getPOST("ApplyForAll", $page_url)) {
             }
         }
     }
-
-    if ($all_ok) {
-        print "Success!";
-    } else {
-        print "Fail!";
-    }
 }
+
+$message = $all_ok ? "Success!" : "Fail!";
+print "<div style='padding:20px; font-size:18px; background:#e9f7ef; border:1px solid #2ecc71;'>$message</div>";
+
 ?>

+ 5 - 3
html/utils/auth_remove.php

@@ -9,9 +9,10 @@ $page_url = null;
 $remove_action = getPOST('RemoveAuth', $page_url, null);
 $f_deleted     = getPOST('f_deleted', $page_url, null);
 
+$all_ok = true;
+
 if ($remove_action !== null && $f_deleted !== '') {
     $auth_id = getPOST('fid', $page_url, []);
-    $all_ok = true;
 
     foreach ($auth_id as $val) {
         $id = (int)$val;
@@ -22,8 +23,9 @@ if ($remove_action !== null && $f_deleted !== '') {
             }
         }
     }
-
-    echo $all_ok ? 'Success!' : 'Fail!';
 }
 
+$message = $all_ok ? "Success!" : "Fail!";
+print "<div style='padding:20px; font-size:18px; background:#e9f7ef; border:1px solid #2ecc71;'>$message</div>";
+
 ?>

+ 5 - 2
html/utils/devices_apply.php

@@ -6,6 +6,8 @@ if (!defined("CONFIG")) die("Not defined");
 
 $page_url = null;
 
+$all_ok = true;
+
 if (getPOST("ApplyForAll", $page_url) !== null) {
 
     $dev_id = getPOST("fid", $page_url, []);
@@ -17,7 +19,6 @@ if (getPOST("ApplyForAll", $page_url) !== null) {
     $a_ro_community = trim(getPOST("a_ro_community", $page_url, 'public'));
     $a_rw_community = trim(getPOST("a_rw_community", $page_url, 'private'));
 
-    $all_ok = true;
 
     foreach ($dev_id as $val) {
         $id = (int)$val;
@@ -55,7 +56,9 @@ if (getPOST("ApplyForAll", $page_url) !== null) {
         }
     }
 
-    echo $all_ok ? "Success!" : "Fail!";
 }
 
+$message = $all_ok ? "Success!" : "Fail!";
+print "<div style='padding:20px; font-size:18px; background:#e9f7ef; border:1px solid #2ecc71;'>$message</div>";
+
 ?>

+ 5 - 2
html/utils/devices_remove.php

@@ -9,9 +9,10 @@ $page_url = null;
 $remove_action = getPOST('RemoveDevice', null, null);
 $f_deleted     = getPOST('f_deleted', null, null);
 
+$all_ok = true;
+
 if ($remove_action !== null && $f_deleted !== '') {
     $dev_ids = getPOST('fid', null, []);
-    $all_ok = true;
 
     foreach ($dev_ids as $val) {
         $id = (int)$val;
@@ -23,7 +24,9 @@ if ($remove_action !== null && $f_deleted !== '') {
         }
     }
 
-    echo $all_ok ? 'Success!' : 'Fail!';
 }
 
+$message = $all_ok ? "Success!" : "Fail!";
+print "<div style='padding:20px; font-size:18px; background:#e9f7ef; border:1px solid #2ecc71;'>$message</div>";
+
 ?>

+ 6 - 6
html/utils/user_apply.php

@@ -6,6 +6,8 @@ if (!defined("CONFIG")) die("Not defined");
 
 $page_url = null;
 
+$all_ok = true;
+
 if (getPOST("ApplyForAll", $page_url)) {
 
     // === Безопасное получение и приведение параметров через getPOST ===
@@ -26,7 +28,6 @@ if (getPOST("ApplyForAll", $page_url)) {
     $a_dhcp_acl = trim(getPOST("a_dhcp_acl", $page_url, ''));
     $a_dhcp_option_set = trim(getPOST("a_dhcp_option_set", $page_url, ''));
 
-    $all_ok = true;
 
     foreach ($auth_id as $user_id_raw) {
         $user_id = (int)$user_id_raw;
@@ -191,10 +192,9 @@ if (getPOST("ApplyForAll", $page_url)) {
         }
     }
 
-    if ($all_ok) {
-        print "Success!";
-    } else {
-        print "Fail!";
-    }
 }
+
+$message = $all_ok ? "Success!" : "Fail!";
+print "<div style='padding:20px; font-size:18px; background:#e9f7ef; border:1px solid #2ecc71;'>$message</div>";
+
 ?>

+ 6 - 5
html/utils/user_remove.php

@@ -6,16 +6,16 @@ if (!defined("CONFIG")) die("Not defined");
 
 $page_url = null;
 
-// Получаем массив fid только из POST (т.к. это форма удаления)
+// Получаем массив fid только из POST
 $fid = getPOST('fid', null, []); // возвращаем пустой массив по умолчанию
 
 // Проверяем наличие действия "RemoveUser" и флага f_deleted
 $remove_action = getPOST('RemoveUser', null, null);
 $f_deleted    = getPOST('f_deleted', null, null);
 
-if ($remove_action !== null && $f_deleted !== null && $f_deleted !== '') {
-    $all_ok = true;
+$all_ok = true;
 
+if ($remove_action !== null && $f_deleted !== null && $f_deleted !== '') {
     foreach ($fid as $val) {
         $id = (int)$val;
         if ($id > 0) {
@@ -25,8 +25,9 @@ if ($remove_action !== null && $f_deleted !== null && $f_deleted !== '') {
             }
         }
     }
-
-    echo $all_ok ? "Success!" : "Fail!";
 }
 
+$message = $all_ok ? "Success!" : "Fail!";
+print "<div style='padding:20px; font-size:18px; background:#e9f7ef; border:1px solid #2ecc71;'>$message</div>";
+
 ?>