]> git.ipfire.org Git - thirdparty/AWStats.git/commitdiff
Added patch 857319: Allow AllowAccessFromWebToFollowingIPAddresses.
authoreldy <>
Fri, 12 Dec 2003 18:32:47 +0000 (18:32 +0000)
committereldy <>
Fri, 12 Dec 2003 18:32:47 +0000 (18:32 +0000)
Fixed pb in loading plugins with mod_perl2.

wwwroot/cgi-bin/awstats.model.conf
wwwroot/cgi-bin/awstats.pl

index b31d3bda2e6abb38d348f7fef66b2c1f391698dc..721122d7213e86a4bad11ededf7e833f4c4e960c 100644 (file)
@@ -333,9 +333,9 @@ AllowAccessFromWebToFollowingAuthenticatedUsers=""
 
 # When this parameter is define to something, the IP address of the user that
 # read its statistics from a browser (when AWStats is used as a CGI) is
-# checked and must match the IP address range defined by this parameter.
+# checked and must match one of the IP address values or ranges.
 # Change : Effective immediatly
-# Example: "123.123.123.10-123.123.123.255"
+# Example: "127.0.0.1 123.123.123.1-123.123.123.255"
 # Default: ""
 #
 AllowAccessFromWebToFollowingIPAddresses=""
index 560b5a19861761a84d5f1ce57e56a0f1fd336d03..0fb84de8a5e239d05b9880c8c0e57cf8fbfa3302 100644 (file)
@@ -1786,10 +1786,11 @@ sub Read_Plugins {
                                                        push @INC, "$dir";
                                                        $DirAddedInINC{"$dir"}=1;
                                                }
-                                               #my $loadret=require "$pluginpath";     # Can fix pb with mod_perl2. Give other pb ?
-                                               #my $loadret=do "${pluginfile}.pm";     # Can fix pb with mod_perl2 but might slow since module is recompiled each time.
-                                               my $loadret=require "${pluginfile}.pm";
-
+                                               my $loadret=0;\r
+                                               my $modperl=$ENV{"MOD_PERL"}? eval { require mod_perl; $mod_perl::VERSION >= 1.99 ? 2 : 1 } : 0;
+                                               if ($modperl == 2) { $loadret=require "$pluginpath"; }
+                                               else { $loadret=require "$pluginfile.pm"; }\r
+       
                                                if (! $loadret || $loadret =~ /^error/i) {
                                                        # Load failed, we stop here
                                                        error("Plugin load for plugin '$pluginname' failed with return code: $loadret");
@@ -5359,7 +5360,10 @@ if ($FrameName ne 'index') {
 $NBOFLINESFORBENCHMARK--;
 if ($ENV{'GATEWAY_INTERFACE'}) { $DirCgi=''; }
 if ($DirCgi && !($DirCgi =~ /\/$/) && !($DirCgi =~ /\\$/)) { $DirCgi .= '/'; }
-if (! $DirData || $DirData eq '.') { $DirData="$DIR"; }        # If not defined or chosen to '.' value then DirData is current dir
+if (! $DirData || $DirData =~ /^\./) {\r
+     if (! $DirData || $DirData eq '.') { $DirData="$DIR"; }      # If not defined or chosen to '.' value then DirData is current dir\r
+     elsif ($DIR && $DIR ne '.') { $DirData="$DIR/$DirData"; }
+}\r
 $DirData||='.';                # If current dir not defined then we put it to '.'
 $DirData =~ s/\/$//; $DirData =~ s/\\$//;
 # Define SiteToAnalyze and SiteToAnalyzeWithoutwww for regex operations
@@ -5402,13 +5406,22 @@ if ($AllowAccessFromWebToAuthenticatedUsersOnly && $ENV{'GATEWAY_INTERFACE'}) {
        }
 }
 if ($AllowAccessFromWebToFollowingIPAddresses && $ENV{'GATEWAY_INTERFACE'}) {
-       if ($AllowAccessFromWebToFollowingIPAddresses   !~ /^(\d+\.\d+\.\d+\.\d+)-(\d+\.\d+\.\d+\.\d+)$/) {
-               error("AllowAccessFromWebToFollowingIPAddresses is defined to '$AllowAccessFromWebToFollowingIPAddresses' but does not match the correct syntax: IPAddressMin-IPAddressMax");
-       }
-       my $ipmin=&Convert_IP_To_Decimal($1);
-       my $ipmax=&Convert_IP_To_Decimal($2);
        my $useripaddress=&Convert_IP_To_Decimal($ENV{"REMOTE_ADDR"});
-       if ($useripaddress < $ipmin || $useripaddress > $ipmax) {
+       my @allowaccessfromipaddresses = split (/[\s,]+/, $AllowAccessFromWebToFollowingIPAddresses);
+       my $allowaccess = 0;
+       foreach my $ipaddressrange (@allowaccessfromipaddresses) {
+           if ($ipaddressrange !~ /^(\d+\.\d+\.\d+\.\d+)(?:-(\d+\.\d+\.\d+\.\d+))*$/) {
+                       error("AllowAccessFromWebToFollowingIPAddresses is defined to '$AllowAccessFromWebToFollowingIPAddresses' but does not match the correct syntax: IPAddressMin[-IPAddressMax]");
+               }
+               my $ipmin=&Convert_IP_To_Decimal($1);
+               my $ipmax=$2?&Convert_IP_To_Decimal($2):$ipmin;
+               # Is it an authorized ip ?
+               if (($useripaddress >= $ipmin) && ($useripaddress <= $ipmax)) {
+                       $allowaccess = 1;
+                       last;
+               }
+       }
+    if (! $allowaccess) {
                error("Access to statistics is not allowed from your IP Address ".$ENV{"REMOTE_ADDR"});
        }
 }