X-Git-Url: http://git.ipfire.org/?p=people%2Fpmueller%2Fipfire-2.x.git;a=blobdiff_plain;f=html%2Fcgi-bin%2Fcountry.cgi;h=8df2427a9eb10d24fd43bd8c5ce1b36cceecb416;hp=65ce154337f9f5f635005aa7b1e21cb90acf36a3;hb=08cf4d21540c4fe185db1f17ae365f7ab6adae27;hpb=851a984121f4a20d646de229c7901258fe5605d2 diff --git a/html/cgi-bin/country.cgi b/html/cgi-bin/country.cgi index 65ce154337..8df2427a9e 100644 --- a/html/cgi-bin/country.cgi +++ b/html/cgi-bin/country.cgi @@ -23,14 +23,12 @@ use strict; 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();