From 3ea01fe042cfb1619415aed3e69bc700dd48ad53 Mon Sep 17 00:00:00 2001 From: Stefan Schantl Date: Sat, 2 May 2015 13:45:50 +0200 Subject: [PATCH] Multiple CGI's: Use &GeoIP::get_flag_icon for getting country flags. --- html/cgi-bin/country.cgi | 9 +++++++-- html/cgi-bin/logs.cgi/firewalllog.dat | 14 +++++++++---- html/cgi-bin/logs.cgi/firewalllogcountry.dat | 15 +++++++++----- html/cgi-bin/logs.cgi/firewalllogip.dat | 21 +++++++++++++------- 4 files changed, 41 insertions(+), 18 deletions(-) diff --git a/html/cgi-bin/country.cgi b/html/cgi-bin/country.cgi index 65ce15433..60c2e5869 100644 --- a/html/cgi-bin/country.cgi +++ b/html/cgi-bin/country.cgi @@ -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 "$flagcode"; + print "$flagcode"; print "$flagcode"; print "$country\n"; } @@ -81,7 +86,7 @@ foreach $flag (@flaglistfiles) $col="style='background-color:${Header::table1colour};'"; } print ""; - print "$flagcode"; + print "$flagcode"; print "$flagcode"; print "$country"; print " "; diff --git a/html/cgi-bin/logs.cgi/firewalllog.dat b/html/cgi-bin/logs.cgi/firewalllog.dat index 752562666..5a584d60d 100644 --- a/html/cgi-bin/logs.cgi/firewalllog.dat +++ b/html/cgi-bin/logs.cgi/firewalllog.dat @@ -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) $srcport
$dstport END ; - if ( $fcode ne "" ){ - print "$ccode";} - else { - print "";} + # Get flag icon for of the country. + my $flag_icon = &GeoIP::get_flag_icon($fcode); + + if ( $flag_icon) { + print "$ccode"; + } else { + print ""; + } + print <$macaddr diff --git a/html/cgi-bin/logs.cgi/firewalllogcountry.dat b/html/cgi-bin/logs.cgi/firewalllogcountry.dat index 3a774f922..29c084218 100644 --- a/html/cgi-bin/logs.cgi/firewalllogcountry.dat +++ b/html/cgi-bin/logs.cgi/firewalllogcountry.dat @@ -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 "$key[$s]"; } else { - if($key[$s] ne 'unknown' ) { - my $fcode = lc($key[$s]); - print "$key[$s]";} - else { - print "$key[$s]"; + my $fcode = lc($key[$s]); + + # Get flag icon for of the country. + my $flag_icon = &GeoIP::get_flag_icon($fcode); + + if($flag_icon) { + print "$key[$s]"; + } else { + print "$key[$s]"; } } print "$value[$s]"; diff --git a/html/cgi-bin/logs.cgi/firewalllogip.dat b/html/cgi-bin/logs.cgi/firewalllogip.dat index 07bcc77f8..7d82d20e7 100644 --- a/html/cgi-bin/logs.cgi/firewalllogip.dat +++ b/html/cgi-bin/logs.cgi/firewalllogip.dat @@ -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 "
"; print "$key[$s]"; - if ( $fcode ne "" ){ - print "$ccode";} - else { - print "";} - print "$value[$s]"; - print "$percent"; - print ""; + + # Get flag icon for of the country. + my $flag_icon = &GeoIP::get_flag_icon($ccode); + + if ( $flag_icon ) { + print "$ccode"; + } else { + print ""; + } + + print "$value[$s]"; + print "$percent"; + print ""; } if($cgiparams{'otherspie'} == 2 ){} -- 2.39.2