X-Git-Url: http://git.ipfire.org/?p=ipfire-2.x.git;a=blobdiff_plain;f=html%2Fcgi-bin%2Fcountry.cgi;h=8df2427a9eb10d24fd43bd8c5ce1b36cceecb416;hp=474d60cd06572f602a38a94f3089d4f13b21a409;hb=00793c27c929b68a21c4ef07044fbbb68942a192;hpb=95fb58a3d7d29084ebfc011eb753b200c42cc0c0 diff --git a/html/cgi-bin/country.cgi b/html/cgi-bin/country.cgi index 474d60cd06..8df2427a9e 100644 --- a/html/cgi-bin/country.cgi +++ b/html/cgi-bin/country.cgi @@ -21,89 +21,84 @@ 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"; &Header::showhttpheaders(); -&Header::openpage('Country Codes', 1, ''); -&Header::openbigbox('100%', 'LEFT'); +&Header::openpage($Lang::tr{'countries'}, 1, ''); +&Header::openbigbox('100%', 'left'); + +&Header::openbox('100%', 'left', $Lang::tr{'country codes and flags'}); + +print< + + $Lang::tr{'flag'} + $Lang::tr{'countrycode'} + $Lang::tr{'country'} +   + $Lang::tr{'flag'} + $Lang::tr{'countrycode'} + $Lang::tr{'country'} + +END -&Header::openbox('100%', 'LEFT', 'Flags & Country Codes:'); -print ""; -print ""; -print ""; -print ""; -print ""; -print ""; -print ""; -print ""; +# Get a list of all supported country codes. +my @countries = Locale::Codes::Country::all_country_codes(); -@flaglist = <$flagdir/*>; +# Loop through whole country list. +foreach my $country (@countries) { + $lines++; -undef @flaglistfiles; + # Convert country code into upper case. + $country = uc($country); -foreach (@flaglist) -{ - if (!-d) { push(@flaglistfiles,substr($_,rindex($_,"/")+1)); } -} + # Get flag icon for of the country. + my $flag_icon = &GeoIP::get_flag_icon($country); -foreach $flag (@flaglistfiles) -{ - $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'; } - if ($lines % 2) { - print ""; - print "\n"; - } - else { - $lines2++; - if($lines2 % 2) { - print ""; + # Get country name. + my $name = &GeoIP::get_full_country_name($country); + + if ($lines % 2) { + print ""; + print ""; + print "\n"; } else { - print ""; + $lines2++; + if($lines2 % 2) { + $col="style='background-color:${Header::table2colour};'"; + } else { + $col="style='background-color:${Header::table1colour};'"; + } + 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 ""; - print ""; - #print ""; - print ""; - } } - - -print "
FlagCodeCountry FlagCodeCountry
$flagcode"; - print "$flagcode$country
$country$country$name
$country$country$name    
$flagcode"; - print "$flagcode$country* 
"; +print ""; &Header::closebox(); &Header::closebigbox(); -print < - - - - -
$Lang::tr{'back'}
- -END -; +print "
$Lang::tr{'back'}
\n"; &Header::closepage();