]> git.ipfire.org Git - thirdparty/AWStats.git/commitdiff
Fix: Path of data file can contains spaces
authoreldy <>
Wed, 4 Aug 2010 12:38:03 +0000 (12:38 +0000)
committereldy <>
Wed, 4 Aug 2010 12:38:03 +0000 (12:38 +0000)
Fix: Tmp lookup must only check in memory (must not make resolve, this is goal of other function)

wwwroot/cgi-bin/awstats.model.conf
wwwroot/cgi-bin/plugins/geoip.pm
wwwroot/cgi-bin/plugins/geoip_asn_maxmind.pm
wwwroot/cgi-bin/plugins/geoip_city_maxmind.pm
wwwroot/cgi-bin/plugins/geoip_isp_maxmind.pm
wwwroot/cgi-bin/plugins/geoip_org_maxmind.pm
wwwroot/cgi-bin/plugins/geoip_region_maxmind.pm

index f4fd2925500f01c60e15b83afda456ce0a69e17d..1983530f7077bbb39e4b394c5ec0d61e903c379a 100644 (file)
@@ -1412,7 +1412,7 @@ color_x="C1B2E2"                          # Background color for number of exit pages (Default = "C1B2
 
 # PLUGIN: GeoIP
 # REQUIRED MODULES: Geo::IP or Geo::IP::PurePerl (from Maxmind)
-# PARAMETERS: [GEOIP_STANDARD | GEOIP_MEMORY_CACHE] [/pathto/geoip.dat] </pathto/override.txt>
+# PARAMETERS: [GEOIP_STANDARD | GEOIP_MEMORY_CACHE] [/pathto/geoip.dat[+/pathto/override.txt]]
 # DESCRIPTION: Builds a country chart and adds an entry to the hosts 
 # table with country name
 # Replace spaces in the path of geoip data file with string "%20".
@@ -1421,7 +1421,7 @@ color_x="C1B2E2"                          # Background color for number of exit pages (Default = "C1B2
 
 # PLUGIN: GeoIP_City_Maxmind
 # REQUIRED MODULES: Geo::IP or Geo::IP::PurePerl (from Maxmind)
-# PARAMETERS: [GEOIP_STANDARD | GEOIP_MEMORY_CACHE] [/pathto/GeoIPCity.dat] </pathto/override.txt>
+# PARAMETERS: [GEOIP_STANDARD | GEOIP_MEMORY_CACHE] [/pathto/GeoIPCity.dat[+/pathto/override.txt]]
 # DESCRIPTION: This plugin adds a column under the hosts field and tracks the pageviews
 # and hits by city including regions.
 # Replace spaces in the path of geoip data file with string "%20".
@@ -1430,8 +1430,7 @@ color_x="C1B2E2"                          # Background color for number of exit pages (Default = "C1B2
 
 # PLUGIN: GeoIP_ASN_Maxmind
 # REQUIRED MODULES: Geo::IP or Geo::IP::PurePerl (from Maxmind)
-# PARAMETERS: [GEOIP_STANDARD | GEOIP_MEMORY_CACHE] [/pathto/GeoIPASN.dat] 
-#              </pathto/override.txt> <link to AS lookup>
+# PARAMETERS: [GEOIP_STANDARD | GEOIP_MEMORY_CACHE] [/pathto/GeoIPASN.dat[+/pathto/override.txt]] <link to AS lookup>
 # DESCRIPTION: This plugin adds a chart of AS numbers where the host IP address is registered. 
 # This plugin can display some ISP information if included in the database. You can also provide 
 # a link that will be used to lookup additional registration data. Put the link at the end of 
@@ -1442,7 +1441,7 @@ color_x="C1B2E2"                          # Background color for number of exit pages (Default = "C1B2
 
 # PLUGIN: GeoIP_Region_Maxmind
 # REQUIRED MODULES: Geo::IP or Geo::IP::PurePerl (from Maxmind)
