|
|
my $configdir=shift; | my $configdir=shift; |
my @PossibleConfigDir=(); | my @PossibleConfigDir=(); |
| |
if ($configdir) { @PossibleConfigDir=("$configdir"); } |
if ($configdir && $ENV{"AWSTATS_ENABLE_CONFIG_DIR"}) { @PossibleConfigDir=("$configdir"); } |
else { @PossibleConfigDir=("$DIR","/etc/awstats","/usr/local/etc/awstats","/etc","/etc/opt/awstats"); } | else { @PossibleConfigDir=("$DIR","/etc/awstats","/usr/local/etc/awstats","/etc","/etc/opt/awstats"); } |
| |
# Open config file | # Open config file |
|
|
$QueryString =~ s/&/&/g; | $QueryString =~ s/&/&/g; |
} | } |
| |
$QueryString = CleanFromCSSA($QueryString); |
$QueryString = CleanFromCSSA(&DecodeEncodedString($QueryString)); |
| |
# Security test | # Security test |
if ($QueryString =~ /LogFile=([^&]+)/i) { error("Logfile parameter can't be overwritten when AWStats is used from a CGI"); } | if ($QueryString =~ /LogFile=([^&]+)/i) { error("Logfile parameter can't be overwritten when AWStats is used from a CGI"); } |
|
|
# No update but report by default when run from a browser | # No update but report by default when run from a browser |
$UpdateStats=($QueryString=~/update=1/i?1:0); | $UpdateStats=($QueryString=~/update=1/i?1:0); |
| |
if ($QueryString =~ /config=([^&]+)/i) { $SiteConfig=&DecodeEncodedString("$1"); } |
if ($QueryString =~ /config=([^&]+)/i) { $SiteConfig=&Sanitize(&DecodeEncodedString("$1")); } |
if ($QueryString =~ /diricons=([^&]+)/i) { $DirIcons=&DecodeEncodedString("$1"); } | if ($QueryString =~ /diricons=([^&]+)/i) { $DirIcons=&DecodeEncodedString("$1"); } |
if ($QueryString =~ /pluginmode=([^&]+)/i) { $PluginMode=&Sanitize(&DecodeEncodedString("$1"),1); } | if ($QueryString =~ /pluginmode=([^&]+)/i) { $PluginMode=&Sanitize(&DecodeEncodedString("$1"),1); } |
if ($QueryString =~ /configdir=([^&]+)/i) { $DirConfig=&Sanitize(&DecodeEncodedString("$1")); } | if ($QueryString =~ /configdir=([^&]+)/i) { $DirConfig=&Sanitize(&DecodeEncodedString("$1")); } |
|
|
| |
# If migrate | # If migrate |
if ($QueryString =~ /(^|-|&|&)migrate=([^&]+)/i) { | if ($QueryString =~ /(^|-|&|&)migrate=([^&]+)/i) { |
$MigrateStats=&DecodeEncodedString("$2"); |
$MigrateStats=&Sanitize(&DecodeEncodedString("$2")); |
$MigrateStats =~ /^(.*)$PROG(\d{0,2})(\d\d)(\d\d\d\d)(.*)\.txt$/; | $MigrateStats =~ /^(.*)$PROG(\d{0,2})(\d\d)(\d\d\d\d)(.*)\.txt$/; |
$SiteConfig=$5?$5:'xxx'; $SiteConfig =~ s/^\.//; # SiteConfig is used to find config file | $SiteConfig=$5?$5:'xxx'; $SiteConfig =~ s/^\.//; # SiteConfig is used to find config file |
} | } |
|
|
# Update with no report by default when run from command line | # Update with no report by default when run from command line |
$UpdateStats=1; | $UpdateStats=1; |
| |
if ($QueryString =~ /config=([^&]+)/i) { $SiteConfig="$1"; } |
if ($QueryString =~ /config=([^&]+)/i) { $SiteConfig=&Sanitize("$1"); } |
if ($QueryString =~ /diricons=([^&]+)/i) { $DirIcons="$1"; } | if ($QueryString =~ /diricons=([^&]+)/i) { $DirIcons="$1"; } |
if ($QueryString =~ /pluginmode=([^&]+)/i) { $PluginMode=&Sanitize("$1",1); } | if ($QueryString =~ /pluginmode=([^&]+)/i) { $PluginMode=&Sanitize("$1",1); } |
if ($QueryString =~ /configdir=([^&]+)/i) { $DirConfig=&Sanitize("$1"); } | if ($QueryString =~ /configdir=([^&]+)/i) { $DirConfig=&Sanitize("$1"); } |
|
|
# Return: None | # Return: None |
#------------------------------------------------------------------------------ | #------------------------------------------------------------------------------ |
sub error { | sub error { |
print "Error: $_[0].\n"; |
print STDERR "Error: $_[0].\n"; |
exit 1; | exit 1; |
} | } |
| |
|
|
# print "$messagestring<br />\n"; | # print "$messagestring<br />\n"; |
# } | # } |
# else { | # else { |
print "$messagestring\n"; |
print STDERR "$messagestring\n"; |
# } | # } |
# } | # } |
} | } |
|
|
# error | # error |
#------------------------------------------------------- | #------------------------------------------------------- |
sub error { | sub error { |
print "Error: $_[0].\n"; |
print STDERR "Error: $_[0].\n"; |
exit 1; | exit 1; |
} | } |
| |
|
|
my $thirdmessage=shift||""; | my $thirdmessage=shift||""; |
my $donotshowsetupinfo=shift||0; | my $donotshowsetupinfo=shift||0; |
if ($Debug) { debug("$message $secondmessage $thirdmessage",1); } | if ($Debug) { debug("$message $secondmessage $thirdmessage",1); } |
print "$message"; |
print STDERR "$message"; |
print "\n"; |
print STDERR "\n"; |
exit 1; | exit 1; |
} | } |
| |
|
|
# Return: None | # Return: None |
#------------------------------------------------------------------------------ | #------------------------------------------------------------------------------ |
sub error { | sub error { |
print "Error: $_[0].\n"; |
print STDERR "Error: $_[0].\n"; |
exit 1; | exit 1; |
} | } |
| |
|
|
# Return: None | # Return: None |
#------------------------------------------------------------------------------ | #------------------------------------------------------------------------------ |
sub error { | sub error { |
print "Error: $_[0].\n"; |
print STDERR "Error: $_[0].\n"; |
exit 1; | exit 1; |
} | } |
| |
|
|
sub warning { | sub warning { |
my $messagestring=shift; | my $messagestring=shift; |
if ($Debug) { debug("$messagestring",1); } | if ($Debug) { debug("$messagestring",1); } |
print "$messagestring\n"; |
print STDERR "$messagestring\n"; |
} | } |
| |
#----------------------------------------------------------------------------- | #----------------------------------------------------------------------------- |
|
|
#------------------------------------------------------- | #------------------------------------------------------- |
| |
sub error { | sub error { |
print "Error: $_[0].\n"; |
print STDERR "Error: $_[0].\n"; |
exit 1; | exit 1; |
} | } |
| |