]> git.ipfire.org Git - thirdparty/AWStats.git/commitdiff
New feature: Added full list for refering search engines and refering pages.
authoreldy <>
Tue, 28 May 2002 08:50:25 +0000 (08:50 +0000)
committereldy <>
Tue, 28 May 2002 08:50:25 +0000 (08:50 +0000)
docs/awstats_setup.html
docs/awstats_tools.html
tools/awstats_buildstaticpages.pl
wwwroot/cgi-bin/awstats.pl

index a36748c1a899a31a3c41108818e13ac46bd345e5..0d450d515021e69dd6a1bea9342f83e10c7015a9 100644 (file)
@@ -221,14 +221,17 @@ This is how to use all other possible output options:<br>
 <b><i>awstats.pl -config=virtualhostname -output=unknownip -staticlinks > awstats.virtualhostname.unknownip.html</i></b><br>\r
 <b><i>awstats.pl -config=virtualhostname -output=urldetail -staticlinks > awstats.virtualhostname.urldetail.html</i></b><br>\r
 <b><i>awstats.pl -config=virtualhostname -output=urldetail:</b>filter<b> -staticlinks > awstats.virtualhostname.urldetailfiltered.html</i></b><br>\r
-<b><i>awstats.pl -config=virtualhostname -output=unknownos -staticlinks > awstats.virtualhostname.unknownos.html</i></b><br>\r
-<b><i>awstats.pl -config=virtualhostname -output=unknownbrowsers -staticlinks > awstats.virtualhostname.unknownbrowsers.html</i></b><br>\r
 <b><i>awstats.pl -config=virtualhostname -output=browserdetail -staticlinks > awstats.virtualhostname.browserdetail.html</i></b><br>\r
+<b><i>awstats.pl -config=virtualhostname -output=unknownbrowsers -staticlinks > awstats.virtualhostname.unknownbrowsers.html</i></b><br>\r
+<b><i>awstats.pl -config=virtualhostname -output=unknownos -staticlinks > awstats.virtualhostname.unknownos.html</i></b><br>\r
+<b><i>awstats.pl -config=virtualhostname -output=refererse -staticlinks > awstats.virtualhostname.refererse.html</i></b><br>\r
+<b><i>awstats.pl -config=virtualhostname -output=refererpages -staticlinks > awstats.virtualhostname.refererpages.html</i></b><br>\r
 <b><i>awstats.pl -config=virtualhostname -output=allkeyphrases -staticlinks > awstats.virtualhostname.allkeyphrases.html</i></b><br>\r
+<b><i>awstats.pl -config=virtualhostname -output=allkeywords -staticlinks > awstats.virtualhostname.allkeywords.html</i></b><br>\r
 <b><i>awstats.pl -config=virtualhostname -output=errors404 -staticlinks > awstats.virtualhostname.errors404.html</i></b><br>\r
 <br>\r
-Note: If you prefer, you can use <a href="awstats_tools.html#awstats_buildstaticpages">awstats_buildstaticpages</a> tool to build all those\r
-pages in one command.<br>\r
+Note: If you prefer, you can use <a href="awstats_tools.html#awstats_buildstaticpages">awstats_buildstaticpages</a> tool to\r
+build all those pages in one command.<br>\r
 <br>\r
 * You can also view dynamically your statistics from a browser.<br>\r
 If you named your config file awstats.<i>virtualhostname</i>.conf, use URL:<br>\r
index 75f8d31316545456b13c264dfa84a30a85ce7502..0a8aec2df9b2e8ceb9211b9f7c12e8eea343f608 100644 (file)
@@ -40,16 +40,22 @@ All those tools are available in <b>tools</b> directory of AWStats distribution.
 \r
 <br><a name="awstats_buildstaticpages"><H2 style="font: 22px Times; color: #606060"><u>awstats_buildstaticpages</u></H2></a>\r
 <br>awstats_buildstaticpages allows you to launch AWStats with -staticlinks option to\r
-<br>build all possible pages allowed by option -output.\r
+<br>build all possible pages allowed by AWStats -output option.\r
 <br>\r
 <br>Usage:\r
-<br>  awstats_buildstaticpages.pl -config=configvalue -awstatsprog=pathtoawstatspl [-dir=outputdir] [-date] [-update]\r
-<br>\r
-<br>  where configvalue is value for config option of AWStats software.\r
-<br>        pathtoawstatspl is name of AWStats software with path (awstats.pl).\r
-<br>        outputdir is name of output directory for generated pages.\r
-<br>        -date option is used to add build date in built files name.\r
-<br>        -update option is used to update statistics before generate pages.\r
+<br>  awstats_buildstaticpages.pl (awstats_options) [awstatsbuildstaticpages_options]\r
+<br>\r
+<br>  where awstats_options are any option known by AWStats\r
+<br>   -config=configvalue is value for -config parameter (REQUIRED)\r
+<br>   -update             option used to update statistics before to generate pages\r
+<br>   -lang=LL            to output a HTML report in language LL (en,de,es,fr,...)\r
+<br>   -month=MM           to output a HTML report for an old month=MM\r
+<br>   -year=YYYY          to output a HTML report for an old year=YYYY\r
+<br>\r
+<br>  and awstatsbuildstaticpages_options can be\r
+<br>   -awstatsprog=pathtoawstatspl gives AWStats software (awstats.pl) path\r
+<br>   -dir=outputdir               to set output directory for generated pages\r
+<br>   -date                        used to add build date in built pages file name\r
 <br>\r
 <br>New versions and FAQ at http://awstats.sourceforge.net\r
 <br>\r
index 88960a0ee2435153ad0d076dffc330476c127220..b6996d2d7d077ab192c1913a84278e4ab018bdc6 100644 (file)
@@ -37,6 +37,13 @@ my $Awstats="awstats.pl";
 my $OutputDir="";
 my $OutputSuffix;
 my $OutputFile;
+my @OutputList=(
+"allhosts","lasthosts","unknownip","urldetail",
+"unknownos","unknownbrowser","browserdetail",
+"refererse","refererpages",
+#"referersites",
+"allkeyphrases","allkeywords","errors404"
+);
 
 
 #-------------------------------------------------------