-# PARAMETERS: [GEOIP_STANDARD | GEOIP_MEMORY_CACHE] [/pathto/GeoIPRegion.dat]
+# PARAMETERS: [GEOIP_STANDARD | GEOIP_MEMORY_CACHE] [/pathto/GeoIPRegion.dat[+/pathto/override.txt]]
 # DESCRIPTION:This plugin adds a chart of hits by regions. Only regions for US and 
 # Canada can be detected.
 # Replace spaces in the path of geoip data file with string "%20".
@@ -1451,7 +1450,7 @@ color_x="C1B2E2"                          # Background color for number of exit pages (Default = "C1B2
 
 # PLUGIN: GeoIP_ISP_Maxmind
 # REQUIRED MODULES: Geo::IP or Geo::IP::PurePerl (from Maxmind)
-# PARAMETERS: [GEOIP_STANDARD | GEOIP_MEMORY_CACHE] [/pathto/GeoIPISP.dat]
+# PARAMETERS: [GEOIP_STANDARD | GEOIP_MEMORY_CACHE] [/pathto/GeoIPISP.dat[+/pathto/override.txt]]
 # DESCRIPTION: This plugin adds a chart of hits by ISP.
 # Replace spaces in the path of geoip data file with string "%20".
 #
@@ -1459,7 +1458,7 @@ color_x="C1B2E2"                          # Background color for number of exit pages (Default = "C1B2
 
 # PLUGIN: GeoIP_Org_Maxmind
 # REQUIRED MODULES: Geo::IP or Geo::IP::PurePerl (from Maxmind)
-# PARAMETERS: [GEOIP_STANDARD | GEOIP_MEMORY_CACHE] [/pathto/GeoIPOrg.dat]
+# PARAMETERS: [GEOIP_STANDARD | GEOIP_MEMORY_CACHE] [/pathto/GeoIPOrg.dat[+/pathto/override.txt]]
 # DESCRIPTION: This plugin add a chart of hits by Organization name
 # Replace spaces in the path of geoip data file with string "%20".
 #
index 518f0dbbaf8802360a5ec8e03ac2b43840d42b81..0f3c0f9e32196f2be3f2edcd1766e13f6c30b2f9 100644 (file)
@@ -63,8 +63,10 @@ sub Init_geoip {
        # <-----
        # ENTER HERE CODE TO DO INIT PLUGIN ACTIONS
        debug(" Plugin $PluginName: InitParams=$InitParams",1);
-       my ($mode,$datafile,$override)=split(/\s+/,$InitParams,3);
+       my ($mode,$tmpdatafile)=split(/\s+/,$InitParams,2);
+       my ($datafile,$override)=split(/\+/,$tmpdatafile,2);
        if (! $datafile) { $datafile="$PluginName.dat"; }
+    else { $datafile =~ s/%20/ /g; }
        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(); }
@@ -218,21 +220,25 @@ sub LoadOverrideFile_geoip{
                my $conf = (exists(&Get_Config_Name) ? Get_Config_Name() : $SiteConfig);
                if ($conf && open(GEOIPFILE,"$DirData/$PluginName.$conf.txt"))  { $filetoload="$DirData/$PluginName.$conf.txt"; }
                elsif (open(GEOIPFILE,"$DirData/$PluginName.txt"))      { $filetoload="$DirData/$PluginName.txt"; }
-               else { debug("Did not find $PluginName file \"$DirData/$PluginName.txt\": $!"); }
+               else { debug("No override file \"$DirData/$PluginName.txt\": $!"); }
        }
