From: Stefan Schantl Date: Fri, 14 Apr 2023 15:35:48 +0000 (+0200) Subject: ipblocklist-functions.pl: Add function to get all enabled blocklists X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=db651942127d91ee8b87e08f5c5b27722bd8d8be;p=people%2Fstevee%2Fipfire-2.x.git ipblocklist-functions.pl: Add function to get all enabled blocklists Signed-off-by: Stefan Schantl --- diff --git a/config/cfgroot/ipblocklist-functions.pl b/config/cfgroot/ipblocklist-functions.pl index a53018f11..943d3fd34 100644 --- a/config/cfgroot/ipblocklist-functions.pl +++ b/config/cfgroot/ipblocklist-functions.pl @@ -69,6 +69,32 @@ sub get_blocklists () { return sort(@blocklists); } +# +## Function to get all enabled blocklists. +# +sub get_enabled_blocklists () { + my @enabled_blocklists; + my %settings; + + # Get all available blocklists. + my @blocklists = &get_blocklists(); + + # Read-in blocklist settings. + &General::readhash($settings_file, \%settings) if (-e $settings_file); + + # Loop through the array of available blocklists. + foreach my $blocklist (@blocklists) { + # Check if the blocklist is enabled. + if ((exists($settings{$blocklist})) && ($settings{$blocklist} eq "on")) { + # Add the blocklist to the array of enabled blocklists. + push(@enabled_blocklists, $blocklist); + } + } + + # Return the array of enabled blocklists. + return @enabled_blocklists; +} + # ## Function to get the full path and name of the cached blocklist. #