From 6117eb8fd47a44b8093cc460ed27df6ba9789af4 Mon Sep 17 00:00:00 2001 From: Stefan Schantl Date: Mon, 11 Aug 2025 19:39:01 +0200 Subject: [PATCH] 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 --- html/cgi-bin/ids.cgi | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) 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 < -- 2.47.2