X-Git-Url: http://git.ipfire.org/?a=blobdiff_plain;f=html%2Fcgi-bin%2Fcountry.cgi;h=8df2427a9eb10d24fd43bd8c5ce1b36cceecb416;hb=00793c27c929b68a21c4ef07044fbbb68942a192;hp=76035fb46d76ad0c4775e300e8d4c975dcc2b36f;hpb=4ebd3831fab6949542f0d2a9d6e444c5f8619ad1;p=ipfire-2.x.git
diff --git a/html/cgi-bin/country.cgi b/html/cgi-bin/country.cgi
index 76035fb46d..8df2427a9e 100644
--- a/html/cgi-bin/country.cgi
+++ b/html/cgi-bin/country.cgi
@@ -21,16 +21,14 @@
use strict;
-use Locale::Country;
+use Locale::Codes::Country;
-my $flagdir = '/srv/web/ipfire/html/images/flags';
+my $col;
my $lines = '1';
my $lines2 = '';
-my @flaglist=();
-my @flaglistfiles=();
-my $flag = '';
require '/var/ipfire/general-functions.pl';
+require "${General::swroot}/geoip-functions.pl";
require "${General::swroot}/lang.pl";
require "${General::swroot}/header.pl";
@@ -40,40 +38,41 @@ require "${General::swroot}/header.pl";
&Header::openbigbox('100%', 'left');
&Header::openbox('100%', 'left', $Lang::tr{'country codes and flags'});
-print "
";
-print "$Lang::tr{'flag'} | ";
-print "$Lang::tr{'countrycode'} | ";
-print "$Lang::tr{'country'} | ";
-print " | ";
-print "$Lang::tr{'flag'} | ";
-print "$Lang::tr{'countrycode'} | ";
-print "$Lang::tr{'country'} |
";
-
-@flaglist = <$flagdir/*>;
-
-undef @flaglistfiles;
-
-foreach (@flaglist)
-{
- if (!-d) { push(@flaglistfiles,substr($_,rindex($_,"/")+1)); }
-}
-my $col="";
-foreach $flag (@flaglistfiles)
-{
+
+print<
+
+ $Lang::tr{'flag'} |
+ $Lang::tr{'countrycode'} |
+ $Lang::tr{'country'} |
+ |
+ $Lang::tr{'flag'} |
+ $Lang::tr{'countrycode'} |
+ $Lang::tr{'country'} |
+
+END
+
+# Get a list of all supported country codes.
+my @countries = Locale::Codes::Country::all_country_codes();
+
+# Loop through whole country list.
+foreach my $country (@countries) {
$lines++;
- my $flagcode = uc(substr($flag, 0, 2));
- my $fcode = lc($flagcode);
- my $country = Locale::Country::code2country($fcode);
- if($fcode eq 'eu') { $country = 'Europe'; }
- if($fcode eq 'tp') { $country = 'East Timor'; }
- if($fcode eq 'yu') { $country = 'Yugoslavia'; }
+ # Convert country code into upper case.
+ $country = uc($country);
+
+ # Get flag icon for of the country.
+ my $flag_icon = &GeoIP::get_flag_icon($country);
+
+ # Get country name.
+ my $name = &GeoIP::get_full_country_name($country);
+
if ($lines % 2) {
- print " | ";
- print "$flagcode | ";
- print "$country | \n";
- }
- else {
+ print " | ";
+ print "$country | ";
+ print "$name | \n";
+ } else {
$lines2++;
if($lines2 % 2) {
$col="style='background-color:${Header::table2colour};'";
@@ -81,25 +80,25 @@ foreach $flag (@flaglistfiles)
$col="style='background-color:${Header::table1colour};'";
}
print "";
- print " | ";
- print "$flagcode | ";
+ print " | ";
print "$country | ";
+ print "$name | ";
print " | ";
+
+ # Finish column when the last element in the array has passed and we have an uneven amount of items.
+ if ( $country eq $countries[-1] ) {
+ print " | \n";
+ print " | \n";
+ print " |
\n";
+ }
}
}
-
-
print "
";
&Header::closebox();
&Header::closebigbox();
-print <
-$Lang::tr{'back'}
-
-END
-;
+print "\n";
&Header::closepage();