From: Stefan Schantl Date: Thu, 24 Mar 2022 20:17:08 +0000 (+0100) Subject: ids-functions.pl: Add get_subscription_code() function. X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=235e3e92a32a95339c177a94371b22c4bc0877a6;p=people%2Fstevee%2Fipfire-2.x.git ids-functions.pl: Add get_subscription_code() function. This function can be used to obtain the subscription code of a given configured provider. Signed-off-by: Stefan Schantl --- diff --git a/config/cfgroot/ids-functions.pl b/config/cfgroot/ids-functions.pl index 61aecc250b..6819d78793 100644 --- a/config/cfgroot/ids-functions.pl +++ b/config/cfgroot/ids-functions.pl @@ -1607,6 +1607,34 @@ END close(FILE); } +# +## Function to get the subscription code of a configured provider. +# +sub get_subscription_code($) { + my ($provider) = @_; + + my %configured_providers = (); + + # Read-in providers settings file. + &General::readhasharray($providers_settings_file, \%configured_providers); + + # Loop through the hash of configured providers. + foreach my $id (keys %configured_providers) { + # Assign nice human-readable values to the data fields. + my $provider_handle = $configured_providers{$id}[0]; + my $subscription_code = $configured_providers{$id}[1]; + + # Check if the current processed provider is the requested one. + if ($provider_handle eq $provider) { + # Return the obtained subscription code. + return $subscription_code; + } + } + + # No subscription code found - return nothing. + return; +} + # ## Function to get the ruleset date for a given provider. ##