mirror of
https://github.com/vincentmli/bpfire.git
synced 2026-04-11 03:25:54 +02:00
ids.cgi: Introduce and use get_provider_name() function.
This function is used to grab the name of a provider by the given handle. Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
This commit is contained in:
@@ -900,20 +900,10 @@ END
|
||||
|
||||
# Loop throgh the list of providers.
|
||||
foreach my $provider (@ruleset_providers) {
|
||||
my $option_string;
|
||||
|
||||
# Get the translation required string for the current provider.
|
||||
my $tr_string = $IDS::Ruleset::Providers{$provider}{'tr_string'};
|
||||
|
||||
# Check if a translation string is available in the language files.
|
||||
if ($Lang::tr{$tr_string}) {
|
||||
# Use the translated string from the language file.
|
||||
$option_string = $Lang::tr{$tr_string};
|
||||
} else {
|
||||
# Fallback and use the provider summary from the providers file.
|
||||
$option_string = $IDS::Ruleset::Providers{$provider}{'summary'};
|
||||
}
|
||||
# Call get_provider_name function to obtain the provider name.
|
||||
my $option_string = &get_provider_name($provider);
|
||||
|
||||
# Print option.
|
||||
print "<option value='$provider' $selected{'RULES'}{$provider}>$option_string</option>\n";
|
||||
}
|
||||
print <<END;
|
||||
@@ -1399,6 +1389,29 @@ sub read_enabled_disabled_sids_file($) {
|
||||
return %temphash;
|
||||
}
|
||||
|
||||
#
|
||||
## Function to get the provider name from the language file or providers file for a given handle.
|
||||
#
|
||||
sub get_provider_name($) {
|
||||
my ($handle) = @_;
|
||||
my $provider_name;
|
||||
|
||||
# Get the required translation string for the given provider handle.
|
||||
my $tr_string = $IDS::Ruleset::Providers{$handle}{'tr_string'};
|
||||
|
||||
# Check if the translation string is available in the language files.
|
||||
if ($Lang::tr{$tr_string}) {
|
||||
# Use the translated string from the language file.
|
||||
$provider_name = $Lang::tr{$tr_string};
|
||||
} else {
|
||||
# Fallback and use the provider summary from the providers file.
|
||||
$provider_name = $IDS::Ruleset::Providers{$handle}{'summary'};
|
||||
}
|
||||
|
||||
# Return the obtained provider name.
|
||||
return $provider_name;
|
||||
}
|
||||
|
||||
#
|
||||
## Private function to convert a given rulefile to a category name.
|
||||
## ( No file extension anymore and if the name contained a dot, it
|
||||
|
||||
Reference in New Issue
Block a user