This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "IPFire 2.x development tree".
The branch, master has been updated
via b47472c1865f1777251a43376286ce884b8a4ba8 (commit)
via 8fba24ec1503d9cf3ace983d35dc0bab54a1e510 (commit)
via 0ee211ee6be85fa6d12bc6f9278fc2c0a44ea420 (commit)
from 49d769c6e6eae844c6ffe30817024ea70bb2f60c (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit b47472c1865f1777251a43376286ce884b8a4ba8
Merge: 49d769c 8fba24e
Author: Michael Tremer <michael.tremer(a)ipfire.org>
Date: Wed May 13 22:02:46 2015 +0200
Merge remote-tracking branch 'stevee/core90-fixes'
commit 8fba24ec1503d9cf3ace983d35dc0bab54a1e510
Author: Stefan Schantl <stefan.schantl(a)ipfire.org>
Date: Tue May 12 20:41:35 2015 +0200
country.cgi: Rework script.
* Introduce new method to get all country codes. In the past just the countries
has been used for which flag icons where available, which is just not what we
want.
* Finish column when the last element in the array has passed and we have an uneven
amount of items
* Improve code style.
commit 0ee211ee6be85fa6d12bc6f9278fc2c0a44ea420
Author: Stefan Schantl <stefan.schantl(a)ipfire.org>
Date: Tue May 12 20:39:44 2015 +0200
geoip-block.cgi: Finish column after last element and uneven amount of items.
-----------------------------------------------------------------------
Summary of changes:
html/cgi-bin/country.cgi | 88 +++++++++++++++++++++-----------------------
html/cgi-bin/geoip-block.cgi | 11 +++++-
2 files changed, 51 insertions(+), 48 deletions(-)
Difference in files:
diff --git a/html/cgi-bin/country.cgi b/html/cgi-bin/country.cgi
index 60c2e58..f2ae813 100644
--- a/html/cgi-bin/country.cgi
+++ b/html/cgi-bin/country.cgi
@@ -23,12 +23,9 @@ 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";
@@ -41,44 +38,41 @@ require "${General::swroot}/header.pl";
&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> </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> </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 = 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);
+ # Convert country code into upper case.
+ my $country_uc = uc($country);
# Get flag icon for of the country.
- my $flag_icon = &GeoIP::get_flag_icon($fcode);
+ my $flag_icon = &GeoIP::get_flag_icon($country);
+
+ # Get country name.
+ my $name = &GeoIP::get_full_country_name($country);
- 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 "<td $col><a id='$fcode'><img src='$flag_icon' 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_uc' title='$country_uc'/></a></td>";
+ print "<td $col>$country_uc</td>";
+ print "<td $col>$name</td></tr>\n";
+ } else {
$lines2++;
if($lines2 % 2) {
$col="style='background-color:${Header::table2colour};'";
@@ -86,25 +80,25 @@ foreach $flag (@flaglistfiles)
$col="style='background-color:${Header::table1colour};'";
}
print "<tr>";
- print "<td $col><a id='$fcode'><img src='$flag_icon' alt='$flagcode' title='$flagcode'/></a></td>";
- print "<td $col>$flagcode</td>";
- print "<td $col>$country</td>";
+ print "<td $col><a id='$country'><img src='$flag_icon' alt='$country_uc' title='$country_uc'/></a></td>";
+ print "<td $col>$country_uc</td>";
+ print "<td $col>$name</td>";
print "<td $col> </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> </td>\n";
+ print "<td $col> </td>\n";
+ print "<td $col> </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>
-END
-;
+print "<div style='text-align:center'><a href='$ENV{'HTTP_REFERER'}'>$Lang::tr{'back'}</a></div>\n";
&Header::closepage();
diff --git a/html/cgi-bin/geoip-block.cgi b/html/cgi-bin/geoip-block.cgi
index ccbfa92..056b333 100644
--- a/html/cgi-bin/geoip-block.cgi
+++ b/html/cgi-bin/geoip-block.cgi
@@ -225,7 +225,16 @@ foreach my $location (@locations) {
print "<td align='center' $col>$flag</td>\n";
print "<td align='center' $col>$ccode_uc</td>\n";
print "<td align='left' $col>$cname</td>$line_end\n";
-
+
+ # Finish column when the last element in the array has passed and we have an uneven amount of items.
+ if(! ($lines2 % 2) && ($location eq $locations[-1] )) {
+ print "<td $col> </td>\n";
+ print "<td $col> </td>\n";
+ print "<td $col> </td>\n";
+ print "<td $col> </td>\n";
+ print "<td $col> </td></tr>\n";
+ }
+
$lines2++;
}
hooks/post-receive
--
IPFire 2.x development tree