) {
chomp $_; s/\r//; $countlines++;
- # Analyze config line
+ # Extract version for first line
if (! $versionnum && $_ =~ /^AWSTATS DATA FILE (\d+).(\d+)/i) {
$versionnum=($1*1000)+$2;
if ($Debug) { debug(" Data file version is $versionnum",1); }
+ # Show migrate warning
if ($versionnum < 5000 && ! $MigrateStats) {
- warning("Warning: Data file '$historyfilename' is an old format history file. You should upgrade it running awstats.pl -migrate=\"$historyfilename\" from command line.");
+ warning("Warning: Data file '$historyfilename' is an old format history file. You should upgrade it running\n$PROG.$Extension -migrate=\"$historyfilename\" -config=$SiteConfig\nfrom command line.");
}
if (! ($versionnum < 5000) && $MigrateStats) {
- close(HISTORYTMP); close(HISTORY);
- unlink("$historytmpfilename");
- error("Error: You try to migrate a file that is already a recent version.","","",1);
+ warning("Warning: You are migrating a file that is already a recent version (migrate not required for version $1.$2).","","",1);
}
next;
}
+ # Analyze fields
@field=split(/\s+/,$_);
if (! $field[0]) { next; }
@@ -3335,12 +3335,14 @@ sub MinimumButNoZero {
# Return: @keylist response array
#--------------------------------------------------------------------
sub BuildKeyList {
+# my $ArraySize=shift||error("Error: System error. Call to BuildKeyList function with incorrect value for first param","","",1);
+# my $MinValue=shift||error("Error: System error. Call to BuildKeyList function with incorrect value for second param","","",1);
my $ArraySize=shift;
my $MinValue=shift;
my $hashforselect=shift;
my $hashfororder=shift;
if ($Debug) { debug(" BuildKeyList($ArraySize,$MinValue,$hashforselect with size=".(scalar keys %$hashforselect).",$hashfororder with size=".(scalar keys %$hashfororder).")",2); }
- delete $hashforselect->{0};delete $hashforselect->{""}; # Those is to protect from infinite loop when hash array has incorrect keys
+ delete $hashforselect->{0};delete $hashforselect->{""}; # Those is to protect from infinite loop when hash array has an incorrect null key
my $count=0;
$lowerval=0; # Global because used in AddInTree and Removelowerval
%val=(); %nextval=(); %egal=();
@@ -3508,29 +3510,6 @@ if ($Debug) {
debug("QUERY_STRING=$QueryString",2);
}
-#------------------------------------------
-# MIGRATE PROCESS
-#------------------------------------------
-if ($MigrateStats) {
- if ($Debug) { debug("MigrateStats is $MigrateStats",2); }
- $MigrateStats =~ s/^(-|)migrate=//;
- $MigrateStats =~ /^(.*)$PROG(\d{0,2})(\d\d)(\d\d\d\d)(.*)\.txt$/;
- $DirData=$1;
- $DayRequired=$2;
- $MonthRequired=$3;
- $YearRequired=$4;
- $FileSuffix=$5;
- print "Start migration for file '$MigrateStats'.\n";
- if (! -s $MigrateStats) { error("Error: File to migrate '$MigrateStats' not found.","","",1); }
- my $historytmpfilename=&Read_History_With_Update($YearRequired,$MonthRequired,1,0,"all");
- if (rename($historytmpfilename,$MigrateStats)==0) {
- unlink "$historytmpfilename";
- error("Error: Failed to rename \"$historytmpfilename\" into \"$MigrateStats\".\nWrite permissions on \"$MigrateStats\" might be wrong".($ENV{"GATEWAY_INTERFACE"}?" for a 'migration from web'":"")." or file might be opened.");
- }
- print "Migration for file '$MigrateStats' done.\n";
- exit 0;
-}
-
# Force SiteConfig if AWSTATS_CONFIG is defined
if ($ENV{"AWSTATS_CONFIG"}) {
if ($Debug) { debug("AWSTATS_CONFIG parameter is defined '".$ENV{"AWSTATS_CONFIG"}."'. $PROG will use it as config value."); }
@@ -3750,6 +3729,29 @@ if (($UpdateStats || $MigrateStats) && (! $AllowToUpdateStatsFromBrowser) && $EN
error("Error: Update of statistics is not allowed from a browser.");
}
+#------------------------------------------
+# MIGRATE PROCESS (Must be after reading config cause we need MaxNbOf... and Min...)
+#------------------------------------------
+if ($MigrateStats) {
+ if ($Debug) { debug("MigrateStats is $MigrateStats",2); }
+ $MigrateStats =~ s/^(-|)migrate=//;
+ $MigrateStats =~ /^(.*)$PROG(\d{0,2})(\d\d)(\d\d\d\d)(.*)\.txt$/;
+ $DirData=$1;
+ $DayRequired=$2;
+ $MonthRequired=$3;
+ $YearRequired=$4;
+ $FileSuffix=$5;
+ print "Start migration for file '$MigrateStats'.\n";
+ if (! -s $MigrateStats) { error("Error: File to migrate '$MigrateStats' not found.","","",1); }
+ my $historytmpfilename=&Read_History_With_Update($YearRequired,$MonthRequired,1,0,"all");
+ if (rename($historytmpfilename,$MigrateStats)==0) {
+ unlink "$historytmpfilename";
+ error("Error: Failed to rename \"$historytmpfilename\" into \"$MigrateStats\".\nWrite permissions on \"$MigrateStats\" might be wrong".($ENV{"GATEWAY_INTERFACE"}?" for a 'migration from web'":"")." or file might be opened.");
+ }
+ print "Migration for file '$MigrateStats' done.\n";
+ exit 0;
+}
+
# Output main frame page and exit. This must be after the security check.
if ($FrameName eq "index") {
# Define the NewLinkParams for main chart
@@ -6324,7 +6326,6 @@ EOF
if ($ShowHostsStats) {
if ($Debug) { debug("ShowHostsStats",2); }
print "$Center
\n";
- $MaxNbOfHostsShown = (scalar keys %_host_h) if $MaxNbOfHostsShown > (scalar keys %_host_h);
&tab_head("$Message[81] ($Message[77] $MaxNbOfHostsShown) - $Message[80] - $Message[9] - $Message[45]",19);
if ($MonthRequired ne "year") { print "| $Message[81] : $TotalHostsKnown $Message[82], $TotalHostsUnknown $Message[1] - $TotalUnique $Message[11] | "; }
else { print "
|---|
| $Message[81] : ".(scalar keys %_host_h)." | "; }
@@ -6455,7 +6456,6 @@ EOF
if ($ShowPagesStats) {
if ($Debug) { debug("ShowPagesStats (MaxNbOfPageShown=$MaxNbOfPageShown TotalDifferentPages=$TotalDifferentPages)",2); }
print "$Center
\n";
- $MaxNbOfPageShown = $TotalDifferentPages if $MaxNbOfPageShown > $TotalDifferentPages;
&tab_head("$Message[19] ($Message[77] $MaxNbOfPageShown) - $Message[80] - $Message[104] - $Message[116]",19);
print "
|---|
| $TotalDifferentPages $Message[28] | ";
print "$Message[29] | ";
@@ -6721,7 +6721,6 @@ EOF
# By Keyphrases
if ($ShowKeyphrasesStats && $ShowKeywordsStats) { print "\n"; }
if ($Debug) { debug("ShowKeyphrasesStats",2); }
- $MaxNbOfKeyphrasesShown = $TotalDifferentKeyphrases if $MaxNbOfKeyphrasesShown > $TotalDifferentKeyphrases;
&tab_head("$Message[120] ($Message[77] $MaxNbOfKeyphrasesShown) $Message[80]",19,($ShowKeyphrasesStats && $ShowKeywordsStats)?95:70);
print " |
|---|
| $TotalDifferentKeyphrases $Message[103] | $Message[14] | $Message[15] |
\n";
$total_s=0;
@@ -6749,7 +6748,6 @@ EOF
# By Keywords
if ($ShowKeyphrasesStats && $ShowKeywordsStats) { print "\n"; }
if ($Debug) { debug("ShowKeywordsStats",2); }
- $MaxNbOfKeywordsShown = $TotalDifferentKeywords if $MaxNbOfKeywordsShown > $TotalDifferentKeywords;
&tab_head("$Message[121] ($Message[77] $MaxNbOfKeywordsShown) $Message[80]",19,($ShowKeyphrasesStats && $ShowKeywordsStats)?95:70);
print " | | $TotalDifferentKeywords $Message[13] | $Message[14] | $Message[15] |
\n";
$total_s=0;