%MonthBytes = %MonthHits = %MonthHostsKnown = %MonthHostsUnknown = %MonthPages = %MonthUnique = %MonthVisits =
%monthlib = %monthnum = ();
-$VERSION="3.2 (build 37)";
+$VERSION="3.2 (build 40)";
$Lang="en";
# Default value
my $month=sprintf("%02i",shift);
my $part=shift;
&debug("Call to Read_History_File [$year,$month,$part] ($DayRequired)"); # In standard use of AWStats, the DayRequired variable is always empty
- if ($HistoryFileAlreadyRead{"$year$month$DayRequired"}) { return 0; } # Protect code to invoke function only once for each month/year
+ if ($HistoryFileAlreadyRead{"$year$month$DayRequired"}) { # Protect code to invoke function only once for each month/year
+ &debug(" Already loaded");
+ return 0;
+ }
$HistoryFileAlreadyRead{"$year$month$DayRequired"}=1; # Protect code to invoke function only once for each month/year
if (! -s "$DirData/$PROG$DayRequired$month$year$FileSuffix.txt") {
# If file not exists, return
chomp $_; s/\r//;
if ($_ eq "") { error("Error: History file \"$DirData/$PROG$month$year$FileSuffix.txt\" is corrupted (in section VISITOR). Last line read is number $countlines.\nRestore a recent backup of this file, or remove it (data for this month will be lost)."); }
my @field=split(/\s+/,$_); $countlines++;
+ my $count=0;
while ($field[0] ne "END_VISITOR") {
+ $count++;
if ($field[0] ne "Unknown") { if ($field[1] > 0) { $MonthUnique{$year.$month}++; } $MonthHostsKnown{$year.$month}++; }
- if ($part && ($QueryString !~ /output=/i || $QueryString =~ /output=lasthosts/i)) {
+ if ($part && ($UpdateStats || $QueryString !~ /output=/i || $QueryString =~ /output=lasthosts/i)) {
if ($field[1] > 0) { $_hostmachine_p{$field[0]}+=$field[1]; }
if ($field[2] > 0) { $_hostmachine_h{$field[0]}+=$field[2]; }
if ($field[3] > 0) { $_hostmachine_k{$field[0]}+=$field[3]; }
if ($_ eq "") { error("Error: History file \"$DirData/$PROG$month$year$FileSuffix.txt\" is corrupted (in section VISITOR). Last line read is number $countlines.\nRestore a recent backup of this file, or remove it (data for this month will be lost)."); }
@field=split(/\s+/,$_); $countlines++;
}
- &debug(" End of VISITOR section");
+ &debug(" End of VISITOR section ($count entries)");
next;
}
if ($field[0] eq "BEGIN_UNKNOWNIP") {
my $count=0;
while ($field[0] ne "END_LOGIN") {
$count++;
- if ($part) {
+ if ($part && ($UpdateStats || $QueryString !~ /output=/i)) {
if ($field[1] > 0) { $_login_p{$field[0]}+=$field[1]; }
if ($field[2] > 0) { $_login_h{$field[0]}+=$field[2]; }
if ($field[3] > 0) { $_login_k{$field[0]}+=$field[3]; }
chomp $_; s/\r//;
if ($_ eq "") { error("Error: History file \"$DirData/$PROG$month$year$FileSuffix.txt\" is corrupted (in section TIME). Last line read is number $countlines.\nRestore a recent backup of this file, or remove it (data for this month will be lost)."); }
my @field=split(/\s+/,$_); $countlines++;
+ my $count=0;
while ($field[0] ne "END_TIME") {
+ $count++;
$MonthPages{$year.$month}+=$field[1]; $MonthHits{$year.$month}+=$field[2]; $MonthBytes{$year.$month}+=$field[3];
- if ($part) {
+ if ($part && ($UpdateStats || $QueryString !~ /output=/i)) {
$_time_p[$field[0]]+=$field[1];
$_time_h[$field[0]]+=$field[2];
$_time_k[$field[0]]+=$field[3];
if ($_ eq "") { error("Error: History file \"$DirData/$PROG$month$year$FileSuffix.txt\" is corrupted (in section TIME). Last line read is number $countlines.\nRestore a recent backup of this file, or remove it (data for this month will be lost)."); }
@field=split(/\s+/,$_); $countlines++;
}
- &debug(" End of TIME section");
+ &debug(" End of TIME section ($count entries)");
next;
}
if ($field[0] eq "BEGIN_DAY") {
chomp $_; s/\r//;
if ($_ eq "") { error("Error: History file \"$DirData/$PROG$month$year$FileSuffix.txt\" is corrupted (in section DAY). Last line read is number $countlines.\nRestore a recent backup of this file, or remove it (data for this month will be lost)."); }
my @field=split(/\s+/,$_); $countlines++;
+ my $count=0;
while ($field[0] ne "END_DAY" ) {
- if ($QueryString !~ /output=/i) {
+ $count++;
+ if ($UpdateStats || $QueryString !~ /output=/i) {
$DayPages{$field[0]}=int($field[1]); $DayHits{$field[0]}=int($field[2]); $DayBytes{$field[0]}=int($field[3]); $DayVisits{$field[0]}=int($field[4]); $DayUnique{$field[0]}=int($field[5]);
}
$_=<HISTORY>;
if ($_ eq "") { error("Error: History file \"$DirData/$PROG$month$year$FileSuffix.txt\" is corrupted (in section DAY). Last line read is number $countlines.\nRestore a recent backup of this file, or remove it (data for this month will be lost)."); }
@field=split(/\s+/,$_); $countlines++;
}
- &debug(" End of DAY section");
+ &debug(" End of DAY section ($count entries)");
next;
}
if ($field[0] eq "BEGIN_SIDER") {
$count++;
if ($part) {
my $addsider=0;
- if ($UpdateStats) { $addsider=1; }
- if (!$UpdateStats) {
+ if ($UpdateStats) {
+ $addsider=1;
+ }
+ else {
# In this case we count TotalDifferentPages because we won't fill _url_p completely
$TotalDifferentPages++;
- if ($HTMLOutput && $QueryString =~ /output=urldetail/i && (!$URLFilter || $field[0] =~ /$URLFilter/)) { $addsider=1; }
- if ($HTMLOutput && $QueryString !~ /output=/i && $countadd < $MaxNbOfPageShown) { $addsider=1; }
+ if ($QueryString =~ /output=urldetail/i && (!$URLFilter || $field[0] =~ /$URLFilter/)) { $addsider=1; }
+ if ($QueryString !~ /output=/i && $countadd < $MaxNbOfPageShown) { $addsider=1; }
}
if ($addsider) {
$countadd++;
my $count=0;
while ($field[0] ne "END_PAGEREFS") {
$count++;
- if ($part) {
+ if ($part && ($UpdateStats || $QueryString !~ /output=/i)) {
$_pagesrefs_h{$field[0]}+=$field[1];
}
$_=<HISTORY>;
my $count=0;
while ($field[0] ne "END_FILETYPES") {
$count++;
- if ($part) {
+ if ($part && ($UpdateStats || $QueryString !~ /output=/i)) {
$_filetypes_h{$field[0]}+=$field[1];
$_filetypes_k{$field[0]}+=$field[2];
$_filetypes_gz_in{$field[0]}+=$field[3];
my $count=0;
while ($field[0] ne "END_SEARCHWORDS") {
$count++;
- if ($part) {
+ if ($part && ($UpdateStats || $QueryString !~ /output=/i)) {
$_keyphrases{$field[0]}+=$field[1];
}
$_=<HISTORY>;
my $count=0;
while ($field[0] ne "END_SIDER_404") {
$count++;
- if ($part) {
+ if ($part && ($UpdateStats || $QueryString !~ /output=/i || $QueryString =~ /output=notfounderror/i)) {
$_sider404_h{$field[0]}+=$field[1];
if ($UpdateStats || $QueryString =~ /output=notfounderror/i) {
$_referer404_h{$field[0]}=$field[2];
$total_p=$total_h=$total_k=0;
$count=0;
foreach my $key (sort { $SortDir*$_hostmachine_p{$a} <=> $SortDir*$_hostmachine_p{$b} } keys (%_hostmachine_p)) {
- if ($count>=MaxNbOfHostsShown) { last; }
+ if ($count>=$MaxNbOfHostsShown) { last; }
if ($_hostmachine_h{$key}<$MinHitHost) { last; }
if ($key eq "Unknown") {
print "<TR><TD CLASS=AWL><a href=\"$DirCgi$PROG.$Extension?${LinkParamB}output=unknownip\">$Message[1]</a></TD><TD>$_hostmachine_p{$key}</TD><TD>$_hostmachine_h{$key}</TD><TD>".Format_Bytes($_hostmachine_k{$key})."</TD><TD><a href=\"$DirCgi$PROG.$Extension?${LinkParamB}output=unknownip\">$Message[3]</a></TD></TR>\n";