X-Git-Url: http://git.ipfire.org/?p=ipfire-2.x.git;a=blobdiff_plain;f=html%2Fcgi-bin%2Fcountry.cgi;h=8df2427a9eb10d24fd43bd8c5ce1b36cceecb416;hp=db6c07496d6e6d8169c855d8be1d0d3dfa804358;hb=00793c27c929b68a21c4ef07044fbbb68942a192;hpb=534943c67516c9288962fdf86e2ba5d6fa969a69 diff --git a/html/cgi-bin/country.cgi b/html/cgi-bin/country.cgi index db6c07496d..8df2427a9e 100644 --- a/html/cgi-bin/country.cgi +++ b/html/cgi-bin/country.cgi @@ -21,90 +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)); } -} -my $col=""; -foreach $flag (@flaglistfiles) -{ - $lines++; + # 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); - 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 ""; - $col="bgcolor='${Header::table2colour}'"; + print ""; + print ""; + print "\n"; } else { + $lines2++; + if($lines2 % 2) { + $col="style='background-color:${Header::table2colour};'"; + } else { + $col="style='background-color:${Header::table1colour};'"; + } print ""; - $col="bgcolor='${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 "
FlagCode$Lang::tr{'country'} FlagCode$Lang::tr{'country'}
$flagcode"; - print "$flagcode$country
$country$country$name
$flagcode"; - print "$flagcode$country $country$country$name    
"; +print ""; &Header::closebox(); &Header::closebigbox(); -print < - - - - -
$Lang::tr{'back'}
- -END -; +print "
$Lang::tr{'back'}
\n"; &Header::closepage();