[05/11] tor.cgi: Use own location functions.

Message ID 20200922182509.18643-5-stefan.schantl@ipfire.org
State Accepted
Commit 8b4525732624aba0fccb506088167d5c1441ab2e
Headers
Series [01/11] location-functions.pl: Refactor get_locations() function to use the Location module. |

Commit Message

Stefan Schantl Sept. 22, 2020, 6:25 p.m. UTC
  Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
---
 html/cgi-bin/tor.cgi | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)
  

Patch

diff --git a/html/cgi-bin/tor.cgi b/html/cgi-bin/tor.cgi
index c9416be01..28dec6cf0 100644
--- a/html/cgi-bin/tor.cgi
+++ b/html/cgi-bin/tor.cgi
@@ -20,7 +20,6 @@ 
 ###############################################################################
 
 use strict;
-use Locale::Codes::Country;
 
 # enable only the following on debugging purpose
 #use warnings;
@@ -31,6 +30,9 @@  require "${General::swroot}/location-functions.pl";
 require "${General::swroot}/lang.pl";
 require "${General::swroot}/header.pl";
 
+# Init libloc database connection.
+my $db_handle = &Location::Functions::init();
+
 #workaround to suppress a warning when a variable is used only once
 my @dummy = ( ${Header::colouryellow} );
 undef (@dummy);
@@ -321,10 +323,14 @@  END
 						<option value=''>- $Lang::tr{'tor exit country any'} -</option>
 END
 
-		my @country_names = Locale::Codes::Country::all_country_names();
-		foreach my $country_name (sort @country_names) {
-			my $country_code = Locale::Codes::Country::country2code($country_name);
+		my @country_codes = &Location::database_countries();
+		foreach my $country_code (@country_codes) {
+			# Convert country code into upper case format.
 			$country_code = uc($country_code);
+
+			# Get country name.
+			my $country_name = &Location::Functions::get_country_name($country_code);
+
 			print "<option value='$country_code'";
 
 			if ($settings{'TOR_EXIT_COUNTRY'} eq $country_code) {