From: eldy <> Date: Thu, 24 Apr 2003 19:14:41 +0000 (+0000) Subject: Plugin geoip can works with perl modules Geo::IP or Geo::IP::PurePerl. X-Git-Tag: AWSTATS_5_5_BETA~19 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=05d17a332d72db5430ae52cd6448d0fedb9e523c;p=thirdparty%2FAWStats.git Plugin geoip can works with perl modules Geo::IP or Geo::IP::PurePerl. --- diff --git a/wwwroot/cgi-bin/plugins/geoip.pm b/wwwroot/cgi-bin/plugins/geoip.pm index 4498fcd7..e25055a6 100644 --- a/wwwroot/cgi-bin/plugins/geoip.pm +++ b/wwwroot/cgi-bin/plugins/geoip.pm @@ -5,14 +5,19 @@ # from a Geographical database (GeoIP internal database) instead of domain # hostname suffix. #----------------------------------------------------------------------------- -# Perl Required Modules: Geo::IP +# Perl Required Modules: Geo::IP or Geo::IP::PurePerl #----------------------------------------------------------------------------- # $Revision$ - $Author$ - $Date$ # <----- # ENTER HERE THE USE COMMAND FOR ALL REQUIRED PERL MODULES -if (!eval ('require "Geo/IP.pm";')) { return "Error: Need Perl module Geo::IP"; } +use vars qw/ $type /; +$type='geoip'; +if (!eval ('require "Geo/IP.pm";')) { + $type='geoippureperl'; + if (!eval ('require "Geo/IP/PurePerl.pm";')) { return "Error: Need Perl module Geo::IP or Geo::IP::PurePerl"; } +} # -----> use strict;no strict "refs"; @@ -48,11 +53,20 @@ sub Init_geoip { # ENTER HERE CODE TO DO INIT PLUGIN ACTIONS debug(" InitParams=$InitParams",1); my $mode=$InitParams; - if ($mode eq '' || $mode eq 'GEOIP_MEMORY_CACHE') { $mode=Geo::IP::GEOIP_MEMORY_CACHE(); } - else { $mode=Geo::IP::GEOIP_STANDARD(); } + if ($type eq 'geoippureperl') { + if ($mode eq '' || $mode eq 'GEOIP_MEMORY_CACHE') { $mode=Geo::IP::PurePerl::GEOIP_MEMORY_CACHE(); } + else { $mode=Geo::IP::PurePerl::GEOIP_STANDARD(); } + } else { + if ($mode eq '' || $mode eq 'GEOIP_MEMORY_CACHE') { $mode=Geo::IP::GEOIP_MEMORY_CACHE(); } + else { $mode=Geo::IP::GEOIP_STANDARD(); } + } %TmpDomainLookup=(); debug(" GeoIP working in mode $mode",1); - $gi = Geo::IP->new($mode); + if ($type eq 'geoippureperl') { + $gi = Geo::IP::PurePerl->new($mode); + } else { + $gi = Geo::IP->new($mode); + } # -----> return ($checkversion?$checkversion:"$PluginHooksFunctions");