From: Stefan Schantl Date: Mon, 11 Aug 2025 17:39:01 +0000 (+0200) Subject: ids.cgi: Auto fill form inputs with their temporary stored values in X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=refs%2Fheads%2Fsuricata-8;p=people%2Fstevee%2Fipfire-2.x.git ids.cgi: Auto fill form inputs with their temporary stored values in 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 --- diff --git a/html/cgi-bin/ids.cgi b/html/cgi-bin/ids.cgi index fc3e58368..f5735947c 100644 --- a/html/cgi-bin/ids.cgi +++ b/html/cgi-bin/ids.cgi @@ -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 <