Multiple CGI's: Use &GeoIP::get_flag_icon for getting country flags.

This commit is contained in:
Stefan Schantl
2015-05-02 13:45:50 +02:00
parent b013822b99
commit 3ea01fe042
4 changed files with 41 additions and 18 deletions

View File

@@ -31,6 +31,7 @@ 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";
@@ -64,12 +65,16 @@ foreach $flag (@flaglistfiles)
my $flagcode = uc(substr($flag, 0, 2));
my $fcode = lc($flagcode);
# Get flag icon for of the country.
my $flag_icon = &GeoIP::get_flag_icon($fcode);
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='/images/flags/$fcode.png' alt='$flagcode' title='$flagcode'/></a></td>";
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";
}
@@ -81,7 +86,7 @@ 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><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>&nbsp;</td>";

View File

@@ -21,6 +21,7 @@ use Getopt::Std;
#use CGI::Carp 'fatalsToBrowser';
require '/var/ipfire/general-functions.pl';
require "${General::swroot}/geoip-functions.pl";
require "${General::swroot}/lang.pl";
require "${General::swroot}/header.pl";
@@ -372,10 +373,15 @@ foreach $_ (@log)
<td align='center' $col>$srcport<br/>$dstport</td>
END
;
if ( $fcode ne "" ){
print "<td align='center' $col><a href='../country.cgi#$fcode'><img src='/images/flags/$fcode.png' border='0' align='absmiddle' alt='$ccode'></a></td>";}
else {
print "<td align='center' $col></td>";}
# Get flag icon for of the country.
my $flag_icon = &GeoIP::get_flag_icon($fcode);
if ( $flag_icon) {
print "<td align='center' $col><a href='../country.cgi#$fcode'><img src='$flag_icon' border='0' align='absmiddle' alt='$ccode'></a></td>";
} else {
print "<td align='center' $col></td>";
}
print <<END
<td align='center' $col>$macaddr</td>
</tr>

View File

@@ -19,6 +19,7 @@ use Getopt::Std;
#use CGI::Carp 'fatalsToBrowser';
require '/var/ipfire/general-functions.pl';
require "${General::swroot}/geoip-functions.pl";
require "${General::swroot}/lang.pl";
require "${General::swroot}/header.pl";
@@ -460,11 +461,15 @@ for($s=0;$s<$lines;$s++)
print "<td align='center' $col>$key[$s]</td>";
}
else {
if($key[$s] ne 'unknown' ) {
my $fcode = lc($key[$s]);
print "<td align='center' $col><a href='/cgi-bin/country.cgi#$fcode'><img src='/images/flags/$fcode.png' border='0' align='absmiddle' alt='$key[$s]' title='$key[$s]'></a></td>";}
else {
print "<td align='center' $col>$key[$s]</td>";
my $fcode = lc($key[$s]);
# Get flag icon for of the country.
my $flag_icon = &GeoIP::get_flag_icon($fcode);
if($flag_icon) {
print "<td align='center' $col><a href='/cgi-bin/country.cgi#$fcode'><img src='$flag_icon' border='0' align='absmiddle' alt='$key[$s]' title='$key[$s]'></a></td>";
} else {
print "<td align='center' $col>$key[$s]</td>";
}
}
print "<td align='center' $col>$value[$s]</td>";

View File

@@ -19,6 +19,7 @@ use Getopt::Std;
#use CGI::Carp 'fatalsToBrowser';
require '/var/ipfire/general-functions.pl';
require "${General::swroot}/geoip-functions.pl";
require "${General::swroot}/lang.pl";
require "${General::swroot}/header.pl";
@@ -441,13 +442,19 @@ for($s=0;$s<$lines;$s++)
$color++;
print "<td align='center' $col><form method='post' action='showrequestfromip.dat'><input type='hidden' name='MONTH' value='$cgiparams{'MONTH'}'> <input type='hidden' name='DAY' value='$cgiparams{'DAY'}'> <input type='hidden' name='ip' value='$key[$s]'> <input type='submit' value='$Lang::tr{'details'}'></form></td>";
print "<td align='center' $col><a href='/cgi-bin/ipinfo.cgi?ip=$key[$s]'>$key[$s]</a></td>";
if ( $fcode ne "" ){
print "<td align='center' $col><a href='/cgi-bin/country.cgi#$fcode'><img src='/images/flags/$fcode.png' border='0' align='absmiddle' alt='$ccode' title='$ccode'></a></td>";}
else {
print "<td align='center' $col></td>";}
print "<td align='center' $col>$value[$s]</td>";
print "<td align='center' $col>$percent</td>";
print "</tr>";
# Get flag icon for of the country.
my $flag_icon = &GeoIP::get_flag_icon($ccode);
if ( $flag_icon ) {
print "<td align='center' $col><a href='/cgi-bin/country.cgi#$fcode'><img src='$flag_icon' border='0' align='absmiddle' alt='$ccode' title='$ccode'></a></td>";
} else {
print "<td align='center' $col></td>";
}
print "<td align='center' $col>$value[$s]</td>";
print "<td align='center' $col>$percent</td>";
print "</tr>";
}
if($cgiparams{'otherspie'} == 2 ){}