]> git.ipfire.org Git - people/pmueller/ipfire-2.x.git/blobdiff - html/cgi-bin/country.cgi
suricata: Change midstream policy to "pass-flow"
[people/pmueller/ipfire-2.x.git] / html / cgi-bin / country.cgi
index 76035fb46d76ad0c4775e300e8d4c975dcc2b36f..30111dc21757439db90c73126d40884c8e5fb093 100644 (file)
 
 use strict;
 
-use Locale::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}/location-functions.pl";
 require "${General::swroot}/lang.pl";
 require "${General::swroot}/header.pl";
 
+require "${General::swroot}/location-functions.pl";
+
 &Header::showhttpheaders();
 
 &Header::openpage($Lang::tr{'countries'}, 1, '');
 &Header::openbigbox('100%', 'left');
 
 &Header::openbox('100%', 'left', $Lang::tr{'country codes and flags'});
-print "<table class='tbl'>";
-print "<tr><th style='width=5%;'><b>$Lang::tr{'flag'}</b></th>";
-print "<th style='width=5%;'><b>$Lang::tr{'countrycode'}</b></th>";
-print "<th style='width=40%; text-align:left;'><b>$Lang::tr{'country'}</b></th>";
-print "<th>&nbsp;</th>";
-print "<th style='width=5%;'><b>$Lang::tr{'flag'}</b></th>";
-print "<th style='width=5%;'><b>$Lang::tr{'countrycode'}</b></th>";
-print "<th style='width=40%; text-align:left;'><b>$Lang::tr{'country'}</b></th></tr>";
-
-@flaglist = <$flagdir/*>;
-
-undef @flaglistfiles;
-
-foreach (@flaglist)
-{
-       if (!-d) { push(@flaglistfiles,substr($_,rindex($_,"/")+1));    }
-}
-my $col="";
-foreach $flag (@flaglistfiles)
-{
+
+print<<END;
+<table class='tbl'>
+       <tr>
+               <th style='width=5%'><b>$Lang::tr{'flag'}</b></th>
+               <th style='width=5%'><b>$Lang::tr{'countrycode'}</b></th>
+               <th style='width=40% text-align:left'><b>$Lang::tr{'country'}</b></th>
+               <th>&nbsp;</th>
+               <th style='width=5%'><b>$Lang::tr{'flag'}</b></th>
+               <th style='width=5%;'><b>$Lang::tr{'countrycode'}</b></th>
+               <th style='width=40% text-align:left;'><b>$Lang::tr{'country'}</b></th>
+       </tr>
+END
+
+# Get a list of all supported country codes.
+my @countries = &Location::Functions::get_locations();
+
+# 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 = &Location::Functions::get_flag_icon($country);
+
+       # Get country name.
+       my $name = &Location::Functions::get_full_country_name($country);
+
        if ($lines % 2) {
-               print "<td $col><a id='$fcode'><img src='/images/flags/$fcode.png' alt='$flagcode' title='$flagcode'/></a></td>";
-               print "<td $col>$flagcode</td>";
-               print "<td $col>$country</td></tr>\n";
-       }
-       else {
+               print "<td $col><a id='$country'><img src='$flag_icon' alt='$country' title='$country'/></a></td>";
+               print "<td $col>$country</td>";
+               print "<td $col>$name</td></tr>\n";
+       } else {
                $lines2++;
                if($lines2 % 2) {
                        $col="style='background-color:${Header::table2colour};'";
@@ -81,26 +80,33 @@ foreach $flag (@flaglistfiles)
                        $col="style='background-color:${Header::table1colour};'";
                }
                print "<tr>";
-               print "<td $col><a id='$fcode'><img src='/images/flags/$fcode.png' alt='$flagcode' title='$flagcode'/></a></td>";
-               print "<td $col>$flagcode</td>";
+               print "<td $col><a id='$country'><img src='$flag_icon' alt='$country' title='$country'/></a></td>";
                print "<td $col>$country</td>";
+               print "<td $col>$name</td>";
                print "<td $col>&nbsp;</td>";
+
+               # 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 "<td $col>&nbsp;</td>\n";
+                       print "<td $col>&nbsp;</td>\n";
+                       print "<td $col>&nbsp;</td></tr>\n";
+               }
        }
 }
-
-
 print "</table>";
 &Header::closebox();
 
-&Header::closebigbox();
-
 print <<END
-<div style='text-align:center'>
-<a href='$ENV{'HTTP_REFERER'}'>$Lang::tr{'back'}</a>
+<div align='center'>
+<table width='80%'>
+<tr>
+       <td align='center'><a href='$ENV{'HTTP_REFERER'}'><img src='/images/back.png' alt='$Lang::tr{'back'}' title='$Lang::tr{'back'}' /></a></td>
+</tr>
+</table>
 </div>
 END
-; 
-
-&Header::closepage();
+;
 
+&Header::closebigbox();
 
+&Header::closepage();