@@ -93,19 +100,22 @@ if ($OutputDir) { if ($OutputDir !~ /[\\\/]$/) { $OutputDir.="/"; } }
 if (! $Config) {
        print "----- $PROG $VERSION (c) Laurent Destailleur -----\n";
        print "$PROG allows you to launch AWStats with -staticlinks option to\n";
-       print "build all possible pages allowed by option -output.\n";
+       print "build all possible pages allowed by AWStats -output option.\n";
        print "\n";
        print "Usage:\n";
-       print "  $PROG.$Extension -config=configvalue -awstatsprog=pathtoawstatspl [-dir=outputdir] [-date] [-update] \n";
+       print "  $PROG.$Extension (awstats_options) [awstatsbuildstaticpages_options]\n";
        print "\n";
-       print "  where configvalue  is value for config option of AWStats software.\n";
-       print "        pathtoawstatspl is name of AWStats software with path (awstats.pl).\n";
-       print "        outputdir    is name of output directory for generated pages.\n";
-       print "        -date        option is used to add build date in built files name.\n";
-       print "        -update      option is used to update statistics before generate pages.\n";
-       print "        -lang=LL     to output a HTML report in language LL (en,de,es,fr,it,nl,...)\n";
-       print "        -month=MM    to output a HTML report for an old month=MM\n";
-       print "        -year=YYYY   to output a HTML report for an old year=YYYY\n";
+       print "  where awstats_options are any option known by AWStats\n";
+       print "   -config=configvalue is value for -config parameter (REQUIRED)\n";
+       print "   -update             option used to update statistics before to generate pages\n";
+       print "   -lang=LL            to output a HTML report in language LL (en,de,es,fr,...)\n";
+       print "   -month=MM           to output a HTML report for an old month=MM\n";
+       print "   -year=YYYY          to output a HTML report for an old year=YYYY\n";
+       print "\n";
+       print "  and awstatsbuildstaticpages_options can be\n";
+       print "   -awstatsprog=pathtoawstatspl gives AWStats software (awstats.pl) path\n";
+       print "   -dir=outputdir               to set output directory for generated pages\n";
+       print "   -date                        used to add build date in built pages file name\n";
        print "\n";
        print "New versions and FAQ at http://awstats.sourceforge.net\n";
        exit 0;
@@ -156,7 +166,6 @@ close("OUTPUT");
 $cpt++;
 
 # Launch all other awstats output
-my @OutputList=("allhosts","lasthosts","unknownip","urldetail","unknownos","unknownbrowser","browserdetail","allkeyphrases","allkeywords","errors404");
 for my $output (@OutputList) {
        my $command="$smallcommand -output=$output";
        print "Build $output page: $command\n";
index 13a179d7bbe1b82361b7107a7a71561a9a688bec..ec6baf5b3bb61ddc1fb8c9b4a2f84c0c1bac6ef6 100644 (file)
@@ -189,30 +189,32 @@ $color_text, $color_textpercent, $color_titletext, $color_weekend, $color_link,
 $color_h, $color_k, $color_p, $color_e, $color_x, $color_s, $color_u, $color_v)=
 ("","","","","","","","","","","","","","","","","","","","","");
 use vars qw/
-$FileConfig $FileSuffix $Host $LastUpdate $DayRequired $MonthRequired $YearRequired
+$FileConfig $FileSuffix $Host $DayRequired $MonthRequired $YearRequired
 $QueryString $SiteConfig $StaticLinks $URLFilter $PageCode $LogFormatString $PerlParsingFormat
 $SiteToAnalyze $SiteToAnalyzeWithoutwww $UserAgent
 /;
-($FileConfig, $FileSuffix, $Host, $LastUpdate, $DayRequired, $MonthRequired, $YearRequired,
+($FileConfig, $FileSuffix, $Host, $DayRequired, $MonthRequired, $YearRequired,
 $QueryString, $SiteConfig, $StaticLinks, $URLFilter, $PageCode, $LogFormatString, $PerlParsingFormat,
 $SiteToAnalyze, $SiteToAnalyzeWithoutwww, $UserAgent)=
-("","","","","","","","","","","","","","","","","","");
+("","","","","","","","","","","","","","","","");
 use vars qw/
 $pos_vh $pos_rc $pos_logname $pos_date $pos_method $pos_url $pos_code $pos_size
 $pos_referer $pos_agent $pos_query $pos_gzipin $pos_gzipout $pos_gzipratio
 $lastrequiredfield $lowerval
 $FirstTime $LastTime
 $TotalUnique $TotalVisits $TotalHostsKnown $TotalHostsUnknown
-$TotalPages $TotalHits $TotalBytes $TotalEntries $TotalExits $TotalBytesPages
-$TotalKeyphrases $TotalKeywords $TotalDifferentPages $TotalDifferentKeyphrases $TotalDifferentKeywords
+$TotalPages $TotalHits $TotalBytes $TotalEntries $TotalExits $TotalBytesPages $TotalDifferentPages
+$TotalKeyphrases $TotalKeywords $TotalDifferentKeyphrases $TotalDifferentKeywords
+$TotalSearchEngines $TotalRefererPages $TotalDifferentSearchEngines $TotalDifferentRefererPages
 /;
 $pos_vh = $pos_rc = $pos_logname = $pos_date = $pos_method = $pos_url = $pos_code = $pos_size = 0;
 $pos_referer = $pos_agent = $pos_query = $pos_gzipin = $pos_gzipout = $pos_gzipratio = 0;
 $lastrequiredfield = $lowerval = 0;
 $FirstTime = $LastTime = 0;
 $TotalUnique = $TotalVisits = $TotalHostsKnown = $TotalHostsUnknown = 0;
-$TotalPages = $TotalHits = $TotalBytes = $TotalEntries = $TotalExits = $TotalBytesPages = 0;
-$TotalKeyphrases = $TotalKeywords = $TotalDifferentPages = $TotalDifferentKeyphrases = $TotalDifferentKeywords = 0;
+$TotalPages = $TotalHits = $TotalBytes = $TotalEntries = $TotalExits = $TotalBytesPages = $TotalDifferentPages = 0;
+$TotalKeyphrases = $TotalKeywords = $TotalDifferentKeyphrases = $TotalDifferentKeywords = 0;
+$TotalSearchEngines = $TotalRefererPages = $TotalDifferentSearchEngines = $TotalDifferentRefererPages = 0;
 # ---------- Init arrays --------
 use vars qw/
 @RobotsSearchIDOrder_list1 @RobotsSearchIDOrder_list2 @RobotsSearchIDOrder_list3
@@ -1145,6 +1147,8 @@ sub Check_Config {
        if ($MinHitFile !~ /^\d+/ || $MinHitFile<1)                                     { $MinHitFile=1; }
        if ($MaxNbOfRefererShown !~ /^\d+/ || $MaxNbOfRefererShown<1)           { $MaxNbOfRefererShown=25; }
        if ($MinHitRefer !~ /^\d+/ || $MinHitRefer<1)                                   { $MinHitRefer=1; }
+       if ($MaxNbOfKeyphrasesShown !~ /^\d+/ || $MaxNbOfKeyphrasesShown<1)     { $MaxNbOfKeyphrasesShown=25; }
+       if ($MinHitKeyphrase !~ /^\d+/ || $MinHitKeyphrase<1)                   { $MinHitKeyphrase=1; }
        if ($MaxNbOfKeywordsShown !~ /^\d+/ || $MaxNbOfKeywordsShown<1)         { $MaxNbOfKeywordsShown=25; }
        if ($MinHitKeyword !~ /^\d+/ || $MinHitKeyword<1)                       { $MinHitKeyword=1; }
        if ($FirstDayOfWeek !~ /[0-1]/)                 { $FirstDayOfWeek=1; }
@@ -1300,6 +1304,10 @@ sub Check_Config {
        if (! $Message[119]) { $Message[119]="Bytes"; }
        if (! $Message[120]) { $Message[120]="Search&nbsp;Keyphrases"; }
        if (! $Message[121]) { $Message[121]="Search&nbsp;Keywords"; }
+       if (! $Message[122]) { $Message[122]="different refering search engines"; }
+       if (! $Message[123]) { $Message[123]="different refering sites"; }
+       if (! $Message[124]) { $Message[124]="Other phrases"; }
+
        # Refuse LogFile if contains a pipe and PurgeLogFile || ArchiveLogRecords set on
        if (($PurgeLogFile || $ArchiveLogRecords) && $LogFile =~ /\|\s*$/) {
                error("Error: A pipe in log file name is not allowed if PurgeLogFile and ArchiveLogRecords are not set to 0");
@@ -1394,7 +1402,7 @@ sub Read_History_File {
                        if ($Debug) { debug(" Begin of TIME section"); }
                        $_=<HISTORY>;
                        chomp $_; s/\r//;
-                       if (! $_) { error("Error: History file \"$DirData/$PROG$month$year$FileSuffix.txt\" is corrupted (in section TIME). Last line read is number $countlines.\nCorrect the line, restore a recent backup of this file, or remove it (data for this month will be lost)."); }
+                       if (! $_) { error("Error: History file \"$historyfilename\" is corrupted (in section TIME). Last line read is number $countlines.\nCorrect the line, restore a recent backup of this file, or remove it (data for this month will be lost)."); }
                        my @field=split(/\s+/,$_); $countlines++;
                        my $count=0;my $countloaded=0;
                        while ($field[0] ne "END_TIME") {
@@ -1411,7 +1419,7 @@ sub Read_History_File {
                                #}
                                $_=<HISTORY>;
                                chomp $_; s/\r//;
-                               if (! $_) { error("Error: History file \"$DirData/$PROG$month$year$FileSuffix.txt\" is corrupted (in section TIME). Last line read is number $countlines.\nCorrect the line, restore a recent backup of this file, or remove it (data for this month will be lost)."); }
+                               if (! $_) { error("Error: History file \"$historyfilename\" is corrupted (in section TIME). Last line read is number $countlines.\nCorrect the line, restore a recent backup of this file, or remove it (data for this month will be lost)."); }
                                @field=split(/\s+/,$_); $countlines++;
                        }
                        if ($Debug) { debug(" End of TIME section ($count entries, $countloaded loaded)"); }
@@ -1421,7 +1429,7 @@ sub Read_History_File {
                        if ($Debug) { debug(" Begin of DAY section"); }
                        $_=<HISTORY>;
                        chomp $_; s/\r//;
-                       if (! $_) { error("Error: History file \"$DirData/$PROG$month$year$FileSuffix.txt\" is corrupted (in section DAY). Last line read is number $countlines.\nCorrect the line, restore a recent backup of this file, or remove it (data for this month will be lost)."); }
+                       if (! $_) { error("Error: History file \"$historyfilename\" is corrupted (in section DAY). Last line read is number $countlines.\nCorrect the line, restore a recent backup of this file, or remove it (data for this month will be lost)."); }
                        my @field=split(/\s+/,$_); $countlines++;
                        my $count=0;my $countloaded=0;
                        while ($field[0] ne "END_DAY" ) {
@@ -1438,7 +1446,7 @@ sub Read_History_File {
                                }
                                $_=<HISTORY>;
                                chomp $_; s/\r//;
-                               if (! $_) { error("Error: History file \"$DirData/$PROG$month$year$FileSuffix.txt\" is corrupted (in section DAY). Last line read is number $countlines.\nCorrect the line, restore a recent backup of this file, or remove it (data for this month will be lost)."); }
+                               if (! $_) { error("Error: History file \"$historyfilename\" is corrupted (in section DAY). Last line read is number $countlines.\nCorrect the line, restore a recent backup of this file, or remove it (data for this month will be lost)."); }
                                @field=split(/\s+/,$_); $countlines++;
                        }
                        if ($Debug) { debug(" End of DAY section ($count entries, $countloaded loaded)"); }
@@ -1448,7 +1456,7 @@ sub Read_History_File {
                        if ($Debug) { debug(" Begin of VISITOR section"); }
                        $_=<HISTORY>;
                        chomp $_; s/\r//;
-                       if (! $_) { error("Error: History file \"$DirData/$PROG$month$year$FileSuffix.txt\" is corrupted (in section VISITOR). Last line read is number $countlines.\nCorrect the line, restore a recent backup of this file, or remove it (data for this month will be lost)."); }
+                       if (! $_) { error("Error: History file \"$historyfilename\" is corrupted (in section VISITOR). Last line read is number $countlines.\nCorrect the line, restore a recent backup of this file, or remove it (data for this month will be lost)."); }
                        my @field=split(/\s+/,$_); $countlines++;
                        my $count=0;my $countloaded=0;
                        while ($field[0] ne "END_VISITOR") {
@@ -1500,7 +1508,7 @@ sub Read_History_File {
                                }
                                $_=<HISTORY>;
                                chomp $_; s/\r//;
-                               if (! $_) { error("Error: History file \"$DirData/$PROG$month$year$FileSuffix.txt\" is corrupted (in section VISITOR). Last line read is number $countlines.\nCorrect the line, restore a recent backup of this file, or remove it (data for this month will be lost)."); }
+                               if (! $_) { error("Error: History file \"$historyfilename\" is corrupted (in section VISITOR). Last line read is number $countlines.\nCorrect the line, restore a recent backup of this file, or remove it (data for this month will be lost)."); }
                                @field=split(/\s+/,$_); $countlines++;
                        }
                        if ($Debug) { debug(" End of VISITOR section ($count entries, $countloaded loaded)"); }
@@ -1510,7 +1518,7 @@ sub Read_History_File {
                        if ($Debug) { debug(" Begin of LOGIN section"); }
                        $_=<HISTORY>;
                        chomp $_; s/\r//;
-                       if (! $_) { error("Error: History file \"$DirData/$PROG$month$year$FileSuffix.txt\" is corrupted (in section LOGIN). Last line read is number $countlines.\nCorrect the line, restore a recent backup of this file, or remove it (data for this month will be lost)."); }
+                       if (! $_) { error("Error: History file \"$historyfilename\" is corrupted (in section LOGIN). Last line read is number $countlines.\nCorrect the line, restore a recent backup of this file, or remove it (data for this month will be lost)."); }
                        my @field=split(/\s+/,$_); $countlines++;
                        my $count=0;my $countloaded=0;
                        while ($field[0] ne "END_LOGIN") {
@@ -1526,7 +1534,7 @@ sub Read_History_File {
                                }
                                $_=<HISTORY>;
                                chomp $_; s/\r//;
-                               if (! $_) { error("Error: History file \"$DirData/$PROG$month$year$FileSuffix.txt\" is corrupted (in section LOGIN). Last line read is number $countlines.\nCorrect the line, restore a recent backup of this file, or remove it (data for this month will be lost)."); }
+                               if (! $_) { error("Error: History file \"$historyfilename\" is corrupted (in section LOGIN). Last line read is number $countlines.\nCorrect the line, restore a recent backup of this file, or remove it (data for this month will be lost)."); }
                                @field=split(/\s+/,$_); $countlines++;
                        }
                        if ($Debug) { debug(" End of LOGIN section ($count entries, $countloaded loaded)"); }
@@ -1536,7 +1544,7 @@ sub Read_History_File {
                        if ($Debug) { debug(" Begin of DOMAIN section"); }
                        $_=<HISTORY>;
                        chomp $_; s/\r//;
-                       if (! $_) { error("Error: History file \"$DirData/$PROG$month$year$FileSuffix.txt\" is corrupted (in section DOMAIN). Last line read is number $countlines.\nCorrect the line, restore a recent backup of this file, or remove it (data for this month will be lost)."); }
+                       if (! $_) { error("Error: History file \"$historyfilename\" is corrupted (in section DOMAIN). Last line read is number $countlines.\nCorrect the line, restore a recent backup of this file, or remove it (data for this month will be lost)."); }
                        my @field=split(/\s+/,$_); $countlines++;
                        my $count=0;my $countloaded=0;
                        while ($field[0] ne "END_DOMAIN") {
@@ -1551,7 +1559,7 @@ sub Read_History_File {
                                }
                                $_=<HISTORY>;
                                chomp $_; s/\r//;
-                               if (! $_) { error("Error: History file \"$DirData/$PROG$month$year$FileSuffix.txt\" is corrupted (in section DOMAIN). Last line read is number $countlines.\nCorrect the line, restore a recent backup of this file, or remove it (data for this month will be lost)."); }
+                               if (! $_) { error("Error: History file \"$historyfilename\" is corrupted (in section DOMAIN). Last line read is number $countlines.\nCorrect the line, restore a recent backup of this file, or remove it (data for this month will be lost)."); }
                                @field=split(/\s+/,$_); $countlines++;
                        }
                        if ($Debug) { debug(" End of DOMAIN section ($count entries, $countloaded loaded)"); }
@@ -1561,7 +1569,7 @@ sub Read_History_File {
                        if ($Debug) { debug(" Begin of SESSION section"); }
                        $_=<HISTORY>;
                        chomp $_; s/\r//;
-                       if (! $_) { error("Error: History file \"$DirData/$PROG$month$year$FileSuffix.txt\" is corrupted (in section SESSION). Last line read is number $countlines.\nCorrect the line, restore a recent backup of this file, or remove it (data for this month will be lost)."); }
+                       if (! $_) { error("Error: History file \"$historyfilename\" is corrupted (in section SESSION). Last line read is number $countlines.\nCorrect the line, restore a recent backup of this file, or remove it (data for this month will be lost)."); }
                        my @field=split(/\s+/,$_); $countlines++;
                        my $count=0;my $countloaded=0;
                        while ($field[0] ne "END_SESSION") {
@@ -1574,7 +1582,7 @@ sub Read_History_File {
                                }
                                $_=<HISTORY>;
                                chomp $_; s/\r//;
-                               if (! $_) { error("Error: History file \"$DirData/$PROG$month$year$FileSuffix.txt\" is corrupted (in section SESSION). Last line read is number $countlines.\nCorrect the line, restore a recent backup of this file, or remove it (data for this month will be lost)."); }
+                               if (! $_) { error("Error: History file \"$historyfilename\" is corrupted (in section SESSION). Last line read is number $countlines.\nCorrect the line, restore a recent backup of this file, or remove it (data for this month will be lost)."); }
                                @field=split(/\s+/,$_); $countlines++;
                        }
                        if ($Debug) { debug(" End of SESSION section ($count entries, $countloaded loaded)"); }
@@ -1584,7 +1592,7 @@ sub Read_History_File {
                        if ($Debug) { debug(" Begin of BROWSER section"); }
                        $_=<HISTORY>;
                        chomp $_; s/\r//;
-                       if (! $_) { error("Error: History file \"$DirData/$PROG$month$year$FileSuffix.txt\" is corrupted (in section BROWSER). Last line read is number $countlines.\nCorrect the line, restore a recent backup of this file, or remove it (data for this month will be lost)."); }
+                       if (! $_) { error("Error: History file \"$historyfilename\" is corrupted (in section BROWSER). Last line read is number $countlines.\nCorrect the line, restore a recent backup of this file, or remove it (data for this month will be lost)."); }
                        my @field=split(/\s+/,$_); $countlines++;
                        my $count=0;my $countloaded=0;
                        while ($field[0] ne "END_BROWSER") {
@@ -1597,7 +1605,7 @@ sub Read_History_File {
                                }
                                $_=<HISTORY>;
                                chomp $_; s/\r//;
-                               if (! $_) { error("Error: History file \"$DirData/$PROG$month$year$FileSuffix.txt\" is corrupted (in section BROWSER). Last line read is number $countlines.\nCorrect the line, restore a recent backup of this file, or remove it (data for this month will be lost)."); }
+                               if (! $_) { error("Error: History file \"$historyfilename\" is corrupted (in section BROWSER). Last line read is number $countlines.\nCorrect the line, restore a recent backup of this file, or remove it (data for this month will be lost)."); }
                                @field=split(/\s+/,$_); $countlines++;
                        }
                        if ($Debug) { debug(" End of BROWSER section ($count entries, $countloaded loaded)"); }
@@ -1607,7 +1615,7 @@ sub Read_History_File {
                        if ($Debug) { debug(" Begin of MSIEVER section"); }
                        $_=<HISTORY>;
                        chomp $_; s/\r//;
-                       if (! $_) { error("Error: History file \"$DirData/$PROG$month$year$FileSuffix.txt\" is corrupted (in section MSIEVER). Last line read is number $countlines.\nCorrect the line, restore a recent backup of this file, or remove it (data for this month will be lost)."); }
+                       if (! $_) { error("Error: History file \"$historyfilename\" is corrupted (in section MSIEVER). Last line read is number $countlines.\nCorrect the line, restore a recent backup of this file, or remove it (data for this month will be lost)."); }
                        my @field=split(/\s+/,$_); $countlines++;
                        my $count=0;my $countloaded=0;
                        while ($field[0] ne "END_MSIEVER") {
@@ -1620,7 +1628,7 @@ sub Read_History_File {
                                }
                                $_=<HISTORY>;
                                chomp $_; s/\r//;
-                               if (! $_) { error("Error: History file \"$DirData/$PROG$month$year$FileSuffix.txt\" is corrupted (in section MSIEVER). Last line read is number $countlines.\nCorrect the line, restore a recent backup of this file, or remove it (data for this month will be lost)."); }
+                               if (! $_) { error("Error: History file \"$historyfilename\" is corrupted (in section MSIEVER). Last line read is number $countlines.\nCorrect the line, restore a recent backup of this file, or remove it (data for this month will be lost)."); }
                                @field=split(/\s+/,$_); $countlines++;
                        }
                        if ($Debug) { debug(" End of MSIEVER section ($count entries, $countloaded loaded)"); }
@@ -1630,7 +1638,7 @@ sub Read_History_File {
                        if ($Debug) { debug(" Begin of NSVER section"); }
                        $_=<HISTORY>;
                        chomp $_; s/\r//;
-                       if (! $_) { error("Error: History file \"$DirData/$PROG$month$year$FileSuffix.txt\" is corrupted (in section NSVER). Last line read is number $countlines.\nCorrect the line, restore a recent backup of this file, or remove it (data for this month will be lost)."); }
+                       if (! $_) { error("Error: History file \"$historyfilename\" is corrupted (in section NSVER). Last line read is number $countlines.\nCorrect the line, restore a recent backup of this file, or remove it (data for this month will be lost)."); }
                        my @field=split(/\s+/,$_); $countlines++;
                        my $count=0;my $countloaded=0;
                        while ($field[0] ne "END_NSVER") {
@@ -1643,7 +1651,7 @@ sub Read_History_File {
                                }
                                $_=<HISTORY>;
                                chomp $_; s/\r//;
-                               if (! $_) { error("Error: History file \"$DirData/$PROG$month$year$FileSuffix.txt\" is corrupted (in section NSVER). Last line read is number $countlines.\nCorrect the line, restore a recent backup of this file, or remove it (data for this month will be lost)."); }
+                               if (! $_) { error("Error: History file \"$historyfilename\" is corrupted (in section NSVER). Last line read is number $countlines.\nCorrect the line, restore a recent backup of this file, or remove it (data for this month will be lost)."); }
                                @field=split(/\s+/,$_); $countlines++;
                        }
                        if ($Debug) { debug(" End of NSVER section ($count entries, $countloaded loaded)"); }
@@ -1653,7 +1661,7 @@ sub Read_History_File {
                        if ($Debug) { debug(" Begin of OS section"); }
                        $_=<HISTORY>;
                        chomp $_; s/\r//;
-                       if (! $_) { error("Error: History file \"$DirData/$PROG$month$year$FileSuffix.txt\" is corrupted (in section OS). Last line read is number $countlines.\nCorrect the line, restore a recent backup of this file, or remove it (data for this month will be lost)."); }
+                       if (! $_) { error("Error: History file \"$historyfilename\" is corrupted (in section OS). Last line read is number $countlines.\nCorrect the line, restore a recent backup of this file, or remove it (data for this month will be lost)."); }
                        my @field=split(/\s+/,$_); $countlines++;
                        my $count=0;my $countloaded=0;
                        while ($field[0] ne "END_OS") {
@@ -1666,7 +1674,7 @@ sub Read_History_File {
                                }
                                $_=<HISTORY>;
                                chomp $_; s/\r//;
-                               if (! $_) { error("Error: History file \"$DirData/$PROG$month$year$FileSuffix.txt\" is corrupted (in section OS). Last line read is number $countlines.\nCorrect the line, restore a recent backup of this file, or remove it (data for this month will be lost)."); }
+                               if (! $_) { error("Error: History file \"$historyfilename\" is corrupted (in section OS). Last line read is number $countlines.\nCorrect the line, restore a recent backup of this file, or remove it (data for this month will be lost)."); }
                                @field=split(/\s+/,$_); $countlines++;
                        }
                        if ($Debug) { debug(" End of OS section ($count entries, $countloaded loaded)"); }
@@ -1676,7 +1684,7 @@ sub Read_History_File {
                        if ($Debug) { debug(" Begin of UNKNOWNREFERER section"); }
                        $_=<HISTORY>;
                        chomp $_; s/\r//;
-                       if (! $_) { error("Error: History file \"$DirData/$PROG$month$year$FileSuffix.txt\" is corrupted (in section UNKNOWNREFERER). Last line read is number $countlines.\nCorrect the line, restore a recent backup of this file, or remove it (data for this month will be lost)."); }
+                       if (! $_) { error("Error: History file \"$historyfilename\" is corrupted (in section UNKNOWNREFERER). Last line read is number $countlines.\nCorrect the line, restore a recent backup of this file, or remove it (data for this month will be lost)."); }
                        my @field=split(/\s+/,$_); $countlines++;
                        my $count=0;my $countloaded=0;
                        while ($field[0] ne "END_UNKNOWNREFERER") {
@@ -1689,7 +1697,7 @@ sub Read_History_File {
                                }
                                $_=<HISTORY>;
                                chomp $_; s/\r//;
-                               if (! $_) { error("Error: History file \"$DirData/$PROG$month$year$FileSuffix.txt\" is corrupted (in section UNKNOWNREFERER). Last line read is number $countlines.\nCorrect the line, restore a recent backup of this file, or remove it (data for this month will be lost)."); }
+                               if (! $_) { error("Error: History file \"$historyfilename\" is corrupted (in section UNKNOWNREFERER). Last line read is number $countlines.\nCorrect the line, restore a recent backup of this file, or remove it (data for this month will be lost)."); }
                                @field=split(/\s+/,$_); $countlines++;
                        }
                        if ($Debug) { debug(" End of UNKNOWNREFERER section ($count entries, $countloaded loaded)"); }
@@ -1699,7 +1707,7 @@ sub Read_History_File {
                        if ($Debug) { debug(" Begin of UNKNOWNREFERERBROWSER section"); }
                        $_=<HISTORY>;
                        chomp $_; s/\r//;
-                       if (! $_) { error("Error: History file \"$DirData/$PROG$month$year$FileSuffix.txt\" is corrupted (in section UNKNOWNREFERERBROWSER). Last line read is number $countlines.\nCorrect the line, restore a recent backup of this file, or remove it (data for this month will be lost)."); }
+                       if (! $_) { error("Error: History file \"$historyfilename\" is corrupted (in section UNKNOWNREFERERBROWSER). Last line read is number $countlines.\nCorrect the line, restore a recent backup of this file, or remove it (data for this month will be lost)."); }
                        my @field=split(/\s+/,$_); $countlines++;
                        my $count=0;my $countloaded=0;
                        while ($field[0] ne "END_UNKNOWNREFERERBROWSER") {
@@ -1712,7 +1720,7 @@ sub Read_History_File {
                                }
                                $_=<HISTORY>;
                                chomp $_; s/\r//;
-                               if (! $_) { error("Error: History file \"$DirData/$PROG$month$year$FileSuffix.txt\" is corrupted (in section UNKNOWNREFERERBROWSER). Last line read is number $countlines.\nCorrect the line, restore a recent backup of this file, or remove it (data for this month will be lost)."); }
+                               if (! $_) { error("Error: History file \"$historyfilename\" is corrupted (in section UNKNOWNREFERERBROWSER). Last line read is number $countlines.\nCorrect the line, restore a recent backup of this file, or remove it (data for this month will be lost)."); }
                                @field=split(/\s+/,$_); $countlines++;
                        }
                        if ($Debug) { debug(" End of UNKNOWNREFERERBROWSER section ($count entries, $countloaded loaded)"); }
@@ -1722,7 +1730,7 @@ sub Read_History_File {
                        if ($Debug) { debug(" Begin of ROBOT section"); }
                        $_=<HISTORY>;
                        chomp $_; s/\r//;
-                       if (! $_) { error("Error: History file \"$DirData/$PROG$month$year$FileSuffix.txt\" is corrupted (in section ROBOT). Last line read is number $countlines.\nCorrect the line, restore a recent backup of this file, or remove it (data for this month will be lost)."); }
+                       if (! $_) { error("Error: History file \"$historyfilename\" is corrupted (in section ROBOT). Last line read is number $countlines.\nCorrect the line, restore a recent backup of this file, or remove it (data for this month will be lost)."); }
                        my @field=split(/\s+/,$_); $countlines++;
                        my $count=0;my $countloaded=0;
                        while ($field[0] ne "END_ROBOT") {
@@ -1736,7 +1744,7 @@ sub Read_History_File {
                                }
                                $_=<HISTORY>;
                                chomp $_; s/\r//;
-                               if (! $_) { error("Error: History file \"$DirData/$PROG$month$year$FileSuffix.txt\" is corrupted (in section ROBOT). Last line read is number $countlines.\nCorrect the line, restore a recent backup of this file, or remove it (data for this month will be lost)."); }
+                               if (! $_) { error("Error: History file \"$historyfilename\" is corrupted (in section ROBOT). Last line read is number $countlines.\nCorrect the line, restore a recent backup of this file, or remove it (data for this month will be lost)."); }
                                @field=split(/\s+/,$_); $countlines++;
                        }
                        if ($Debug) { debug(" End of ROBOT section ($count entries, $countloaded loaded)"); }
@@ -1746,7 +1754,7 @@ sub Read_History_File {
                        if ($Debug) { debug(" Begin of SIDER section"); }
                        $_=<HISTORY>;
                        chomp $_; s/\r//;
-                       if (! $_) { error("Error: History file \"$DirData/$PROG$month$year$FileSuffix.txt\" is corrupted (in section SIDER). Last line read is number $countlines.\nCorrect the line, restore a recent backup of this file, or remove it (data for this month will be lost)."); }
+                       if (! $_) { error("Error: History file \"$historyfilename\" is corrupted (in section SIDER). Last line read is number $countlines.\nCorrect the line, restore a recent backup of this file, or remove it (data for this month will be lost)."); }
                        my @field=split(/\s+/,$_); $countlines++;
                        my $count=0;my $countloaded=0;
                        while ($field[0] ne "END_SIDER") {
@@ -1808,7 +1816,7 @@ sub Read_History_File {
                                }
                                $_=<HISTORY>;
                                chomp $_; s/\r//;
-                               if (! $_) { error("Error: History file \"$DirData/$PROG$month$year$FileSuffix.txt\" is corrupted (in section SIDER). Last line read is number $countlines.\nCorrect the line, restore a recent backup of this file, or remove it (data for this month will be lost)."); }
+                               if (! $_) { error("Error: History file \"$historyfilename\" is corrupted (in section SIDER). Last line read is number $countlines.\nCorrect the line, restore a recent backup of this file, or remove it (data for this month will be lost)."); }
                                @field=split(/\s+/,$_); $countlines++;
                        }
                        if ($Debug) { debug(" End of SIDER section ($count entries, $countloaded loaded)"); }
@@ -1818,7 +1826,7 @@ sub Read_History_File {
                        if ($Debug) { debug(" Begin of FILETYPES section"); }
                        $_=<HISTORY>;
                        chomp $_; s/\r//;
-                       if (! $_) { error("Error: History file \"$DirData/$PROG$month$year$FileSuffix.txt\" is corrupted (in section FILETYPES). Last line read is number $countlines.\nCorrect the line, restore a recent backup of this file, or remove it (data for this month will be lost)."); }
+                       if (! $_) { error("Error: History file \"$historyfilename\" is corrupted (in section FILETYPES). Last line read is number $countlines.\nCorrect the line, restore a recent backup of this file, or remove it (data for this month will be lost)."); }
                        my @field=split(/\s+/,$_); $countlines++;
                        my $count=0;my $countloaded=0;
                        while ($field[0] ne "END_FILETYPES") {
@@ -1834,63 +1842,63 @@ sub Read_History_File {
                                }
                                $_=<HISTORY>;
                                chomp $_; s/\r//;
-                               if (! $_) { error("Error: History file \"$DirData/$PROG$month$year$FileSuffix.txt\" is corrupted (in section FILETYPES). Last line read is number $countlines.\nCorrect the line, restore a recent backup of this file, or remove it (data for this month will be lost)."); }
+                               if (! $_) { error("Error: History file \"$historyfilename\" is corrupted (in section FILETYPES). Last line read is number $countlines.\nCorrect the line, restore a recent backup of this file, or remove it (data for this month will be lost)."); }
                                @field=split(/\s+/,$_); $countlines++;
                        }
                        if ($Debug) { debug(" End of FILETYPES section ($count entries, $countloaded loaded)"); }
                        next;
                }
-               if ($field[0] eq "BEGIN_PAGEREFS")   {
-                       if ($Debug) { debug(" Begin of PAGEREFS section"); }
+               if ($field[0] eq "BEGIN_SEREFERRALS")   {
+                       if ($Debug) { debug(" Begin of SEREFERRALS section"); }
                        $_=<HISTORY>;
                        chomp $_; s/\r//;
-                       if (! $_) { error("Error: History file \"$DirData/$PROG$month$year$FileSuffix.txt\" is corrupted (in section PAGEREFS). Last line read is number $countlines.\nCorrect the line, restore a recent backup of this file, or remove it (data for this month will be lost)."); }
+                       if (! $_) { error("Error: History file \"$historyfilename\" is corrupted (in section SEREFERRALS). Last line read is number $countlines.\nCorrect the line, restore a recent backup of this file, or remove it (data for this month will be lost)."); }
                        my @field=split(/\s+/,$_); $countlines++;
                        my $count=0;my $countloaded=0;
-                       while ($field[0] ne "END_PAGEREFS") {
+                       while ($field[0] ne "END_SEREFERRALS") {
                                if ($field[0]) {
                                        $count++;
-                                       if ($part && ($UpdateStats || $QueryString !~ /output=/i || $QueryString =~ /output=externalreferers/i)) {
+                                       if ($part && ($UpdateStats || $QueryString !~ /output=/i || $QueryString =~ /output=refererse/i)) {
                                                $countloaded++;
-                                               if ($field[1]) { $_pagesrefs_h{$field[0]}+=int($field[1]); }
+                                               if ($field[1]) { $_se_referrals_h{$field[0]}+=$field[1]; }
                                        }
                                }
                                $_=<HISTORY>;
                                chomp $_; s/\r//;
-                               if (! $_) { error("Error: History file \"$DirData/$PROG$month$year$FileSuffix.txt\" is corrupted (in section PAGEREFS). Last line read is number $countlines.\nCorrect the line, restore a recent backup of this file, or remove it (data for this month will be lost)."); }
+                               if (! $_) { error("Error: History file \"$historyfilename\" is corrupted (in section SEREFERRALS). Last line read is number $countlines.\nCorrect the line, restore a recent backup of this file, or remove it (data for this month will be lost)."); }
                                @field=split(/\s+/,$_); $countlines++;
                        }
-                       if ($Debug) { debug(" End of PAGEREFS section ($count entries, $countloaded loaded)"); }
+                       if ($Debug) { debug(" End of SEREFERRALS section ($count entries, $countloaded loaded)"); }
                        next;
                }
-               if ($field[0] eq "BEGIN_SEREFERRALS")   {
-                       if ($Debug) { debug(" Begin of SEREFERRALS section"); }
+               if ($field[0] eq "BEGIN_PAGEREFS")   {
+                       if ($Debug) { debug(" Begin of PAGEREFS section"); }
                        $_=<HISTORY>;
                        chomp $_; s/\r//;
-                       if (! $_) { error("Error: History file \"$DirData/$PROG$month$year$FileSuffix.txt\" is corrupted (in section SEREFERRALS). Last line read is number $countlines.\nCorrect the line, restore a recent backup of this file, or remove it (data for this month will be lost)."); }
+                       if (! $_) { error("Error: History file \"$historyfilename\" is corrupted (in section PAGEREFS). Last line read is number $countlines.\nCorrect the line, restore a recent backup of this file, or remove it (data for this month will be lost)."); }
                        my @field=split(/\s+/,$_); $countlines++;
                        my $count=0;my $countloaded=0;
-                       while ($field[0] ne "END_SEREFERRALS") {
+                       while ($field[0] ne "END_PAGEREFS") {
                                if ($field[0]) {
                                        $count++;
-                                       if ($part && ($UpdateStats || $QueryString !~ /output=/i || $QueryString =~ /output=xxx/i)) {
+                                       if ($part && ($UpdateStats || $QueryString !~ /output=/i || $QueryString =~ /output=refererpages/i)) {
                                                $countloaded++;
-                                               if ($field[1]) { $_se_referrals_h{$field[0]}+=$field[1]; }
+                                               if ($field[1]) { $_pagesrefs_h{$field[0]}+=int($field[1]); }
                                        }
                                }
                                $_=<HISTORY>;
                                chomp $_; s/\r//;
-                               if (! $_) { error("Error: History file \"$DirData/$PROG$month$year$FileSuffix.txt\" is corrupted (in section SEREFERRALS). Last line read is number $countlines.\nCorrect the line, restore a recent backup of this file, or remove it (data for this month will be lost)."); }
+                               if (! $_) { error("Error: History file \"$historyfilename\" is corrupted (in section PAGEREFS). Last line read is number $countlines.\nCorrect the line, restore a recent backup of this file, or remove it (data for this month will be lost)."); }
                                @field=split(/\s+/,$_); $countlines++;
                        }
-                       if ($Debug) { debug(" End of SEREFERRALS section ($count entries, $countloaded loaded)"); }
+                       if ($Debug) { debug(" End of PAGEREFS section ($count entries, $countloaded loaded)"); }
                        next;
                }
                if ($field[0] eq "BEGIN_SEARCHWORDS")   {
                        if ($Debug) { debug(" Begin of SEARCHWORDS section ($MaxNbOfKeyphrasesShown,$MinHitKeyphrase)"); }
                        $_=<HISTORY>;
                        chomp $_; s/\r//;
-                       if (! $_) { error("Error: History file \"$DirData/$PROG$month$year$FileSuffix.txt\" is corrupted (in section SEARCHWORDS). Last line read is number $countlines.\nCorrect the line, restore a recent backup of this file, or remove it (data for this month will be lost)."); }
+                       if (! $_) { error("Error: History file \"$historyfilename\" is corrupted (in section SEARCHWORDS). Last line read is number $countlines.\nCorrect the line, restore a recent backup of this file, or remove it (data for this month will be lost)."); }
                        my @field=split(/\s+/,$_); $countlines++;
                        my $count=0;my $countloaded=0;
                        while ($field[0] ne "END_SEARCHWORDS") {
@@ -1920,14 +1928,14 @@ sub Read_History_File {
                                                        }
                                                        if ($QueryString =~ /output=allkeywords/i) {    # Load keyphrases for keywords chart
                                                                $loadrecord=2;
-                                                               $TotalDifferentKeywords++;
-                                                               $TotalKeywords+=($field[1]||0);
                                                        }
                                                }
                                                if ($loadrecord) {
                                                        if ($field[1]) {
                                                                if ($loadrecord==2) {
-                                                                       my @wordarray=split(/\+/,$field[0]); foreach my $word (@wordarray) { $_keywords{$word}+=$field[1]; }
+                                                                       my @wordarray=split(/\+/,$field[0]); foreach my $word (@wordarray) {
+                                                                               $_keywords{$word}+=$field[1];
+                                                                       }
                                                                }
                                                                else {
                                                                        $_keyphrases{$field[0]}+=$field[1];
@@ -1939,7 +1947,7 @@ sub Read_History_File {
                                }
                                $_=<HISTORY>;
                                chomp $_; s/\r//;
-                               if (! $_) { error("Error: History file \"$DirData/$PROG$month$year$FileSuffix.txt\" is corrupted (in section SEARCHWORDS). Last line read is number $countlines.\nCorrect the line, restore a recent backup of this file, or remove it (data for this month will be lost)."); }
+                               if (! $_) { error("Error: History file \"$historyfilename\" is corrupted (in section SEARCHWORDS). Last line read is number $countlines.\nCorrect the line, restore a recent backup of this file, or remove it (data for this month will be lost)."); }
                                @field=split(/\s+/,$_); $countlines++;
                        }
                        if ($Debug) { debug(" End of SEARCHWORDS section ($count entries, $countloaded loaded)"); }
@@ -1949,7 +1957,7 @@ sub Read_History_File {
                        if ($Debug) { debug(" Begin of KEYWORDS section ($MaxNbOfKeywordsShown,$MinHitKeyword)"); }
                        $_=<HISTORY>;
                        chomp $_; s/\r//;
-                       if (! $_) { error("Error: History file \"$DirData/$PROG$month$year$FileSuffix.txt\" is corrupted (in section KEYWORDS). Last line read is number $countlines.\nCorrect the line, restore a recent backup of this file, or remove it (data for this month will be lost)."); }
+                       if (! $_) { error("Error: History file \"$historyfilename\" is corrupted (in section KEYWORDS). Last line read is number $countlines.\nCorrect the line, restore a recent backup of this file, or remove it (data for this month will be lost)."); }
                        my @field=split(/\s+/,$_); $countlines++;
                        my $count=0;my $countloaded=0;
                        while ($field[0] ne "END_KEYWORDS") {
@@ -1978,7 +1986,7 @@ sub Read_History_File {
                                }
                                $_=<HISTORY>;
                                chomp $_; s/\r//;
-                               if (! $_) { error("Error: History file \"$DirData/$PROG$month$year$FileSuffix.txt\" is corrupted (in section KEYWORDS). Last line read is number $countlines.\nCorrect the line, restore a recent backup of this file, or remove it (data for this month will be lost)."); }
+                               if (! $_) { error("Error: History file \"$historyfilename\" is corrupted (in section KEYWORDS). Last line read is number $countlines.\nCorrect the line, restore a recent backup of this file, or remove it (data for this month will be lost)."); }
                                @field=split(/\s+/,$_); $countlines++;
                        }
                        if ($Debug) { debug(" End of KEYWORDS section ($count entries, $countloaded loaded)"); }
@@ -1988,7 +1996,7 @@ sub Read_History_File {
                        if ($Debug) { debug(" Begin of ERRORS section"); }
                        $_=<HISTORY>;
                        chomp $_; s/\r//;
-                       if (! $_) { error("Error: History file \"$DirData/$PROG$month$year$FileSuffix.txt\" is corrupted (in section ERRORS). Last line read is number $countlines.\nCorrect the line, restore a recent backup of this file, or remove it (data for this month will be lost)."); }
+                       if (! $_) { error("Error: History file \"$historyfilename\" is corrupted (in section ERRORS). Last line read is number $countlines.\nCorrect the line, restore a recent backup of this file, or remove it (data for this month will be lost)."); }
                        my @field=split(/\s+/,$_); $countlines++;
                        my $count=0;my $countloaded=0;
                        while ($field[0] ne "END_ERRORS") {
@@ -2001,7 +2009,7 @@ sub Read_History_File {
                                }
                                $_=<HISTORY>;
                                chomp $_; s/\r//;
-                               if (! $_) { error("Error: History file \"$DirData/$PROG$month$year$FileSuffix.txt\" is corrupted (in section ERRORS). Last line read is number $countlines.\nCorrect the line, restore a recent backup of this file, or remove it (data for this month will be lost)."); }
+                               if (! $_) { error("Error: History file \"$historyfilename\" is corrupted (in section ERRORS). Last line read is number $countlines.\nCorrect the line, restore a recent backup of this file, or remove it (data for this month will be lost)."); }
                                @field=split(/\s+/,$_); $countlines++;
                        }
                        if ($Debug) { debug(" End of ERRORS section ($count entries, $countloaded loaded)"); }
@@ -2011,7 +2019,7 @@ sub Read_History_File {
                        if ($Debug) { debug(" Begin of SIDER_404 section"); }
                        $_=<HISTORY>;
                        chomp $_; s/\r//;
-                       if (! $_) { error("Error: History file \"$DirData/$PROG$month$year$FileSuffix.txt\" is corrupted (in section SIDER_404). Last line read is number $countlines.\nCorrect the line, restore a recent backup of this file, or remove it (data for this month will be lost)."); }
+                       if (! $_) { error("Error: History file \"$historyfilename\" is corrupted (in section SIDER_404). Last line read is number $countlines.\nCorrect the line, restore a recent backup of this file, or remove it (data for this month will be lost)."); }
                        my @field=split(/\s+/,$_); $countlines++;
                        my $count=0;my $countloaded=0;
                        while ($field[0] ne "END_SIDER_404") {
@@ -2027,7 +2035,7 @@ sub Read_History_File {
                                }
                                $_=<HISTORY>;
                                chomp $_; s/\r//;
-                               if (! $_) { error("Error: History file \"$DirData/$PROG$month$year$FileSuffix.txt\" is corrupted (in section SIDER_404). Last line read is number $countlines.\nCorrect the line, restore a recent backup of this file, or remove it (data for this month will be lost)."); }
+                               if (! $_) { error("Error: History file \"$historyfilename\" is corrupted (in section SIDER_404). Last line read is number $countlines.\nCorrect the line, restore a recent backup of this file, or remove it (data for this month will be lost)."); }
                                @field=split(/\s+/,$_); $countlines++;
                        }
                        if ($Debug) { debug(" End of SIDER_404 section ($count entries, $countloaded loaded)"); }
@@ -2272,18 +2280,18 @@ sub Save_History_File {
                $keysinkeylist{$key}=1;
                my $keyphrase=$key;
                print HISTORYTMP "$keyphrase $_keyphrases{$key}\n";
-               my @wordarray=split(/\+/,$key); foreach my $word (@wordarray) { $_keywords{$word}+=$_keyphrases{$key}; }
+               my @wordarray=split(/\+/,$key); foreach my $word (@wordarray) { $_keywords{$word}+=$_keyphrases{$key}; }        # To init %_keywords
        }
        foreach my $key (keys %_keyphrases) {
                if ($keysinkeylist{$key}) { next; }
                my $keyphrase=$key;
                print HISTORYTMP "$keyphrase $_keyphrases{$key}\n";
-               my @wordarray=split(/\+/,$key); foreach my $word (@wordarray) { $_keywords{$word}+=$_keyphrases{$key}; }
+               my @wordarray=split(/\+/,$key); foreach my $word (@wordarray) { $_keywords{$word}+=$_keyphrases{$key}; }        # To init %_keywords
        }
        print HISTORYTMP "END_SEARCHWORDS\n";
        print HISTORYTMP "\n";
        print HISTORYTMP "# Search keywords - Number of search\n";
-       print HISTORYTMP "# Only the $MaxNbOfKeywordsShown first number of search are saved\n";
+       print HISTORYTMP "# The $MaxNbOfKeywordsShown first number of search must be first (order not required for others)\n";
        print HISTORYTMP "BEGIN_KEYWORDS\n";
        &BuildKeyList($MaxNbOfKeywordsShown,$MinHitKeyword,\%_keywords,\%_keywords);
        %keysinkeylist=();
@@ -2292,6 +2300,11 @@ sub Save_History_File {
                my $keyword=$key;
                print HISTORYTMP "$keyword $_keywords{$key}\n";
        }
+       foreach my $key (keys %_keywords) {
+               if ($keysinkeylist{$key}) { next; }
+               my $keyword=$key;
+               print HISTORYTMP "$keyword $_keywords{$key}\n";
+       }
        print HISTORYTMP "END_KEYWORDS\n";
 
        # Other
@@ -2743,10 +2756,14 @@ if ((! $ENV{"GATEWAY_INTERFACE"}) && (! $SiteConfig)) {
        print "               unknownip        to build page of all unresolved IP\n";
        print "               urldetail        to list most often viewed pages \n";
        print "               urldetail:filter to list most often viewed pages matching filter\n";
-       print "               unknownos        to list 'User Agents' with unknown OS\n";
-       print "               unknownbrowser   to list 'User Agents' with unknown browser\n";
        print "               browserdetail    to build page with browsers detailed versions\n";
+       print "               unknownbrowser   to list 'User Agents' with unknown browser\n";
+       print "               unknownos        to list 'User Agents' with unknown OS\n";
+       print "               refererse        to build page of all refering search engines\n";
+       print "               refererpages     to build page of all refering pages\n";
+#      print "               referersites     to build page of all refering sites\n";
        print "               allkeyphrases    to list all keyphrases used on search engines\n";
+       print "               allkeywords      to list all keywords used on search engines\n";
        print "               errors404        to list 'Referers' for 404 errors\n";
        print "  -staticlinks to have static links in HTML report page\n";
        print "  -lang=LL     to output a HTML report in language LL (en,de,es,fr,it,nl,...)\n";
@@ -2886,8 +2903,6 @@ if ($UpdateStats && (! $AllowToUpdateStatsFromBrowser) && $ENV{"GATEWAY_INTERFAC
 # Init global variables required for output and update process
 %monthlib = ("01","$Message[60]","02","$Message[61]","03","$Message[62]","04","$Message[63]","05","$Message[64]","06","$Message[65]","07","$Message[66]","08","$Message[67]","09","$Message[68]","10","$Message[69]","11","$Message[70]","12","$Message[71]");
 %monthnum = ("Jan","01","jan","01","Feb","02","feb","02","Mar","03","mar","03","Apr","04","apr","04","May","05","may","05","Jun","06","jun","06","Jul","07","jul","07","Aug","08","aug","08","Sep","09","sep","09","Oct","10","oct","10","Nov","11","nov","11","Dec","12","dec","12"); # monthnum must be in english because used to translate log date in apache log files
-$LastUpdate=0;
-$TotalEntries=0; $TotalExits=0; $TotalBytesPages=0; $TotalKeyphrases=0; $TotalDifferentPages=0; $TotalDifferentKeyphrases=0;
 for (my $ix=1; $ix<=12; $ix++) {
        my $monthix=$ix;if ($monthix < 10) { $monthix  = "0$monthix"; }
        $LastLine{$YearRequired.$monthix}=0;$FirstTime{$YearRequired.$monthix}=0;$LastTime{$YearRequired.$monthix}=0;$LastUpdate{$YearRequired.$monthix}=0;
@@ -3984,12 +3999,20 @@ EOF
        if (!$TotalKeyphrases) { foreach my $key (keys %_keyphrases) { $TotalKeyphrases+=$_keyphrases{$key}; } }
        # TotalKeywords (if not already specifically counted, we init it from _keywords hash table)
        if (!$TotalKeywords) { foreach my $key (keys %_keywords) { $TotalKeywords+=$_keywords{$key}; } }
+       # TotalSearchEngines (if not already specifically counted, we init it from _se_referrals_h hash table)
+       if (!$TotalSearchEngines) { foreach my $key (keys %_se_referrals_h) { $TotalSearchEngines+=$_se_referrals_h{$key}; } }
+       # TotalRefererPages (if not already specifically counted, we init it from _pagesrefs_h hash table)
+       if (!$TotalRefererPages) { foreach my $key (keys %_pagesrefs_h) { $TotalRefererPages+=$_pagesrefs_h{$key}; } }
        # TotalDifferentPages (if not already specifically counted, we init it from _url_p hash table)
        if (!$TotalDifferentPages) { $TotalDifferentPages=scalar keys %_url_p; }
        # TotalDifferentKeyphrases (if not already specifically counted, we init it from _keyphrases hash table)
        if (!$TotalDifferentKeyphrases) { $TotalDifferentKeyphrases=scalar keys %_keyphrases; }
        # TotalDifferentKeywords (if not already specifically counted, we init it from _keywords hash table)
        if (!$TotalDifferentKeywords) { $TotalDifferentKeywords=scalar keys %_keywords; }
+       # TotalDifferentSearchEngines (if not already specifically counted, we init it from _se_referrals_h hash table)
+       if (!$TotalDifferentSearchEngines) { $TotalDifferentSearchEngines=scalar keys %_se_referrals_h; }
+       # TotalDifferentRefererPages (if not already specifically counted, we init it from _pagesrefs_h hash table)
+       if (!$TotalDifferentRefererPages) { $TotalDifferentRefererPages=scalar keys %_pagesrefs_h; }
        # Define firstdaytocountaverage, lastdaytocountaverage, firstdaytoshowtime, lastdaytoshowtime
        my $firstdaytocountaverage=$nowyear.$nowmonth."01";                             # Set day cursor to 1st day of month
        my $firstdaytoshowtime=$nowyear.$nowmonth."01";                                 # Set day cursor to 1st day of month
@@ -4026,8 +4049,10 @@ EOF
                print "<tr><th class=AWL>$Message[7] : </th><td class=AWL><font style=\"font-size: 14px;\">$SiteDomain</font></th></tr>";
                print "<tr><th class=AWL valign=top>$Message[35] : </th>";
                print "<td class=AWL><font style=\"font-size: 14px;\">";
-               foreach my $key (sort keys %LastUpdate) { if ($LastUpdate < $LastUpdate{$key}) { $LastUpdate = $LastUpdate{$key}; } }
-               if ($LastUpdate) { print Format_Date($LastUpdate,0); }
+               # Search max of %LastUpdate
+               my $lastupdate=0;
+               foreach my $key (sort keys %LastUpdate) { if ($lastupdate < $LastUpdate{$key}) { $lastupdate = $LastUpdate{$key}; } }
+               if ($lastupdate) { print Format_Date($lastupdate,0); }
                else { print "<font color=#880000>Never updated</font>"; }
                print "</font>&nbsp; &nbsp; &nbsp; &nbsp;";
                if ($AllowToUpdateStatsFromBrowser && ! $StaticLinks) {
@@ -4356,6 +4381,70 @@ EOF
                &html_end;
                exit(0);
        }
+       if ($QueryString =~ /output=refererse/i) {
+               print "$CENTER<a name=\"REFERERSE\">&nbsp;</a><BR>";
+               &tab_head($Message[40],19);
+               print "<TR bgcolor=\"#$color_TableBGRowTitle\"><TH>$TotalDifferentSearchEngines $Message[122]</TH>";
+               #print "<TH bgcolor=\"#$color_p\" width=80>$Message[56]</TH><TH bgcolor=\"#$color_p\" width=80>$Message[15]</TH>";
+               print "<TH bgcolor=\"#$color_h\" width=80>$Message[57]</TH><TH bgcolor=\"#$color_h\" width=80>$Message[15]</TH></TR>\n";
+               $total_s=0;
+               my $count=0;
+               &BuildKeyList($MaxRowsInHTMLOutput,$MinHitRefer,\%_se_referrals_h,\%_se_referrals_h);
+               foreach my $key (@keylist) {
+                       my $newreferer=CleanFromCSSA($SearchEnginesHashIDLib{$key}||$key);
+                       my $p;
+                       if ($TotalSearchEngines) { $p=int($_se_referrals_h{$key}/$TotalSearchEngines*1000)/10; }
+                       print "<TR><TD CLASS=AWL>$newreferer</TD><TD>$_se_referrals_h{$key}</TD><TD>$p&nbsp;%</TD></TR>\n";
+                       $total_s += $_se_referrals_h{$key};
+                       $count++;
+               }
+               if ($Debug) { debug("Total real / shown : $TotalSearchEngines / $total_s",2); }
+               $rest_s=$TotalSearchEngines-$total_s;
+               if ($rest_s > 0) {
+                       my $p;
+                       if ($TotalSearchEngines) { $p=int($rest_s/$TotalSearchEngines*1000)/10; }
+                       print "<TR><TD CLASS=AWL><font color=blue>$Message[2]</TD><TD>$rest_s</TD>";
+                       print "<TD>$p&nbsp;%</TD></TR>\n";
+               }
+               &tab_end;
+               &html_end;
+               exit(0);
+       }
+       if ($QueryString =~ /output=refererpages/i) {
+               print "$CENTER<a name=\"REFERERPAGES\">&nbsp;</a><BR>";
+               &tab_head($Message[41],19);
+               print "<TR bgcolor=\"#$color_TableBGRowTitle\"><TH>$TotalDifferentRefererPages $Message[28]</TH>";
+               #print "<TH bgcolor=\"#$color_p\" width=80>$Message[56]</TH><TH bgcolor=\"#$color_p\" width=80>$Message[15]</TH>";
+               print "<TH bgcolor=\"#$color_h\" width=80>$Message[57]</TH><TH bgcolor=\"#$color_h\" width=80>$Message[15]</TH></TR>\n";
+               $total_s=0;
+               my $count=0;
+               &BuildKeyList($MaxRowsInHTMLOutput,$MinHitRefer,\%_pagesrefs_h,\%_pagesrefs_h);
+               foreach my $key (@keylist) {
+                       my $nompage=CleanFromCSSA($key);
+                       if (length($nompage)>$MaxLengthOfURL) { $nompage=substr($nompage,0,$MaxLengthOfURL)."..."; }
+                       my $p;
+                       if ($TotalRefererPages) { $p=int($_pagesrefs_h{$key}/$TotalRefererPages*1000)/10; }
+                       if ($ShowLinksOnUrl && ($key =~ /^http(s|):/i)) {
+                               my $newkey=CleanFromCSSA($key);
+                               print "<TR><TD CLASS=AWL><A HREF=\"$newkey\" target=\"awstatsbis\">$nompage</A></TD><TD>$_pagesrefs_h{$key}</TD><TD>$p&nbsp;%</TD></TR>\n";
+                       } else {
+                               print "<TR><TD CLASS=AWL>$nompage</TD><TD>$_pagesrefs_h{$key}</TD><TD>$p&nbsp;%</TD></TR>\n";
+                       }
+                       $total_s += $_pagesrefs_h{$key};
+                       $count++;
+               }
+               if ($Debug) { debug("Total real / shown : $TotalRefererPages / $total_s",2); }
+               $rest_s=$TotalRefererPages-$total_s;
+               if ($rest_s > 0) {
+                       my $p;
+                       if ($TotalRefererPages) { $p=int($rest_s/$TotalRefererPages*1000)/10; }
+                       print "<TR><TD CLASS=AWL><font color=blue>$Message[2]</TD><TD>$rest_s</TD>";
+                       print "<TD>$p&nbsp;%</TD></TR>\n";
+               }
+               &tab_end;
+               &html_end;
+               exit(0);
+       }
        if ($QueryString =~ /output=allkeyphrases/i) {
                print "$CENTER<a name=\"KEYPHRASES\">&nbsp;</a><BR>";
                &tab_head($Message[43],19);
@@ -5118,18 +5207,24 @@ EOF
                #------- Referrals by news group
                print "<TR><TD CLASS=AWL><b>$Message[107]</b></TD><TD>$_from_p[5]&nbsp;</TD><TD>$p_p[5]&nbsp;%</TD><TD>$_from_h[5]&nbsp;</TD><TD>$p_h[5]&nbsp;%</TD></TR>\n";
                #------- Referrals by search engine
-               print "<TR onmouseover=\"ShowTooltip(13);\" onmouseout=\"HideTooltip(13);\"><TD CLASS=AWL><b>$Message[40]</b><br>\n";
+               print "<TR onmouseover=\"ShowTooltip(13);\" onmouseout=\"HideTooltip(13);\"><TD CLASS=AWL><b>$Message[40]</b> - <a href=\"".($ENV{"GATEWAY_INTERFACE"} || !$StaticLinks?"$AWScript?${NewLinkParams}output=refererse":"$PROG$StaticLinks.refererse.html")."\"".($DetailedReportsOnNewWindows?" target=\"awstatsbis\"":"").">$Message[80]</a><br>\n";
                print "<TABLE>\n";
                my $count=0;
+               $rest_h=0;
                foreach my $key (sort { $_se_referrals_h{$b} <=> $_se_referrals_h{$a} } keys (%_se_referrals_h)) {
+                       if ($count>=$MaxNbOfRefererShown) { $rest_h+=$_se_referrals_h{$key}; next; }
+                       if ($_se_referrals_h{$key}<$MinHitRefer) { $rest_h+=$_se_referrals_h{$key}; next; }
                        my $newreferer=CleanFromCSSA($SearchEnginesHashIDLib{$key}||$key);
                        print "<TR><TD CLASS=AWL>- $newreferer</TD><TD align=right> $_se_referrals_h{$key} </TD></TR>\n";
                        $count++;
                }
+               if ($rest_h > 0) {
+                       print "<TR><TD CLASS=AWL><font color=blue>- $Message[2]</TD><TD>$rest_h</TD>";
+               }
                print "</TABLE></TD>\n";
                print "<TD valign=top>$_from_p[2]&nbsp;</TD><TD valign=top>$p_p[2]&nbsp;%</TD><TD valign=top>$_from_h[2]&nbsp;</TD><TD valign=top>$p_h[2]&nbsp;%</TD></TR>\n";
                #------- Referrals by external HTML link
-               print "<TR onmouseover=\"ShowTooltip(14);\" onmouseout=\"HideTooltip(14);\"><TD CLASS=AWL><b>$Message[41]</b><br>\n";
+               print "<TR onmouseover=\"ShowTooltip(14);\" onmouseout=\"HideTooltip(14);\"><TD CLASS=AWL><b>$Message[41]</b> - <a href=\"".($ENV{"GATEWAY_INTERFACE"} || !$StaticLinks?"$AWScript?${NewLinkParams}output=refererpages":"$PROG$StaticLinks.refererpages.html")."\"".($DetailedReportsOnNewWindows?" target=\"awstatsbis\"":"").">$Message[80]</a><br>\n";
                print "<TABLE>\n";
                $count=0;
                $rest_h=0;
@@ -5183,7 +5278,7 @@ EOF
                if ($rest_s > 0) {
                        my $p;
                        if ($TotalKeyphrases) { $p=int($rest_s/$TotalKeyphrases*1000)/10; }
-                       print "<TR><TD CLASS=AWL><font color=blue>$Message[30]</TD><TD>$rest_s</TD>";
+                       print "<TR><TD CLASS=AWL><font color=blue>$Message[124]</TD><TD>$rest_s</TD>";
                        print "<TD>$p&nbsp;%</TD></TR>\n";
                }
                &tab_end;