From: eldy <> Date: Mon, 20 Aug 2001 00:16:50 +0000 (+0000) Subject: Reduce amount of memory required for main page. X-Git-Tag: AWSTATS_1_0~174 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=033a98a0029017998f4efd7765a7463f5e237dae;p=thirdparty%2FAWStats.git Reduce amount of memory required for main page. --- diff --git a/wwwroot/cgi-bin/awstats.pl b/wwwroot/cgi-bin/awstats.pl index 21d6f591..4a644f5b 100644 --- a/wwwroot/cgi-bin/awstats.pl +++ b/wwwroot/cgi-bin/awstats.pl @@ -31,7 +31,9 @@ # If required month, read 1st and 2nd part of history file for this month # If not required month, read 1st part of history file for this month # End of loop -# Show data arrays in HTML page +# If 'output' +# Show data arrays in HTML page +# End of 'output' #------------------------------------------------------- #use diagnostics; #use strict; @@ -73,7 +75,6 @@ $total_h, $total_k, $total_p) = (); $VERSION="3.1 (build 20)"; $Lang="en"; -$Sort=""; # Default value $MAXROWS = 200000; # Max number of rows for not limited HTML arrays @@ -85,6 +86,8 @@ $MaxNbOfDays = 31; $NbOfLinesForBenchmark=5000; $NbOfLinesForCorruptedLog=10; #$NbOfLinesForCorruptedLog=10000; # ETF1 +$ShowBackLink = 1; +$Sort = ""; $CENTER = ""; $WIDTH = "600"; # Images for graphics @@ -1214,6 +1217,7 @@ sub Check_Config { if ($Message[76] eq "") { $Message[76]="Back to main page"; } if ($Message[77] eq "") { $Message[77]="Top"; } if ($Message[78] eq "") { $Message[78]="dd mmm yyyy - HH:MM"; } + if ($Message[79] eq "") { $Message[79]="Filter"; } } #-------------------------------------------------------------------- @@ -1241,8 +1245,7 @@ sub Read_History_File { while () { chomp $_; s/\r//; my @field=split(/\s+/,$_); - - # FIRST PART: Always read + # Analyze config line if ($field[0] eq "FirstTime") { $FirstTime{$year.$month}=int($field[1]); next; } if ($field[0] eq "LastTime") { if ($LastTime{$year.$month} < int($field[1])) { $LastTime{$year.$month}=int($field[1]); }; next; } if ($field[0] eq "TotalVisits") { $MonthVisits{$year.$month}=int($field[1]); next; } @@ -1335,31 +1338,42 @@ sub Read_History_File { &debug(" End of DAY section"); next; } + if ($field[0] eq "BEGIN_SIDER") { + &debug(" Begin of SIDER section"); + $_=; + chomp $_; s/\r//; + if ($_ eq "") { error("Error: History file \"$DirData/$PROG$_[1]$_[0]$FileSuffix.txt\" is corrupted. Restore a backup of this file, or remove it (data for this month will be lost)."); } + my @field=split(/\s+/,$_); + my $count=0;my $countadd=0; + while ($field[0] ne "END_SIDER") { + $count++; + if ($part) { + my $addsider=0; + if ($UpdateStats) { $addsider=1; } + if (!$UpdateStats) { + # In this case we count TotalDifferentPages because we don't fill _sider_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 ($addsider) { + $countadd++; + $_sider_p{$field[0]}+=$field[1]; + } + } + $_=; + chomp $_; s/\r//; + if ($_ eq "") { error("Error: History file \"$DirData/$PROG$_[1]$_[0]$FileSuffix.txt\" is corrupted. Restore a backup of this file, or remove it (data for this month will be lost)."); } + @field=split(/\s+/,$_); + } + &debug(" End of SIDER section ($count entries loaded)"); + next; + } # SECOND PART: If $part == 0, it means we don't need this part of data. if ($part) { if ($field[0] eq "BEGIN_DOMAIN") { $readdomain=1; next; } if ($field[0] eq "END_DOMAIN") { $readdomain=0; next; } - if ($field[0] eq "BEGIN_SIDER") { - &debug(" Begin of SIDER section"); - $_=; - chomp $_; s/\r//; - if ($_ eq "") { error("Error: History file \"$DirData/$PROG$_[1]$_[0]$FileSuffix.txt\" is corrupted. Restore a backup of this file, or remove it (data for this month will be lost)."); } - my @field=split(/\s+/,$_); - my $count=0; - while ($field[0] ne "END_SIDER") { - $count++; - if ($UpdateStats || $QueryString !~ /output=/i || ($QueryString =~ /output=urldetail/i && (!$URLFilter || $field[0] =~ /$URLFilter/))) { - $_sider_p{$field[0]}+=$field[1]; - } - $_=; - chomp $_; s/\r//; - if ($_ eq "") { error("Error: History file \"$DirData/$PROG$_[1]$_[0]$FileSuffix.txt\" is corrupted. Restore a backup of this file, or remove it (data for this month will be lost)."); } - @field=split(/\s+/,$_); - } - &debug(" End of SIDER section ($count entries)"); - next; - } if ($field[0] eq "BEGIN_BROWSER") { $readbrowser=1; next; } if ($field[0] eq "END_BROWSER") { $readbrowser=0; next; } if ($field[0] eq "BEGIN_NSVER") { $readnsver=1; next; } @@ -2554,7 +2568,7 @@ EOF print " $Message[22]   $Message[31]
\n"; } else { - print "$Message[76]\n"; + if ($ShowBackLink) { print "$Message[76]\n"; } } print "\n"; print "
\n\n"; @@ -2650,7 +2664,8 @@ EOF if ($QueryString =~ /output=urldetail/i) { print "$CENTER 
"; &tab_head($Message[19]); - print "".(scalar keys %_sider_p)."  $Message[19] ".($URLFilter?"  (Filter: $URLFilter)":"")." $Message[29]  \n"; + if ($URLFilter) { print "$Message[79]: $URLFilter - ".(scalar keys %_sider_p)." $Message[28] $Message[29]  \n"; } + else { print "".(scalar keys %_sider_p)."  $Message[28] $Message[29]  \n"; } my $max_p=1; foreach my $key (values %_sider_p) { if ($key > $max_p) { $max_p = $key; } } my $count=0; my $rest=0; foreach my $key (sort { $SortDir*$_sider_p{$a} <=> $SortDir*$_sider_p{$b} } keys (%_sider_p)) { @@ -2695,8 +2710,8 @@ EOF $TotalHostsKnown+=$MonthHostsKnown{$YearRequired.$monthix}; $TotalHostsUnknown+=$MonthHostsUnknown{$YearRequired.$monthix}; } - # TotalDifferentPages - $TotalDifferentPages=scalar keys %_sider_p; + # TotalDifferentPages (if not already specifically counted, we init it from _sider_p hash table) + if (!$TotalDifferentPages) { $TotalDifferentPages=scalar keys %_sider_p; } # TotalPages TotalHits TotalBytes for (my $ix=0; $ix<=23; $ix++) { $TotalPages+=$_time_p[$ix]; $TotalHits+=$_time_h[$ix]; $TotalBytes+=$_time_k[$ix]; } # TotalErrors