From: eldy <> Date: Wed, 1 May 2002 19:07:25 +0000 (+0000) Subject: New feature: Added session length. X-Git-Tag: AWSTATS_4_1_BETA~102 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ea1d4d6f81d70cf6d6d5b63b91d90beec83e6432;p=thirdparty%2FAWStats.git New feature: Added session length. --- diff --git a/wwwroot/cgi-bin/awstats.model.conf b/wwwroot/cgi-bin/awstats.model.conf index f5d79d74..6ff9c10a 100644 --- a/wwwroot/cgi-bin/awstats.model.conf +++ b/wwwroot/cgi-bin/awstats.model.conf @@ -422,8 +422,8 @@ DirLang="./lang" # You choose here which summary report you want to see in the main page. # Whatever is your setup here, all detailed reports are still available. -# So if you setup to 1 only ShowHeader, ShowMenu and ShowMonthDayStats, all -# links in menu will still point to detailed views. +# So if you setup ShowHeader, ShowMenu and ShowMonthDayStats to 1 and all +# others to 0, all links in menu will still point to detailed views. # Possible values: 1 or 0 # ShowHeader=1 # Show AWStats head title and icon @@ -435,6 +435,7 @@ ShowDomainsStats=1 ShowHostsStats=1 ShowAuthenticatedUsers=0 ShowRobotsStats=1 +ShowSessionsStats=1 ShowPagesStats=1 ShowCompressionStats=0 # Show report of compression stats when using mod_gzip ShowFileTypesStats=1 diff --git a/wwwroot/cgi-bin/awstats.pl b/wwwroot/cgi-bin/awstats.pl index f845164e..46354bb9 100644 --- a/wwwroot/cgi-bin/awstats.pl +++ b/wwwroot/cgi-bin/awstats.pl @@ -86,7 +86,7 @@ $LevelForRobotsDetection, $LevelForBrowsersDetection, $LevelForOSDetection, $LevelForSearchEnginesDetection, $LevelForKeywordsDetection, $LevelForRefererAnalyze, $ShowHeader, $ShowMenu, $ShowMonthDayStats, $ShowDaysOfWeekStats, $ShowHoursStats, $ShowDomainsStats, $ShowHostsStats, -$ShowRobotsStats, $ShowPagesStats, $ShowFileTypesStats, +$ShowRobotsStats, $ShowSessionsStats, $ShowPagesStats, $ShowFileTypesStats, $ShowBrowsersStats, $ShowOSStats, $ShowOriginStats, $ShowKeyphrasesStats, $ShowKeywordsStats, $ShowHTTPErrorsStats, $ShowFlagLinks, $ShowLinksOnUrl, @@ -609,6 +609,7 @@ sub Read_Config_File { if ($param =~ /^ShowHostsStats/) { $ShowHostsStats=$value; next; } if ($param =~ /^ShowAuthenticatedUsers/) { $ShowAuthenticatedUsers=$value; next; } if ($param =~ /^ShowRobotsStats/) { $ShowRobotsStats=$value; next; } + if ($param =~ /^ShowSessionsStats/) { $ShowSessionsStats=$value; next; } if ($param =~ /^ShowPagesStats/) { $ShowPagesStats=$value; next; } if ($param =~ /^ShowFileTypesStats/) { $ShowFileTypesStats=$value; next; } if ($param =~ /^ShowFileSizesStats/) { $ShowFileSizesStats=$value; next; } @@ -885,6 +886,7 @@ sub Check_Config { if ($ShowHostsStats !~ /[0-1]/) { $ShowHostsStats=1; } if ($ShowAuthenticatedUsers !~ /[0-1]/) { $ShowAuthenticatedUsers=1; } if ($ShowRobotsStats !~ /[0-1]/) { $ShowRobotsStats=1; } + if ($ShowSessionsStats !~ /[0-1]/) { $ShowSessionsStats=1; } if ($ShowPagesStats !~ /[0-1]/) { $ShowPagesStats=1; } if ($ShowFileTypesStats !~ /[0-1]/) { $ShowFileTypesStats=1; } if ($ShowFileSizesStats !~ /[0-1]/) { $ShowFileSizesStats=1; } @@ -1092,7 +1094,8 @@ sub Read_History_File { return 0; } - # If session for read (no update), file can be open with share. So POSSIBLE CHANGE HERE + # TODO If session for read (no update), file can be open with share. So POSSIBLE CHANGE HERE + # TODO Whith particular option file reading can be stopped if section all read open(HISTORY,"$DirData/$PROG$DayRequired$month$year$FileSuffix.txt") || error("Error: Couldn't open for read file \"$DirData/$PROG$DayRequired$month$year$FileSuffix.txt\" : $!"); # Month before Year kept for backward compatibility $MonthUnique{$year.$month}=0; $MonthPages{$year.$month}=0; $MonthHits{$year.$month}=0; $MonthBytes{$year.$month}=0; $MonthHostsKnown{$year.$month}=0; $MonthHostsUnknown{$year.$month}=0; @@ -1305,6 +1308,29 @@ sub Read_History_File { if ($Debug) { debug(" End of DOMAIN section ($count entries, $countloaded loaded)"); } next; } + if ($field[0] eq "BEGIN_SESSION") { + if ($Debug) { debug(" Begin of SESSION section"); } + $_=; + 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)."); } + my @field=split(/\s+/,$_); $countlines++; + my $count=0;my $countloaded=0; + while ($field[0] ne "END_SESSION") { + if ($field[0]) { + $count++; + if ($part && ($UpdateStats || $QueryString !~ /output=/i || $QueryString =~ /output=sessions/i)) { + $countloaded++; + if ($field[1]) { $_session{$field[0]}+=$field[1]; } + } + } + $_=; + 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)."); } + @field=split(/\s+/,$_); $countlines++; + } + if ($Debug) { debug(" End of SESSION section ($count entries, $countloaded loaded)"); } + next; + } if ($field[0] eq "BEGIN_BROWSER") { if ($Debug) { debug(" Begin of BROWSER section"); } $_=; @@ -3124,10 +3150,10 @@ if ($UpdateStats) { # This is a new visit if ($_hostmachine_l{$_} && $_hostmachine_s{$_} && $_hostmachine_u{$_}) { # If there was a preceding session running # Session for $_ is expired so we close and count it - $_url_x{$_hostmachine_u{$_}}++; + $_url_x{$_hostmachine_u{$_}}++; # Increase exit page $_session{SessionLastToSessionRange($_hostmachine_l{$_},$_hostmachine_s{$_})}++; -# delete $_hostmachine_s{$_}; -# delete $_hostmachine_u{$_}; + #delete $_hostmachine_s{$_}; + #delete $_hostmachine_u{$_}; } $MonthVisits{$yearmonth}++; @@ -3686,8 +3712,10 @@ EOF # Navigation print "$Message[72] : "; print ""; + if ($ShowSessionsStats) { print "$Message[117]   "; } if ($ShowPagesStats) { print "$Message[29]   "; } if ($ShowPagesStats) { print "$Message[104]   "; } + if ($ShowPagesStats) { print "$Message[116]   "; } if ($ShowFileTypesStats) { print "$Message[73]   "; } if ($ShowFileSizesStats) { } if ($ShowOSStats) { print "$Message[59]   "; } @@ -4458,11 +4486,31 @@ EOF &tab_end; } + # BY SESSION + #---------------------------- + if ($ShowSessionsStats) { + if ($Debug) { debug("ShowSessionsStats",2); } + print "$CENTER 
"; + &tab_head($Message[117],19); + print "$Message[117]$Message[10]\n"; + $total_s=0; + my $count=0; + foreach my $key (keys %_session) { + $total_s+=$_session{$key}; + print "$key$_session{$key}\n"; + $count++; + } + if ($TotalVisits > $total_s) { + print "$Message[0]".($TotalVisits-$total_s)."\n"; + } + &tab_end; + } + # BY URL #------------------------- if ($ShowPagesStats) { if ($Debug) { debug("ShowPagesStats (MaxNbOfPageShown=$MaxNbOfPageShown TotalDifferentPages=$TotalDifferentPages)",2); } - print "$CENTER  
"; + print "$CENTER   
"; $MaxNbOfPageShown = $TotalDifferentPages if $MaxNbOfPageShown > $TotalDifferentPages; &tab_head("$Message[19] ($Message[77] $MaxNbOfPageShown)   -   $Message[80]",19); print "$TotalDifferentPages $Message[28]";