X-Git-Url: http://git.ipfire.org/?p=ipfire-2.x.git;a=blobdiff_plain;f=html%2Fcgi-bin%2Fcountry.cgi;h=8df2427a9eb10d24fd43bd8c5ce1b36cceecb416;hp=76035fb46d76ad0c4775e300e8d4c975dcc2b36f;hb=00793c27c929b68a21c4ef07044fbbb68942a192;hpb=e405fe9e3aa14116fe58aa0d9affb2bcf554214d 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 ""; -print ""; -print ""; -print ""; -print ""; -print ""; -print ""; - -@flaglist = <$flagdir/*>; - -undef @flaglistfiles; - -foreach (@flaglist) -{ - if (!-d) { push(@flaglistfiles,substr($_,rindex($_,"/")+1)); } -} -my $col=""; -foreach $flag (@flaglistfiles) -{ + +print< + + + + + + + + + +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 ""; - print "\n"; - } - else { + print ""; + print ""; + print "\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 ""; + print ""; print ""; + print ""; 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 "
$Lang::tr{'flag'}$Lang::tr{'countrycode'}$Lang::tr{'country'} $Lang::tr{'flag'}$Lang::tr{'countrycode'}$Lang::tr{'country'}
$Lang::tr{'flag'}$Lang::tr{'countrycode'}$Lang::tr{'country'} $Lang::tr{'flag'}$Lang::tr{'countrycode'}$Lang::tr{'country'}
$flagcode$flagcode$country
$country$country$name
$flagcode$flagcode$country$country$name    
"; &Header::closebox(); &Header::closebigbox(); -print < -$Lang::tr{'back'} - -END -; +print "
$Lang::tr{'back'}
\n"; &Header::closepage();