-       # This is the fastest way to load with regexp that I know
-       while (<GEOIPFILE>){
-               chomp $_;
-               s/\r//;
-               my @record = split(",", $_);
-               # replace quotes if they were used in the file
-               foreach (@record){ $_ =~ s/"//g; }
-               # store in hash
-               $TmpDomainLookup{$record[0]} = $record[1];
+       if ($filetoload)
+       {
+               # This is the fastest way to load with regexp that I know
+               while (<GEOIPFILE>){
+                       chomp $_;
+                       s/\r//;
+                       my @record = split(",", $_);
+                       # replace quotes if they were used in the file
+                       foreach (@record){ $_ =~ s/"//g; }
+                       # store in hash
+                       $TmpDomainLookup{$record[0]} = $record[1];
+               }
+               close GEOIPFILE;
+        debug(" Plugin $PluginName: Overload file loaded: ".(scalar keys %TmpDomainLookup)." entries found.");
        }
-       close GEOIPFILE;
        $LoadedOverride = 1;
-       debug(" Plugin $PluginName: Overload file loaded: ".(scalar keys %TmpDomainLookup)." entries found.");
+       return;
 }
 
 #-----------------------------------------------------------------------------
@@ -243,14 +249,15 @@ sub LoadOverrideFile_geoip{
 sub TmpLookup_geoip(){
        $param = shift;
        if (!$LoadedOverride){&LoadOverrideFile_geoip();}
-       my $val;
-       if ($gi &&
-       (($type eq 'geoip' && $gi->VERSION >= 1.30) || 
-         $type eq 'geoippureperl' && $gi->VERSION >= 1.17)){
-               $val = $TmpDomainLookup{$gi->get_ip_address($param)};
-       }
-    else {$val = $TmpDomainLookup{$param};}
-    return $val || '';
+       #my $val;
+       #if ($gi &&
+       #(($type eq 'geoip' && $gi->VERSION >= 1.30) || 
+       #  $type eq 'geoippureperl' && $gi->VERSION >= 1.17)){
+       #       $val = $TmpDomainLookup{$gi->get_ip_address($param)};
+       #}
+    #else {$val = $TmpDomainLookup{$param};}
+    #return $val || '';
+    return $TmpDomainLookup{$param}||'';
 }
 
 1;     # Do not remove this line
index c73b6dc59caee14fa46b04c1145c2d548c2dd9f1..dbc565362cc57ec542faba09e5b539edcc926410 100644 (file)
@@ -79,7 +79,8 @@ sub Init_geoip_asn_maxmind {
        # <-----
        # ENTER HERE CODE TO DO INIT PLUGIN ACTIONS
        debug(" Plugin $PluginName: InitParams=$InitParams",1);
-       my ($mode,$datafile,$override,$link)=split(/\s+/,$InitParams,4);
+    my ($mode,$tmpdatafile)=split(/\s+/,$InitParams,2);
+    my ($datafile,$override,$link)=split(/\+/,$tmpdatafile,3);
        if (! $datafile) { $datafile="GeoIPASNum.dat"; }
        else { $datafile =~ s/%20/ /g; }
        if ($type eq 'geoippureperl') {
@@ -485,21 +486,25 @@ sub LoadOverrideFile_geoip_asn_maxmind{
                my $conf = (exists(&Get_Config_Name) ? Get_Config_Name() : $SiteConfig);
                if ($conf && open(GEOIPFILE,"$DirData/$PluginName.$conf.txt"))  { $filetoload="$DirData/$PluginName.$conf.txt"; }
                elsif (open(GEOIPFILE,"$DirData/$PluginName.txt"))      { $filetoload="$DirData/$PluginName.txt"; }
-               else { debug("Did not find $PluginName file \"$DirData/$PluginName.txt\": $!"); }
+               else { debug("No override file \"$DirData/$PluginName.txt\": $!"); }
        }
-       # This is the fastest way to load with regexp that I know
-       while (<GEOIPFILE>){
-               chomp $_;
-               s/\r//;
-               my @record = split(",", $_);
-               # replace quotes if they were used in the file
-               foreach (@record){ $_ =~ s/"//g; }
-               # store in hash
-               $TmpLookup{$record[0]} = $record[1];
+       if ($filetoload)
+       {
+               # This is the fastest way to load with regexp that I know
+               while (<GEOIPFILE>){
+                       chomp $_;
+                       s/\r//;
+                       my @record = split(",", $_);
+                       # replace quotes if they were used in the file
+                       foreach (@record){ $_ =~ s/"//g; }
+                       # store in hash
+                       $TmpLookup{$record[0]} = $record[1];
+               }
+               close GEOIPFILE;
+        debug(" Plugin $PluginName: Overload file loaded: ".(scalar keys %TmpLookup)." entries found.");
        }
-       close GEOIPFILE;
        $LoadedOverride = 1;
-       debug(" Plugin $PluginName: Overload file loaded: ".(scalar keys %TmpLookup)." entries found.");
+       return;
 }
 
 sub trim($)
@@ -518,14 +523,16 @@ sub trim($)
 sub TmpLookup_geoip_asn_maxmind(){
        $param = shift;
        if (!$LoadedOverride){&LoadOverrideFile_geoip_asn_maxmind();}
-       my $val;
-       if ($geoip_asn_maxmind && 
-       (($type eq 'geoip' && $geoip_asn_maxmind->VERSION >= 1.30) || 
-         $type eq 'geoippureperl' && $geoip_asn_maxmind->VERSION >= 1.17)){
-               $val = $TmpLookup{$geoip_asn_maxmind->get_ip_address($param)};
-       }
-    else {$val = $TmpLookup{$param};}
-    return $val || '';
+#      my $val;
+#      if ($geoip_asn_maxmind && 
+#      (($type eq 'geoip' && $geoip_asn_maxmind->VERSION >= 1.30) || 
+#        $type eq 'geoippureperl' && $geoip_asn_maxmind->VERSION >= 1.17)){
+#              $val = $TmpLookup{$geoip_asn_maxmind->get_ip_address($param)};
+#      }
+#    else {$val = $TmpLookup{$param};}
+#    return $val || '';
+    return $TmpLookup{$param}||'';
+    
 }
 
 
index a8ec54c8a95cf252409728373bbe5a0833a62f81..20d99ece20e4298e9883ee6347f803b6187fa7a4 100755 (executable)
@@ -4289,7 +4289,8 @@ sub Init_geoip_city_maxmind {
        # <-----
        # ENTER HERE CODE TO DO INIT PLUGIN ACTIONS
        debug(" Plugin $PluginName: InitParams=$InitParams",1);
-       my ($mode,$datafile,$override)=split(/\s+/,$InitParams,3);
+    my ($mode,$tmpdatafile)=split(/\s+/,$InitParams,2);
+    my ($datafile,$override)=split(/\+/,$tmpdatafile,2);
        if (! $datafile) { $datafile="GeoIPCity.dat"; }
        else { $datafile =~ s/%20/ /g; }
        if ($type eq 'geoippureperl') {
@@ -4696,28 +4697,22 @@ sub SectionProcessIp_geoip_city_maxmind {
        }
        else
        {
-               my $record=();
-               my $city, $countrycity, $region;
+        my $record=();
                my @rec = TmpLookup_geoip_city_maxmind($param);
                if (@rec){
-                       $city = $rec[4];
-                       $countrycity = $rec[3];
-                       $region = $rec[0];
+            $record->city = $rec[4];
+            $record->region = $rec[0];
+            $record->country_code = $rec[3];
                }else{
                        $record=$geoip_city_maxmind->record_by_addr($param) if $geoip_city_maxmind;
-                       if ($record){
-                               $city = $record->city;
-                               $countrycity = $record->country_code;
-                               $region = $record->region;
-                       }
                }
-               if ($Debug) { debug("  Plugin $PluginName: GetCityByIp for $param: [$city]",5); }
-           if ($city) {
+               if ($Debug) { debug("  Plugin $PluginName: GetCityByIp for $param: [$record]",5); }
+           if ($record) {
        #       if ($PageBool) { $_city_p{$city}++; }
                if ($city) {
-                   my $countrycity=$countrycity.'_'.$city;
+                   my $countrycity=$record->country_code.'_'.$record->city;
                    $countrycity=~s/ /%20/g;
-                   if ($region) { $countrycity.='_'.$region; }
+                   if ($region) { $countrycity.='_'.$record->region; }
                    $_city_h{lc($countrycity)}++;
                } else {
                    $_city_h{'unknown'}++;
@@ -4878,31 +4873,34 @@ sub LoadOverrideFile_geoip_city_maxmind{
                my $conf = (exists(&Get_Config_Name) ? Get_Config_Name() : $SiteConfig);
                if ($conf && open(GEOIPFILE,"$DirData/$PluginName.$conf.txt"))  { $filetoload="$DirData/$PluginName.$conf.txt"; }
                elsif (open(GEOIPFILE,"$DirData/$PluginName.txt"))      { $filetoload="$DirData/$PluginName.txt"; }
-               else { debug("Did not find $PluginName file \"$DirData/$PluginName.txt\": $!"); }
+               else { debug("No override file \"$DirData/$PluginName.txt\": $!"); }
        }
-       # This is the fastest way to load with regexp that I know
-       while (<GEOIPFILE>){
-               chomp $_;
-               s/\r//;
-               my @record = split(",", $_);
-               # replace quotes if they were used in the file
-               foreach (@record){ $_ =~ s/"//g; }
-               # now we need to copy our file values in the order to mimic the lookup values
-               my @res = ();
-               $res[0] = $record[1];
-               $res[3] = $record[2];
-               $res[4] = $record[3];
-               $res[5] = $record[4];
-               $res[6] = $record[5];
-               $res[7] = $record[6];
-               $res[8] = $record[7];
-               $res[9] = $record[8];
-               # store in hash
-               $TmpDomainLookup{$record[0]} = [@res];
+       if ($filetoload)
+       {
+               # This is the fastest way to load with regexp that I know
+               while (<GEOIPFILE>){
+                       chomp $_;
+                       s/\r//;
+                       my @record = split(",", $_);
+                       # replace quotes if they were used in the file
+                       foreach (@record){ $_ =~ s/"//g; }
+                       # now we need to copy our file values in the order to mimic the lookup values
+                       my @res = ();
+                       $res[0] = $record[1];
+                       $res[3] = $record[2];
+                       $res[4] = $record[3];
+                       $res[5] = $record[4];
+                       $res[6] = $record[5];
+                       $res[7] = $record[6];
+                       $res[8] = $record[7];
+                       $res[9] = $record[8];
+                       # store in hash
+                       $TmpDomainLookup{$record[0]} = [@res];
+               }
+               close GEOIPFILE;
+        debug(" Plugin $PluginName: Overload file loaded: ".(scalar keys %TmpDomainLookup)." entries found.");
        }
-       close GEOIPFILE;
        $LoadedOverride = 1;
-       debug(" Plugin $PluginName: Overload file loaded: ".(scalar keys %TmpDomainLookup)." entries found.");
        return;
 }
 
@@ -4914,14 +4912,15 @@ sub LoadOverrideFile_geoip_city_maxmind{
 sub TmpLookup_geoip_city_maxmind(){
        $param = shift;
        if (!$LoadedOverride){&LoadOverrideFile_geoip_city_maxmind();}
-       my @val = ();
-       if ($geoip_city_maxmind &&
-       (($type eq 'geoip' && $geoip_city_maxmind->VERSION >= 1.30) || 
-         $type eq 'geoippureperl' && $geoip_city_maxmind->VERSION >= 1.17)){
-               @val = @{$TmpDomainLookup{$geoip_city_maxmind->get_ip_address($param)}};
-       }
-    else {@val = @{$TmpDomainLookup{$param};}}
-    return @val;
+#      my @val = ();
+#      if ($geoip_city_maxmind &&
+#      (($type eq 'geoip' && $geoip_city_maxmind->VERSION >= 1.30) || 
+#        $type eq 'geoippureperl' && $geoip_city_maxmind->VERSION >= 1.17)){
+#              @val = @{$TmpDomainLookup{$geoip_city_maxmind->get_ip_address($param)}};
+#      }
+#    else {@val = @{$TmpDomainLookup{$param};}}
+#    return @val;
+    return @{$TmpDomainLookup{$param};}||'';
 }
 
 
index 904bc89f6afa50bff1d7c250b3cb117fa90a1f80..4ea6a0302b296215ab66423e1410f879c2d98c21 100644 (file)
@@ -69,7 +69,8 @@ sub Init_geoip_isp_maxmind {
        # <-----
        # ENTER HERE CODE TO DO INIT PLUGIN ACTIONS
        debug(" Plugin $PluginName: InitParams=$InitParams",1);
-       my ($mode,$datafile,$override)=split(/\s+/,$InitParams,3);
+    my ($mode,$tmpdatafile)=split(/\s+/,$InitParams,2);
+    my ($datafile,$override)=split(/\+/,$tmpdatafile,2);
        if (! $datafile) { $datafile="GeoIPIsp.dat"; }
        else { $datafile =~ s/%20/ /g; }
        if ($type eq 'geoippureperl') {
@@ -464,21 +465,24 @@ sub LoadOverrideFile_geoip_isp_maxmind{
                my $conf = (exists(&Get_Config_Name) ? Get_Config_Name() : $SiteConfig);
                if ($conf && open(GEOIPFILE,"$DirData/$PluginName.$conf.txt"))  { $filetoload="$DirData/$PluginName.$conf.txt"; }
                elsif (open(GEOIPFILE,"$DirData/$PluginName.txt"))      { $filetoload="$DirData/$PluginName.txt"; }
-               else { debug("Did not find $PluginName file \"$DirData/$PluginName.txt\": $!"); }
+               else { debug("No override file \"$DirData/$PluginName.txt\": $!"); }
        }
-       # This is the fastest way to load with regexp that I know
-       while (<GEOIPFILE>){
-               chomp $_;
-               s/\r//;
-               my @record = split(",", $_);
-               # replace quotes if they were used in the file
-               foreach (@record){ $_ =~ s/"//g; }
-               # store in hash
-               $TmpDomainLookup{$record[0]} = $record[1];
+       if ($filetoload)
+       {
+               # This is the fastest way to load with regexp that I know
+               while (<GEOIPFILE>){
+                       chomp $_;
+                       s/\r//;
+                       my @record = split(",", $_);
+                       # replace quotes if they were used in the file
+                       foreach (@record){ $_ =~ s/"//g; }
+                       # store in hash
+                       $TmpDomainLookup{$record[0]} = $record[1];
+               }
+               close GEOIPFILE;
+        debug(" Plugin $PluginName: Overload file loaded: ".(scalar keys %TmpDomainLookup)." entries found.");
        }
-       close GEOIPFILE;
        $LoadedOverride = 1;
-       debug(" Plugin $PluginName: Overload file loaded: ".(scalar keys %TmpDomainLookup)." entries found.");
        return;
 }
 
@@ -490,14 +494,15 @@ sub LoadOverrideFile_geoip_isp_maxmind{
 sub TmpLookup_geoip_isp_maxmind(){
        $param = shift;
        if (!$LoadedOverride){&LoadOverrideFile_geoip_isp_maxmind();}
-       my $val;
-       if ($geoip_isp_maxmind &&
-       (($type eq 'geoip' && $geoip_isp_maxmind->VERSION >= 1.30) || 
-         $type eq 'geoippureperl' && $geoip_isp_maxmind->VERSION >= 1.17)){
-               $val = $TmpDomainLookup{$geoip_isp_maxmind->get_ip_address($param)};
-       }
-    else {$val = $TmpDomainLookup{$param};}
-    return $val || '';
+       #my $val;
+       #if ($geoip_isp_maxmind &&
+       #(($type eq 'geoip' && $geoip_isp_maxmind->VERSION >= 1.30) || 
+       #  $type eq 'geoippureperl' && $geoip_isp_maxmind->VERSION >= 1.17)){
+       #       $val = $TmpDomainLookup{$geoip_isp_maxmind->get_ip_address($param)};
+       #}
+    #else {$val = $TmpDomainLookup{$param};}
+    #return $val || '';
+    return $TmpDomainLookup{$param}||'';
 }
 
 1;     # Do not remove this line
index cb71f836b19ce0f9812c0b97a90fa6bbdf91e52e..a3b93112c6ed3f2d6131bd9a228222b81deb2e11 100644 (file)
@@ -69,7 +69,8 @@ sub Init_geoip_org_maxmind {
        # <-----
        # ENTER HERE CODE TO DO INIT PLUGIN ACTIONS
        debug(" Plugin $PluginName: InitParams=$InitParams",1);
-       my ($mode,$datafile,$override)=split(/\s+/,$InitParams,3);
+    my ($mode,$tmpdatafile)=split(/\s+/,$InitParams,2);
+    my ($datafile,$override)=split(/\+/,$tmpdatafile,2);
        if (! $datafile) { $datafile="GeoIPOrg.dat"; }
        else { $datafile =~ s/%20/ /g; }
        if ($type eq 'geoippureperl') {
@@ -462,21 +463,24 @@ sub LoadOverrideFile_geoip_org_maxmind{
                my $conf = (exists(&Get_Config_Name) ? Get_Config_Name() : $SiteConfig);
                if ($conf && open(GEOIPFILE,"$DirData/$PluginName.$conf.txt"))  { $filetoload="$DirData/$PluginName.$conf.txt"; }
                elsif (open(GEOIPFILE,"$DirData/$PluginName.txt"))      { $filetoload="$DirData/$PluginName.txt"; }
-               else { debug("Did not find $PluginName file \"$DirData/$PluginName.txt\": $!"); }
+               else { debug("No override file \"$DirData/$PluginName.txt\": $!"); }
        }
-       # This is the fastest way to load with regexp that I know
-       while (<GEOIPFILE>){
-               chomp $_;
-               s/\r//;
-               my @record = split(",", $_);
-               # replace quotes if they were used in the file
-               foreach (@record){ $_ =~ s/"//g; }
-               # store in hash
-               $TmpDomainLookup{$record[0]} = $record[1];
+       if ($filetoload)
+       {
+               # This is the fastest way to load with regexp that I know
+               while (<GEOIPFILE>){
+                       chomp $_;
+                       s/\r//;
+                       my @record = split(",", $_);
+                       # replace quotes if they were used in the file
+                       foreach (@record){ $_ =~ s/"//g; }
+                       # store in hash
+                       $TmpDomainLookup{$record[0]} = $record[1];
+               }
+               close GEOIPFILE;
+        debug(" Plugin $PluginName: Overload file loaded: ".(scalar keys %TmpDomainLookup)." entries found.");
        }
-       close GEOIPFILE;
        $LoadedOverride = 1;
-       debug(" Plugin $PluginName: Overload file loaded: ".(scalar keys %TmpDomainLookup)." entries found.");
        return;
 }
 
@@ -488,14 +492,15 @@ sub LoadOverrideFile_geoip_org_maxmind{
 sub TmpLookup_geoip_org_maxmind(){
        $param = shift;
        if (!$LoadedOverride){&LoadOverrideFile_geoip_org_maxmind();}
-       my $val;
-       if ($geoip_org_maxmind && 
-       (($type eq 'geoip' && $geoip_org_maxmind->VERSION >= 1.30) || 
-         $type eq 'geoippureperl' && $geoip_org_maxmind->VERSION >= 1.17)){
-               $val = $TmpDomainLookup{$geoip_org_maxmind->get_ip_address($param)};
-       }
-    else {$val = $TmpDomainLookup{$param};}
-    return $val || '';
+       #my $val;
+       #if ($geoip_org_maxmind && 
+       #(($type eq 'geoip' && $geoip_org_maxmind->VERSION >= 1.30) || 
+       #  $type eq 'geoippureperl' && $geoip_org_maxmind->VERSION >= 1.17)){
+       #       $val = $TmpDomainLookup{$geoip_org_maxmind->get_ip_address($param)};
+       #}
+    #else {$val = $TmpDomainLookup{$param};}
+    #return $val || '';
+    return $TmpDomainLookup{$param};
 }
 
 1;     # Do not remove this line
index 4f7004270a64e386b28f7ec958376e2671c5e98e..214af5f2ed26e980ff84b871dd15594486206796 100755 (executable)
@@ -154,7 +154,8 @@ sub Init_geoip_region_maxmind {
        # <-----
        # ENTER HERE CODE TO DO INIT PLUGIN ACTIONS
        debug(" Plugin $PluginName: InitParams=$InitParams",1);
-       my ($mode,$datafile,$override)=split(/\s+/,$InitParams,3);
+    my ($mode,$tmpdatafile)=split(/\s+/,$InitParams,2);
+    my ($datafile,$override)=split(/\+/,$tmpdatafile,2);
        if (! $datafile) { $datafile="GeoIPRegion.dat"; }
        else { $datafile =~ s/%20/ /g; }
        if ($type eq 'geoippureperl') {
@@ -614,25 +615,28 @@ sub LoadOverrideFile_geoip_region_maxmind{
                my $conf = (exists(&Get_Config_Name) ? Get_Config_Name() : $SiteConfig);
                if ($conf && open(GEOIPFILE,"$DirData/$PluginName.$conf.txt"))  { $filetoload="$DirData/$PluginName.$conf.txt"; }
                elsif (open(GEOIPFILE,"$DirData/$PluginName.txt"))      { $filetoload="$DirData/$PluginName.txt"; }
-               else { debug("Did not find $PluginName file \"$DirData/$PluginName.txt\": $!"); }
+               else { debug("No override file \"$DirData/$PluginName.txt\": $!"); }
        }
-       # This is the fastest way to load with regexp that I know
-       while (<GEOIPFILE>){
-               chomp $_;
-               s/\r//;
-               my @record = split(",", $_);
-               # replace quotes if they were used in the file
-               foreach (@record){ $_ =~ s/"//g; }
-               # now we need to copy our file values in the order to mimic the lookup values
-               my @res = ();
-               $res[0] = $record[1];   # country code
-               $res[1] = $record[2];   # region code
-               # store in hash
-               $TmpDomainLookup{$record[0]} = [@res];
+       if ($filetoload)
+       {
+               # This is the fastest way to load with regexp that I know
+               while (<GEOIPFILE>){
+                       chomp $_;
+                       s/\r//;
+                       my @record = split(",", $_);
+                       # replace quotes if they were used in the file
+                       foreach (@record){ $_ =~ s/"//g; }
+                       # now we need to copy our file values in the order to mimic the lookup values
+                       my @res = ();
+                       $res[0] = $record[1];   # country code
+                       $res[1] = $record[2];   # region code
+                       # store in hash
+                       $TmpDomainLookup{$record[0]} = [@res];
+               }
+               close GEOIPFILE;
+        debug(" Plugin $PluginName: Overload file loaded: ".(scalar keys %TmpDomainLookup)." entries found.");
        }
-       close GEOIPFILE;
        $LoadedOverride = 1;
-       debug(" Plugin $PluginName: Overload file loaded: ".(scalar keys %TmpDomainLookup)." entries found.");
        return;
 }
 
@@ -644,14 +648,15 @@ sub LoadOverrideFile_geoip_region_maxmind{
 sub TmpLookup_geoip_region_maxmind(){
        $param = shift;
        if (!$LoadedOverride){&LoadOverrideFile_geoip_region_maxmind();}
-       my @val = ();
-       if ($geoip_region_maxmind &&
-       (($type eq 'geoip' && $geoip_region_maxmind->VERSION >= 1.30) || 
-         $type eq 'geoippureperl' && $geoip_region_maxmind->VERSION >= 1.17)){
-               @val = @{$TmpDomainLookup{$geoip_region_maxmind->get_ip_address($param)}};
-       }
-    else {@val = @{$TmpDomainLookup{$param};}}
-    return @val;
+       #my @val = ();
+       #if ($geoip_region_maxmind &&
+       #(($type eq 'geoip' && $geoip_region_maxmind->VERSION >= 1.30) || 
+       #  $type eq 'geoippureperl' && $geoip_region_maxmind->VERSION >= 1.17)){
+       #       @val = @{$TmpDomainLookup{$geoip_region_maxmind->get_ip_address($param)}};
+       #}
+    #else {@val = @{$TmpDomainLookup{$param};}}
+    #return @val;
+    return @{$TmpDomainLookup{$param};}||'';
 }
 
 1;     # Do not remove this line