]> git.ipfire.org Git - people/pmueller/ipfire-2.x.git/blobdiff - html/cgi-bin/logs.cgi/showrequestfromcountry.dat
logs.cgi/showrequestfromcountry.dat: Use location-functions.pl
[people/pmueller/ipfire-2.x.git] / html / cgi-bin / logs.cgi / showrequestfromcountry.dat
index b6383ed59bf6806bbff57f2bc8e8cd247505e918..4d80e77a4d68fa2bacba9f275c1df842bd2d9c4c 100644 (file)
 #use CGI::Carp 'fatalsToBrowser';
 
 #use strict;
-use Geo::IP::PurePerl;
 
 require '/var/ipfire/general-functions.pl';
+require "${General::swroot}/location-functions.pl";
 require "${General::swroot}/lang.pl";
 require "${General::swroot}/header.pl";
 
+# Libloc database handle.
+my $libloc_db_handle = &Location::Functions::init();
+
 use POSIX();
 
 #workaround to suppress a warning when a variable is used only once
@@ -152,7 +155,6 @@ if (!(open (FILE,($filestr =~ /.gz$/ ? "gzip -dc $filestr |" : $filestr)))) {
 my $lines = 0;
 my @log=();
 my $country = $cgiparams{country};
-my $gi = Geo::IP::PurePerl->new();
 
 if (!$skip)
 {
@@ -179,7 +181,7 @@ if (!$skip)
                        }
                        elsif($srcaddr ne '') {
                                # or srcaddr matches country code
-                               my $ccode = $gi->country_code_by_name($srcaddr);
+                               my $ccode = &Location::Functions::lookup_country_code($libloc_db_handle, $srcaddr);
                                if($ccode eq uc($country)){
                                        $log[$lines] = $_;
                                        $lines++;
@@ -350,7 +352,7 @@ foreach $_ (@slice)
        if($iface eq $country || $srcaddr ne '') {
                my $ccode='';
                if($iface ne $country) {
-                       $ccode = $gi->country_code_by_name($srcaddr);
+                       $ccode = &Location::Functions::lookup_country_code($libloc_db_handle, $srcaddr);
                }
                if($iface eq $country || $ccode eq uc($country)) {
                        my $chain = '';