From: eldy <>
Date: Fri, 2 Nov 2001 01:20:35 +0000 (+0000)
Subject: Solve a problem of corrupted history file when log file contains non ascii chars.
X-Git-Tag: AWSTATS_1_0~59
X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a1b3cf3e1d0cd8eeb7cb8dc27c11185e357410f2;p=thirdparty%2FAWStats.git
Solve a problem of corrupted history file when log file contains non ascii chars.
---
diff --git a/wwwroot/cgi-bin/awstats.pl b/wwwroot/cgi-bin/awstats.pl
index 41fe4903..156acaf5 100644
--- a/wwwroot/cgi-bin/awstats.pl
+++ b/wwwroot/cgi-bin/awstats.pl
@@ -82,7 +82,7 @@ $WarningMessages= 1;
%MonthBytes = %MonthHits = %MonthHostsKnown = %MonthHostsUnknown = %MonthPages = %MonthUnique = %MonthVisits =
%monthlib = %monthnum = ();
-$VERSION="3.2 (build 36)";
+$VERSION="3.2 (build 37)";
$Lang="en";
# Default value
@@ -252,64 +252,77 @@ sub tab_end {
}
sub UnescapeURLParam {
- $_[0] =~ tr/\+/ /s;
+ $_[0] =~ tr/\+\'\(\)\",/ /s; # "&" and "=" must not be in this list
$_[0] =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg; # Decode encoded URL
- $_[0] =~ tr/\'\(\)\"/ /s; # "&" and "=" must not be in this list
}
sub error {
- if ($_[0] eq "Format error") {
+ my $message=shift;
+ my $secondmessage=shift;
+ my $thirdmessage=shift;
+
+ if ($message =~ /^Format error$/) {
# Files seems to have bad format
+ if ($HTMLOutput) { print "
\n"; }
print "AWStats did not found any valid log lines that match your LogFormat parameter, in the ${NbOfLinesForCorruptedLog}th first non commented lines read of your log.
\n";
- print "Your log file $_[2] must have a bad format or LogFormat parameter setup does not match this format.
\n";
+ print "Your log file $thirdmessage must have a bad format or LogFormat parameter setup does not match this format.
\n";
print "Your LogFormat parameter is $LogFormat, this means each line in your log file need to have ";
if ($LogFormat == 1) {
print "\"combined log format\" like this:
\n";
- print "111.22.33.44 - - [10/Jan/2001:02:14:14 +0200] \"GET / HTTP/1.1\" 200 1234 \"http://www.fromserver.com/from.htm\" \"Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)\"
\n";
+ print ($HTMLOutput?"":"");
+ print "111.22.33.44 - - [10/Jan/2001:02:14:14 +0200] \"GET / HTTP/1.1\" 200 1234 \"http://www.fromserver.com/from.htm\" \"Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)\"\n";
+ print ($HTMLOutput?"
":"");
}
if ($LogFormat == 2) {
print "\"MSIE Extended W3C log format\" like this:
\n";
- print "date time c-ip c-username cs-method cs-uri-sterm sc-status sc-bytes cs-version cs(User-Agent) cs(Referer)
\n";
+ print ($HTMLOutput?"":"");
+ print "date time c-ip c-username cs-method cs-uri-sterm sc-status sc-bytes cs-version cs(User-Agent) cs(Referer)\n";
+ print ($HTMLOutput?"
":"");
}
if ($LogFormat == 3) {
print "\"WebStar native log format\"
\n";
}
if ($LogFormat == 4) {
print "\"common log format\" like this:
\n";
- print "111.22.33.44 - - [10/Jan/2001:02:14:14 +0200] \"GET / HTTP/1.1\" 200 1234
\n";
+ print ($HTMLOutput?"":"");
+ print "111.22.33.44 - - [10/Jan/2001:02:14:14 +0200] \"GET / HTTP/1.1\" 200 1234\n";
+ print ($HTMLOutput?"
":"");
}
if ($LogFormat != 1 && $LogFormat != 2 && $LogFormat != 3 && $LogFormat != 4) {
print "the following personalised log format:
\n";
- print "$LogFormat
\n";
- }
- print "
";
- print "And this is a sample of what AWStats found in your log (the record number $NbOfLinesForCorruptedLog in your log):
\n";
- print ($ENV{"GATEWAY_INTERFACE"} ne ""?"":"");
- print "$_[1]";
- print ($ENV{"GATEWAY_INTERFACE"} ne ""?"
":"");
- print "\n";
- print "Note: If your $NbOfLinesForCorruptedLog first lines in your log files are wrong because they are ";
- print "result of a worm virus attack, you can increase the NbOfLinesForCorruptedLog parameter in config file.\n";
+ print ($HTMLOutput?"":"");
+ print "$LogFormat\n";
+ print ($HTMLOutput?"
":"");
+ }
+ print "And this is a sample of what AWStats found in your log (the record number $NbOfLinesForCorruptedLog in your log):\n";
+ print ($HTMLOutput?"
":"");
+ print "$secondmessage";
+ print ($HTMLOutput?"
":"");
print "\n";
+ #print "Note: If your $NbOfLinesForCorruptedLog first lines in your log files are wrong because they are ";
+ #print "result of a worm virus attack, you can increase the NbOfLinesForCorruptedLog parameter in config file.\n";
+ #print "\n";
}
- if ($_[0] ne "Format error" && $_[0] ne "") {
- print ($ENV{"GATEWAY_INTERFACE"} ne ""?"
":"");
- print "$_[0]";
- print ($ENV{"GATEWAY_INTERFACE"} ne ""?"
":"");
+ else {
+ print ($HTMLOutput?"
":"");
+ print "$message";
+ print ($HTMLOutput?"
":"");
print "\n";
}
- if ($ENV{"GATEWAY_INTERFACE"} ne "") { print "
\n"; }
- if ($_[0] ne "") { print "Setup ($FileConfig file, web server or logfile permissions) may be wrong.\n"; }
- if ($ENV{"GATEWAY_INTERFACE"} ne "") { print "
\n"; }
- print "See README.TXT for informations on how to setup $PROG.\n";
- if ($ENV{"GATEWAY_INTERFACE"} ne "") { print "