]> git.ipfire.org Git - ipfire-2.x.git/commitdiff
dnsbl.cgi: Minor code cleanup
authorMichael Tremer <michael.tremer@ipfire.org>
Wed, 28 Jan 2026 12:18:24 +0000 (13:18 +0100)
committerMichael Tremer <michael.tremer@ipfire.org>
Fri, 6 Mar 2026 14:04:26 +0000 (14:04 +0000)
No functional changes.

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
html/cgi-bin/dnsbl.cgi

index 8f2b10611bf3c731b6f9af2a940a13db44ec8805..503038da933c48eb4a6c63c3a5c0f0fd9927794d 100644 (file)
@@ -61,7 +61,7 @@ my @network_zones = &Network::get_available_network_zones();
 
 # Get the available filter categories.
 #
-# Open the JSON file. 
+# Open the JSON file.
 open(DNSBL, $dnsbl_json_file);
 
 # Read-in the dnsbl.json file content and append the lines to a string.
@@ -123,7 +123,7 @@ if ($cgiparams{'ACTION'} eq "$Lang::tr{'save'}") {
                my $enabled_zone_lc = lc($enabled_zone);
 
                # Check if the zone is known.
-               if( ! grep(/$enabled_zone_lc/, @network_zones) ) {
+               unless (grep(/$enabled_zone_lc/, @network_zones)) {
                        # Display error message about unknown network zone.
                        $errormessage = "$enabled_zone - $Lang::tr{'unknown network zone'}.";
                }
@@ -134,8 +134,8 @@ if ($cgiparams{'ACTION'} eq "$Lang::tr{'save'}") {
                next unless($address);
 
                if ((!&Network::check_ip_address($address)) && (!&Network::check_subnet($address))) {
-                        $errormessage = "$address - $Lang::tr{'guardian invalid address or subnet'}";
-                }
+                       $errormessage = "$address - $Lang::tr{'guardian invalid address or subnet'}";
+               }
        }
 
        # Only go further, if there was no error message.
@@ -196,8 +196,7 @@ if ($cgiparams{'ACTION'} eq "$Lang::tr{'save'}") {
                $errormessage = "$dup - $Lang::tr{'dnsbl error domain specified twice'}";
        }
 
-       # Check for valid domains.
-       #
+       # Check for valid domains
        unless ($errormessage) {
                # Loop through the arrays and check for valid domains and duplicates.
                foreach my $domain (@merged) {
@@ -211,9 +210,9 @@ if ($cgiparams{'ACTION'} eq "$Lang::tr{'save'}") {
                }
        }
 
+       # Check if a domain from the posted blocked domains array is allready part of
+       # the saved allowed domains array.
        unless ($errormessage) {
-               # Check if a domain from the posted blocked domains array is allready part of the saved allowed domains
-               # array.
                $dup = &compare_arrays(\@custom_allowed_domains, \@cgi_blocked_domains);
 
                if ($dup) {
@@ -221,9 +220,9 @@ if ($cgiparams{'ACTION'} eq "$Lang::tr{'save'}") {
                }
        }
 
+       # Check if a domain from the posted allowed domains array is allready part of
+       # the saved blocked domains array.
        unless ($errormessage) {
-               # Check if a domain from the posted allowed domains array is allready part of the saved blocked domains
-               # array.
                $dup = &compare_arrays(\@custom_blocked_domains, \@cgi_allowed_domains);
 
                if ($dup) {
@@ -467,7 +466,7 @@ sub readsettings {
        %$hash = ();
 
        open(FILE, $filename) or die "Unable to read file $filename";
-       
+
        while (<FILE>) {
                my ($key, $rest, @temp);
                chomp;
@@ -521,8 +520,6 @@ sub check_for_duplicates (@) {
                # Store last processed element.
                $lastelement = $element;
        }
-
-       return;
 }
 
 sub compare_arrays (\@\@) {
@@ -535,14 +532,11 @@ sub compare_arrays (\@\@) {
        return unless (@data);
        return unless (@test);
 
-
        # Loop through the content of the test array and check
        # if the current processed element is part of the data array.
        foreach my $element (@test) {
                if (grep(/$element/, @data)) {
-                       return "$element"
+                       return "$element";
                }
        }
-
-       return;
 }