]> git.ipfire.org Git - people/stevee/ipfire-2.x.git/commitdiff
ids.cgi: Auto fill form inputs with their temporary stored values in suricata-8
authorStefan Schantl <stefan.schantl@ipfire.org>
Mon, 11 Aug 2025 17:39:01 +0000 (19:39 +0200)
committerStefan Schantl <stefan.schantl@ipfire.org>
Mon, 11 Aug 2025 17:39:01 +0000 (19:39 +0200)
error case

If an user provides any invalid input in the form an error message will be
displayed. In this case, all the form elements (inputs) will be filled
with their temporary stored values from the cgiparams hash.

Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
html/cgi-bin/ids.cgi

index fc3e583682b9dc5998fffac564efbf0b4e0c3bad..f5735947c9b99e23d78a9ad8b0ff508aeb10a785 100644 (file)
@@ -1047,6 +1047,22 @@ sub show_mainpage() {
        $checked{'ENABLE_REPORT_MONTHLY'}{'on'} = '';
        $checked{'ENABLE_REPORT_MONTHLY'}{$idssettings{'ENABLE_REPORT_MONTHLY'}} = "checked='checked'";
 
+       # Set E-Mail settings from settings hash.
+       my $email_sender = $idssettings{'EMAIL_SENDER'};
+       my $email_recipients = $idssettings{'EMAIL_RECIPIENTS'};
+
+       # Set form values to cgiparams state in error case.
+       if ($errormessage) {
+               $checked{'ENABLE_IDS'}{$cgiparams{'ENABLE_IDS'}} = "checked='checked'";
+               $checked{'ENABLE_EMAIL'}{$cgiparams{'ENABLE_EMAIL'}} = "checked='checked'";
+               $checked{'ENABLE_REPORT_DAILY'}{$cgiparams{'ENABLE_REPORT_DAILY'}} = "checked='checked'";
+               $checked{'ENABLE_REPORT_WEEKLY'}{$cgiparams{'ENABLE_REPORT_WEEKLY'}} = "checked='checked'";
+               $checked{'ENABLE_REPORT_MONTHLY'}{$cgiparams{'ENABLE_REPORT_MONTHLY'}} = "checked='checked'";
+
+               $email_sender = $cgiparams{'EMAIL_SENDER'};
+               $email_recipients = $cgiparams{'EMAIL_RECIPIENTS'};
+       }
+
        # Draw current state of the IDS
        &Header::opensection();
 
@@ -1105,6 +1121,11 @@ END
                                $checked_input = "checked = 'checked'";
                        }
 
+                       # Set the checkbox status to the cgiparams state in error case.
+                       if ($errormessage) {
+                               $checked_input = "checked = 'checked'" if ($cgiparams{"ENABLE_IDS_$zone_upper"} eq "on");
+                       }
+
                        print <<END;
                                <tr>
                                        <td>