# 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=""
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");
$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
}
}
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"});
}
}