]> git.ipfire.org Git - ipfire-2.x.git/commitdiff
geoip-block.cgi: Use geoip-functions.pl.
authorStefan Schantl <stefan.schantl@ipfire.org>
Sun, 8 Feb 2015 17:24:51 +0000 (18:24 +0100)
committerStefan Schantl <stefan.schantl@ipfire.org>
Sun, 8 Feb 2015 17:24:51 +0000 (18:24 +0100)
html/cgi-bin/geoip-block.cgi

index 6a7d1d96efe92deda9ccc6453cde89c1002d57e3..ccbfa926a0ad3c576217107f0fbc7842edf1cfc4 100644 (file)
@@ -25,15 +25,11 @@ use strict;
 #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";
 require "/usr/lib/firewall/firewall-lib.pl";
 
-# Directory which contains flag icons.
-my $flagdir = "/srv/web/ipfire/html/images/flags";
-# File extension of the country flags.
-my $extension = "png";
-
 my $notice;
 my $settingsfile = "${General::swroot}/firewall/geoipblock";
 
@@ -179,20 +175,15 @@ foreach my $location (@locations) {
        my $ccode_lc = lc($location);
 
        # Full name of the country based on the country code.
-       my $cname = &General::get_full_country_name($ccode_lc);
-
-       # Generate flag filename, based on the lower case written contry code
-       # and the defined file extension of the image files. (de.png)
-       my $flagfile = join('.', $ccode_lc,$extension);
+       my $cname = &GeoIP::get_full_country_name($ccode_lc);
 
-       # Generate the full path to the flagfile, based on the given path and
-       # the previously generated filename.
-       my $flagpath = join('/', $flagdir,$flagfile);
+       # Get flag icon for of the country.
+       my $flag_icon = &GeoIP::get_flag_icon($ccode_uc);
 
        my $flag;
        # Check if a flag for the country is available.
-       if (-e "$flagpath") {
-               $flag="<img src='/images/flags/$flagfile' alt='$ccode_uc' title='$ccode_uc'>";
+       if ($flag_icon) {
+               $flag="<img src='$flag_icon' alt='$ccode_uc' title='$ccode_uc'>";
        } else {
                $flag="<b>N/A</b>";
        }