functions.pl: add missing sub routine for wireguard.cgi

wireguard.cgi calls errorbox and opensection/closesection,
but they are missing from header.pl. ipfire had functons.pl
removed and moved subroutines to header.pl and added errorbox
in header.pl. to keep the change minimum so not affect other
features, add errorbox and opensection/closesection in functions.pl

Signed-off-by: Vincent Li <vincent.mc.li@gmail.com>
This commit is contained in:
Vincent Li
2025-07-04 17:10:17 +00:00
parent 67d1b8a4e9
commit a3f7758510

View File

@@ -265,3 +265,41 @@ sub openbox {
sub closebox {
print "</div>";
}
sub errorbox($) {
my @errors = grep { $_ ne "" } @_;
# Do nothing if there are no errors
return unless (@errors);
# Open a new box
&openbox('100%', 'left', "Oops something went wrong");
# Print all error messages
print "<ul>\n";
foreach my $error (@errors) {
print "<li>$error</li>\n";
}
print "</ul>\n";
# Close the box again
&closebox();
}
# Sections
sub opensection($) {
my $title = shift;
# Open the section
print "<section class=\"section\">";
# Show the title if set
if ($title) {
print " <h2 class=\"title\">${title}</h2>\n";
}
}
sub closesection() {
print "</section>";
}