) {
if ( !print ARCHIVELOG $_ ) { $archiveok = 0; last; }
}
close(ARCHIVELOG)
|| error("Archiving failed during closing archive: $!");
if ($SaveDatabaseFilesWithPermissionsForEveryone) {
chmod 0666, "$ArchiveFileName";
}
if ($Debug) { debug("End of archiving log file"); }
}
# If rename and archive ok
if ( $renameok && $archiveok ) {
if ($Debug) { debug("Purge log file"); }
my $bold = ( $ENV{'GATEWAY_INTERFACE'} ? '' : '' );
my $unbold = ( $ENV{'GATEWAY_INTERFACE'} ? '' : '' );
my $br = ( $ENV{'GATEWAY_INTERFACE'} ? '
' : '' );
truncate( LOG, 0 )
|| warning(
"Warning: $bold$PROG$unbold couldn't purge logfile \"$bold$LogFile$unbold\".$br\nChange your logfile permissions to allow write for your web server CGI process or change PurgeLogFile=1 into PurgeLogFile=0 in configure file and think to purge sometimes manually your logfile (just after running an update process to not loose any not already processed records your log file contains)."
);
}
close(LOG);
}
if ( $DNSLookup == 1 && $DNSLookupAlreadyDone ) {
# DNSLookup warning
my $bold = ( $ENV{'GATEWAY_INTERFACE'} ? '' : '' );
my $unbold = ( $ENV{'GATEWAY_INTERFACE'} ? '' : '' );
my $br = ( $ENV{'GATEWAY_INTERFACE'} ? '
' : '' );
warning(
"Warning: $bold$PROG$unbold has detected that some hosts names were already resolved in your logfile $bold$DNSLookupAlreadyDone$unbold.$br\nIf DNS lookup was already made by the logger (web server), you should change your setup DNSLookup=$DNSLookup into DNSLookup=0 to increase $PROG speed."
);
}
if ( $DNSLookup == 1 && $NbOfNewLines ) {
# Save new DNS last update cache file
Save_DNS_Cache_File( \%TmpDNSLookup, "$DirData/$DNSLastUpdateCacheFile",
"$FileSuffix" ); # Save into file using FileSuffix
}
if ($EnableLockForUpdate) {
# Remove lock
&Lock_Update(0);
# Restore signals handler
$SIG{INT} = 'DEFAULT'; # 2
#$SIG{KILL} = 'DEFAULT'; # 9
#$SIG{TERM} = 'DEFAULT'; # 15
}
}
# End of log processing if ($UPdateStats)
#---------------------------------------------------------------------
# SHOW REPORT
#---------------------------------------------------------------------
if ( scalar keys %HTMLOutput ) {
debug( "YearRequired=$YearRequired, MonthRequired=$MonthRequired", 2 );
debug( "DayRequired=$DayRequired, HourRequired=$HourRequired", 2 );
my $max_p;
my $max_h;
my $max_k;
my $max_v;
my $total_u;
my $total_v;
my $total_p;
my $total_h;
my $total_k;
my $total_e;
my $total_x;
my $total_s;
my $total_l;
my $total_r;
my $average_u;
my $average_v;
my $average_p;
my $average_h;
my $average_k;
my $average_s;
my $rest_p;
my $rest_h;
my $rest_k;
my $rest_e;
my $rest_x;
my $rest_s;
my $rest_l;
my $rest_r;
my $average_nb;
# Define the NewLinkParams for main chart
my $NewLinkParams = ${QueryString};
$NewLinkParams =~ s/(^|&|&)update(=\w*|$)//i;
$NewLinkParams =~ s/(^|&|&)output(=\w*|$)//i;
$NewLinkParams =~ s/(^|&|&)staticlinks(=\w*|$)//i;
$NewLinkParams =~ s/(^|&|&)framename=[^&]*//i;
my $NewLinkTarget = '';
if ($DetailedReportsOnNewWindows) {
$NewLinkTarget = " target=\"awstatsbis\"";
}
if ( ( $FrameName eq 'mainleft' || $FrameName eq 'mainright' )
&& $DetailedReportsOnNewWindows < 2 )
{
$NewLinkParams .= "&framename=mainright";
$NewLinkTarget = " target=\"mainright\"";
}
$NewLinkParams =~ s/(&|&)+/&/i;
$NewLinkParams =~ s/^&//;
$NewLinkParams =~ s/&$//;
if ($NewLinkParams) { $NewLinkParams = "${NewLinkParams}&"; }
if ( $FrameName ne 'mainleft' ) {
# READING DATA
#-------------
&Init_HashArray();
# Lecture des fichiers history
if ( $DatabaseBreak eq 'month' ) {
for ( my $ix = 12 ; $ix >= 1 ; $ix-- ) {
my $stringforload = '';
my $monthix = sprintf( "%02s", $ix );
if ( $MonthRequired eq 'all' || $monthix eq $MonthRequired ) {
$stringforload = 'all'; # Read full history file
}
elsif ( ( $HTMLOutput{'main'} && $ShowMonthStats )
|| $HTMLOutput{'alldays'} )
{
$stringforload =
'general time'; # Read general and time sections.
}
if ($stringforload) {
# On charge fichier
&Read_History_With_TmpUpdate( $YearRequired, $monthix, '',
'', 0, 0, $stringforload );
}
}
}
if ( $DatabaseBreak eq 'day' ) {
my $stringforload = 'all';
my $monthix = sprintf( "%02s", $MonthRequired );
my $dayix = sprintf( "%02s", $DayRequired );
&Read_History_With_TmpUpdate( $YearRequired, $monthix, $dayix, '',
0, 0, $stringforload );
}
if ( $DatabaseBreak eq 'hour' ) {
my $stringforload = 'all';
my $monthix = sprintf( "%02s", $MonthRequired );
my $dayix = sprintf( "%02s", $DayRequired );
my $hourix = sprintf( "%02s", $HourRequired );
&Read_History_With_TmpUpdate( $YearRequired, $monthix, $dayix,
$hourix, 0, 0, $stringforload );
}
}
# HTMLHeadSection
if ( $FrameName ne 'index' && $FrameName ne 'mainleft' ) {
print "\n\n";
my $newhead = $HTMLHeadSection;
$newhead =~ s/\\n/\n/g;
print "$newhead\n";
print "\n";
}
# Call to plugins' function AddHTMLBodyHeader
foreach my $pluginname ( keys %{ $PluginsLoaded{'AddHTMLBodyHeader'} } ) {
# my $function="AddHTMLBodyHeader_$pluginname()";
# eval("$function");
my $function = "AddHTMLBodyHeader_$pluginname";
&$function();
}
my $WIDTHMENU1 = ( $FrameName eq 'mainleft' ? $FRAMEWIDTH : 150 );
# TOP BAN
#---------------------------------------------------------------------
if ( $ShowMenu || $FrameName eq 'mainleft' ) {
my $frame = ( $FrameName eq 'mainleft' );
if ($Debug) { debug( "ShowTopBan", 2 ); }
print "$Center \n";
if ( $FrameName ne 'mainleft' ) {
my $NewLinkParams = ${QueryString};
$NewLinkParams =~ s/(^|&|&)update(=\w*|$)//i;
$NewLinkParams =~ s/(^|&|&)staticlinks(=\w*|$)//i;
$NewLinkParams =~ s/(^|&|&)year=[^&]*//i;
$NewLinkParams =~ s/(^|&|&)month=[^&]*//i;
$NewLinkParams =~ s/(^|&|&)framename=[^&]*//i;
$NewLinkParams =~ s/(&|&)+/&/i;
$NewLinkParams =~ s/^&//;
$NewLinkParams =~ s/&$//;
my $NewLinkTarget = '';
if ( $FrameName eq 'mainright' ) {
$NewLinkTarget = " target=\"_parent\"";
}
print "\n"; }
else { print "
\n"; }
print "\n";
}
# Call to plugins' function AddHTMLMenuHeader
foreach my $pluginname ( keys %{ $PluginsLoaded{'AddHTMLMenuHeader'} } ) {
# my $function="AddHTMLMenuHeader_$pluginname()";
# eval("$function");
my $function = "AddHTMLMenuHeader_$pluginname";
&$function();
}
# MENU (ON LEFT IF FRAME OR TOP)
#---------------------------------------------------------------------
if ( $ShowMenu || $FrameName eq 'mainleft' ) {
my $frame = ( $FrameName eq 'mainleft' );
if ($Debug) { debug( "ShowMenu", 2 ); }
# Print menu links
if ( ( $HTMLOutput{'main'} && $FrameName ne 'mainright' )
|| $FrameName eq 'mainleft' )
{ # If main page asked
# Define link anchor
my $linkanchor =
( $FrameName eq 'mainleft' ? "$AWScript?${NewLinkParams}" : "" );
if ( $linkanchor && ( $linkanchor !~ /framename=mainright/ ) ) {
$linkanchor .= "framename=mainright";
}
$linkanchor =~ s/(&|&)$//;
$linkanchor = XMLEncode("$linkanchor");
# Define target
my $targetpage =
( $FrameName eq 'mainleft' ? " target=\"mainright\"" : "" );
# Print Menu
my $linetitle; # TODO a virer
if ( !$PluginsLoaded{'ShowMenu'}{'menuapplet'} ) {
my $menuicon = 0; # TODO a virer
# Menu HTML
print "\n";
if ( $FrameName eq 'mainleft' && $ShowMonthStats ) {
print( $frame? "| " : "" );
print
"$Message[128]";
print( $frame? " |
\n" : " " );
}
my %menu = ();
my %menulink = ();
my %menutext = ();
# When
%menu = (
'month' => $ShowMonthStats ? 1 : 0,
'daysofmonth' => $ShowDaysOfMonthStats ? 2 : 0,
'daysofweek' => $ShowDaysOfWeekStats ? 3 : 0,
'hours' => $ShowHoursStats ? 4 : 0
);
%menulink = (
'month' => 1,
'daysofmonth' => 1,
'daysofweek' => 1,
'hours' => 1
);
%menutext = (
'month' => $Message[162],
'daysofmonth' => $Message[138],
'daysofweek' => $Message[91],
'hours' => $Message[20]
);
ShowMenuCateg(
'when', $Message[93],
'menu4.png', $frame,
$targetpage, $linkanchor,
$NewLinkParams, $NewLinkTarget,
\%menu, \%menulink,
\%menutext
);
# Who
%menu = (
'countries' => $ShowDomainsStats ? 1 : 0,
'alldomains' => $ShowDomainsStats ? 2 : 0,
'visitors' => $ShowHostsStats ? 3 : 0,
'allhosts' => $ShowHostsStats ? 4 : 0,
'lasthosts' => ( $ShowHostsStats =~ /L/i ) ? 5 : 0,
'unknownip' => $ShowHostsStats ? 6 : 0,
'logins' => $ShowAuthenticatedUsers ? 7 : 0,
'alllogins' => $ShowAuthenticatedUsers ? 8 : 0,
'lastlogins' => ( $ShowAuthenticatedUsers =~ /L/i ) ? 9 : 0,
'emailsenders' => $ShowEMailSenders ? 10 : 0,
'allemails' => $ShowEMailSenders ? 11 : 0,
'lastemails' => ( $ShowEMailSenders =~ /L/i ) ? 12 : 0,
'emailreceivers' => $ShowEMailReceivers ? 13 : 0,
'allemailr' => $ShowEMailReceivers ? 14 : 0,
'lastemailr' => ( $ShowEMailReceivers =~ /L/i ) ? 15 : 0,
'robots' => $ShowRobotsStats ? 16 : 0,
'allrobots' => $ShowRobotsStats ? 17 : 0,
'lastrobots' => ( $ShowRobotsStats =~ /L/i ) ? 18 : 0,
'worms' => $ShowWormsStats ? 19 : 0
);
%menulink = (
'countries' => 1,
'alldomains' => 2,
'visitors' => 1,
'allhosts' => 2,
'lasthosts' => 2,
'unknownip' => 2,
'logins' => 1,
'alllogins' => 2,
'lastlogins' => 2,
'emailsenders' => 1,
'allemails' => 2,
'lastemails' => 2,
'emailreceivers' => 1,
'allemailr' => 2,
'lastemailr' => 2,
'robots' => 1,
'allrobots' => 2,
'lastrobots' => 2,
'worms' => 1
);
%menutext = (
'countries' => $Message[148],
'alldomains' => $Message[80],
'visitors' => $Message[81],
'allhosts' => $Message[80],
'lasthosts' => $Message[9],
'unknownip' => $Message[45],
'logins' => $Message[94],
'alllogins' => $Message[80],
'lastlogins' => $Message[9],
'emailsenders' => $Message[131],
'allemails' => $Message[80],
'lastemails' => $Message[9],
'emailreceivers' => $Message[132],
'allemailr' => $Message[80],
'lastemailr' => $Message[9],
'robots' => $Message[53],
'allrobots' => $Message[80],
'lastrobots' => $Message[9],
'worms' => $Message[136]
);
ShowMenuCateg(
'who', $Message[92],
'menu5.png', $frame,
$targetpage, $linkanchor,
$NewLinkParams, $NewLinkTarget,
\%menu, \%menulink,
\%menutext
);
# Navigation
$linetitle = &AtLeastOneNotNull(
$ShowSessionsStats, $ShowPagesStats,
$ShowFileTypesStats, $ShowFileSizesStats,
$ShowOSStats, $ShowBrowsersStats,
$ShowScreenSizeStats
);
if ($linetitle) {
print ""
. (
$menuicon
? " "
: ""
)
. "$Message[72]: | \n";
}
if ($linetitle) {
print( $frame? "
\n" : "" );
}
if ($ShowSessionsStats) {
print( $frame? " | | " : "" );
print
"$Message[117]";
print( $frame? " |
\n" : " " );
}
if ($ShowFileTypesStats) {
print( $frame? "| " : "" );
print
"$Message[73]";
print( $frame? " |
\n" : " " );
}
if ($ShowPagesStats) {
print( $frame? "| " : "" );
print
"$Message[29]\n";
print( $frame? " |
\n" : " " );
}
if ($ShowPagesStats) {
print( $frame
? " "
: ""
);
print "$Message[80]\n";
print( $frame? " |
\n" : " " );
}
if ( $ShowPagesStats =~ /E/i ) {
print( $frame
? " "
: ""
);
print "$Message[104]\n";
print( $frame? " |
\n" : " " );
}
if ( $ShowPagesStats =~ /X/i ) {
print( $frame
? " "
: ""
);
print "$Message[116]\n";
print( $frame? " |
\n" : " " );
}
if ($ShowOSStats) {
print( $frame? "| " : "" );
print
"$Message[59]";
print( $frame? " |
\n" : " " );
}
if ($ShowOSStats) {
print( $frame
? " "
: ""
);
print "$Message[58]\n";
print( $frame? " |
\n" : " " );
}
if ($ShowOSStats) {
print( $frame
? " "
: ""
);
print "$Message[0]\n";
print( $frame? " |
\n" : " " );
}
if ($ShowBrowsersStats) {
print( $frame? "| " : "" );
print
"$Message[21]";
print( $frame? " |
\n" : " " );
}
if ($ShowBrowsersStats) {
print( $frame
? " "
: ""
);
print "$Message[58]\n";
print( $frame? " |
\n" : " " );
}
if ($ShowBrowsersStats) {
print( $frame
? " "
: ""
);
print "$Message[0]\n";
print( $frame? " |
\n" : " " );
}
if ($ShowScreenSizeStats) {
print( $frame? "| " : "" );
print
"$Message[135]";
print( $frame? " |
\n" : " " );
}
if ($linetitle) { print( $frame? "" : "\n" ); }
# Referers
%menu = (
'referer' => $ShowOriginStats ? 1 : 0,
'refererse' => $ShowOriginStats ? 2 : 0,
'refererpages' => $ShowOriginStats ? 3 : 0,
'keys' => ( $ShowKeyphrasesStats || $ShowKeywordsStats )
? 4
: 0,
'keyphrases' => $ShowKeyphrasesStats ? 5 : 0,
'keywords' => $ShowKeywordsStats ? 6 : 0
);
%menulink = (
'referer' => 1,
'refererse' => 2,
'refererpages' => 2,
'keys' => 1,
'keyphrases' => 2,
'keywords' => 2
);
%menutext = (
'referer' => $Message[37],
'refererse' => $Message[126],
'refererpages' => $Message[127],
'keys' => $Message[14],
'keyphrases' => $Message[120],
'keywords' => $Message[121]
);
ShowMenuCateg(
'referers', $Message[23],
'menu7.png', $frame,
$targetpage, $linkanchor,
$NewLinkParams, $NewLinkTarget,
\%menu, \%menulink,
\%menutext
);
# Others
%menu = (
'filetypes' => ( $ShowFileTypesStats =~ /C/i ) ? 1 : 0,
'misc' => $ShowMiscStats ? 2 : 0,
'errors' => ( $ShowHTTPErrorsStats || $ShowSMTPErrorsStats )
? 3
: 0,
'clusters' => $ShowClusterStats ? 5 : 0
);
%menulink = (
'filetypes' => 1,
'misc' => 1,
'errors' => 1,
'clusters' => 1
);
%menutext = (
'filetypes' => $Message[98],
'misc' => $Message[139],
'errors' =>
( $ShowSMTPErrorsStats ? $Message[147] : $Message[32] ),
'clusters' => $Message[155]
);
foreach ( keys %TrapInfosForHTTPErrorCodes ) {
$menu{"errors$_"} = $ShowHTTPErrorsStats ? 4 : 0;
$menulink{"errors$_"} = 2;
$menutext{"errors$_"} = $Message[31];
}
ShowMenuCateg(
'others', $Message[2],
'menu8.png', $frame,
$targetpage, $linkanchor,
$NewLinkParams, $NewLinkTarget,
\%menu, \%menulink,
\%menutext
);
# Extra/Marketing
%menu = ();
%menulink = ();
%menutext = ();
my $i = 1;
foreach ( 1 .. @ExtraName - 1 ) {
$menu{"extra$_"} = $i++;
$menulink{"extra$_"} = 1;
$menutext{"extra$_"} = $ExtraName[$_];
$menu{"allextra$_"} = $i++;
$menulink{"allextra$_"} = 2;
$menutext{"allextra$_"} = $Message[80];
}
ShowMenuCateg(
'extra', $Message[134],
'', $frame,
$targetpage, $linkanchor,
$NewLinkParams, $NewLinkTarget,
\%menu, \%menulink,
\%menutext
);
print "
\n";
}
else {
# Menu Applet
if ($frame) { }
else { }
}
#print ($frame?"":"
\n");
print "
\n";
}
# Print Back link
elsif ( !$HTMLOutput{'main'} ) {
print "\n";
$NewLinkParams =~ s/(^|&|&)hostfilter=[^&]*//i;
$NewLinkParams =~ s/(^|&|&)urlfilter=[^&]*//i;
$NewLinkParams =~ s/(^|&|&)refererpagesfilter=[^&]*//i;
$NewLinkParams =~ s/(&|&)+/&/i;
$NewLinkParams =~ s/^&//;
$NewLinkParams =~ s/&$//;
if ( !$DetailedReportsOnNewWindows
|| $FrameName eq 'mainright'
|| $QueryString =~ /buildpdf/i )
{
print "| $Message[76] |
\n";
}
else {
print
"| $Message[118] |
\n";
}
print "
\n";
print "\n";
}
}
# Call to plugins' function AddHTMLMenuFooter
foreach my $pluginname ( keys %{ $PluginsLoaded{'AddHTMLMenuFooter'} } ) {
# my $function="AddHTMLMenuFooter_$pluginname()";
# eval("$function");
my $function = "AddHTMLMenuFooter_$pluginname";
&$function();
}
# Exit if left frame
if ( $FrameName eq 'mainleft' ) {
&html_end(0);
exit 0;
}
# FirstTime LastTime
my $FirstTime = 0;
my $LastTime = 0;
foreach my $key ( keys %FirstTime ) {
my $keyqualified = 0;
if ( $MonthRequired eq 'all' ) { $keyqualified = 1; }
if ( $key =~ /^$YearRequired$MonthRequired/ ) { $keyqualified = 1; }
if ($keyqualified) {
if ( $FirstTime{$key}
&& ( $FirstTime == 0 || $FirstTime > $FirstTime{$key} ) )
{
$FirstTime = $FirstTime{$key};
}
if ( $LastTime < ( $LastTime{$key} || 0 ) ) {
$LastTime = $LastTime{$key};
}
}
}
# TotalVisits TotalUnique TotalPages TotalHits TotalBytes TotalHostsKnown TotalHostsUnknown
$TotalUnique = $TotalVisits = $TotalPages = $TotalHits = $TotalBytes = 0;
$TotalNotViewedPages = $TotalNotViewedHits = $TotalNotViewedBytes = 0;
$TotalHostsKnown = $TotalHostsUnknown = 0;
my $beginmonth = $MonthRequired;
my $endmonth = $MonthRequired;
if ( $MonthRequired eq 'all' ) { $beginmonth = 1; $endmonth = 12; }
for ( my $month = $beginmonth ; $month <= $endmonth ; $month++ ) {
my $monthix = sprintf( "%02s", $month );
$TotalHostsKnown += $MonthHostsKnown{ $YearRequired . $monthix }
|| 0; # Wrong in year view
$TotalHostsUnknown += $MonthHostsUnknown{ $YearRequired . $monthix }
|| 0; # Wrong in year view
$TotalUnique += $MonthUnique{ $YearRequired . $monthix }
|| 0; # Wrong in year view
$TotalVisits += $MonthVisits{ $YearRequired . $monthix }
|| 0; # Not completely true
$TotalPages += $MonthPages{ $YearRequired . $monthix } || 0;
$TotalHits += $MonthHits{ $YearRequired . $monthix } || 0;
$TotalBytes += $MonthBytes{ $YearRequired . $monthix } || 0;
$TotalNotViewedPages += $MonthNotViewedPages{ $YearRequired . $monthix }
|| 0;
$TotalNotViewedHits += $MonthNotViewedHits{ $YearRequired . $monthix }
|| 0;
$TotalNotViewedBytes += $MonthNotViewedBytes{ $YearRequired . $monthix }
|| 0;
}
# TotalHitsErrors TotalBytesErrors
my $TotalHitsErrors = 0;
my $TotalBytesErrors = 0;
foreach ( keys %_errors_h ) {
# print "xxxx".$_." zzz".$_errors_h{$_};
$TotalHitsErrors += $_errors_h{$_};
$TotalBytesErrors += $_errors_k{$_};
}
# TotalEntries (if not already specifically counted, we init it from _url_e hash table)
if ( !$TotalEntries ) {
foreach ( keys %_url_e ) { $TotalEntries += $_url_e{$_}; }
}
# TotalExits (if not already specifically counted, we init it from _url_x hash table)
if ( !$TotalExits ) {
foreach ( keys %_url_x ) { $TotalExits += $_url_x{$_}; }
}
# TotalBytesPages (if not already specifically counted, we init it from _url_k hash table)
if ( !$TotalBytesPages ) {
foreach ( keys %_url_k ) { $TotalBytesPages += $_url_k{$_}; }
}
# TotalKeyphrases (if not already specifically counted, we init it from _keyphrases hash table)
if ( !$TotalKeyphrases ) {
foreach ( keys %_keyphrases ) { $TotalKeyphrases += $_keyphrases{$_}; }
}
# TotalKeywords (if not already specifically counted, we init it from _keywords hash table)
if ( !$TotalKeywords ) {
foreach ( keys %_keywords ) { $TotalKeywords += $_keywords{$_}; }
}
# TotalSearchEnginesPages (if not already specifically counted, we init it from _se_referrals_p hash table)
if ( !$TotalSearchEnginesPages ) {
foreach ( keys %_se_referrals_p ) {
$TotalSearchEnginesPages += $_se_referrals_p{$_};
}
}
# TotalSearchEnginesHits (if not already specifically counted, we init it from _se_referrals_h hash table)
if ( !$TotalSearchEnginesHits ) {
foreach ( keys %_se_referrals_h ) {
$TotalSearchEnginesHits += $_se_referrals_h{$_};
}
}
# TotalRefererPages (if not already specifically counted, we init it from _pagesrefs_p hash table)
if ( !$TotalRefererPages ) {
foreach ( keys %_pagesrefs_p ) {
$TotalRefererPages += $_pagesrefs_p{$_};
}
}
# TotalRefererHits (if not already specifically counted, we init it from _pagesrefs_h hash table)
if ( !$TotalRefererHits ) {
foreach ( keys %_pagesrefs_h ) {
$TotalRefererHits += $_pagesrefs_h{$_};
}
}
# TotalDifferentPages (if not already specifically counted, we init it from _url_p hash table)
$TotalDifferentPages ||= scalar keys %_url_p;
# TotalDifferentKeyphrases (if not already specifically counted, we init it from _keyphrases hash table)
$TotalDifferentKeyphrases ||= scalar keys %_keyphrases;
# TotalDifferentKeywords (if not already specifically counted, we init it from _keywords hash table)
$TotalDifferentKeywords ||= scalar keys %_keywords;
# TotalDifferentSearchEngines (if not already specifically counted, we init it from _se_referrals_h hash table)
$TotalDifferentSearchEngines ||= scalar keys %_se_referrals_h;
# TotalDifferentReferer (if not already specifically counted, we init it from _pagesrefs_h hash table)
$TotalDifferentReferer ||= 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
my $lastdaytocountaverage =
$nowyear . $nowmonth . $nowday; # Set day cursor to today
my $lastdaytoshowtime =
$nowyear . $nowmonth . "31"; # Set day cursor to last day of month
if ( $MonthRequired eq 'all' ) {
$firstdaytocountaverage =
$YearRequired
. "0101"; # Set day cursor to 1st day of the required year
}
if ( ( $MonthRequired ne $nowmonth && $MonthRequired ne 'all' )
|| $YearRequired ne $nowyear )
{
if ( $MonthRequired eq 'all' ) {
$firstdaytocountaverage =
$YearRequired
. "0101"; # Set day cursor to 1st day of the required year
$firstdaytoshowtime =
$YearRequired . "1201"
; # Set day cursor to 1st day of last month of required year
$lastdaytocountaverage =
$YearRequired
. "1231"; # Set day cursor to last day of the required year
$lastdaytoshowtime =
$YearRequired . "1231"
; # Set day cursor to last day of last month of required year
}
else {
$firstdaytocountaverage =
$YearRequired
. $MonthRequired
. "01"; # Set day cursor to 1st day of the required month
$firstdaytoshowtime =
$YearRequired
. $MonthRequired
. "01"; # Set day cursor to 1st day of the required month
$lastdaytocountaverage =
$YearRequired
. $MonthRequired
. "31"; # Set day cursor to last day of the required month
$lastdaytoshowtime =
$YearRequired
. $MonthRequired
. "31"; # Set day cursor to last day of the required month
}
}
if ($Debug) {
debug(
"firstdaytocountaverage=$firstdaytocountaverage, lastdaytocountaverage=$lastdaytocountaverage",
1
);
debug(
"firstdaytoshowtime=$firstdaytoshowtime, lastdaytoshowtime=$lastdaytoshowtime",
1
);
}
# Call to plugins' function AddHTMLContentHeader
foreach my $pluginname ( keys %{ $PluginsLoaded{'AddHTMLContentHeader'} } )
{
# my $function="AddHTMLContentHeader_$pluginname()";
# eval("$function");
# to add unique visitors & number of visits, by J Ruano @ CAPSiDE
if ( $ShowDomainsStats =~ /U/i ) {
print "$Message[11] | ";
}
if ( $ShowDomainsStats =~ /V/i ) {
print "$Message[10] | ";
}
my $function = "AddHTMLContentHeader_$pluginname";
&$function();
}
# Output particular part
#-----------------------
if ( scalar keys %HTMLOutput == 1 ) {
if ( $HTMLOutput{'alldomains'} ) {
print "$Center
\n";
# Show domains list
my $title = '';
my $cpt = 0;
if ( $HTMLOutput{'alldomains'} ) {
$title .= "$Message[25]";
$cpt = ( scalar keys %_domener_h );
}
&tab_head( "$title", 19, 0, 'domains' );
print
"| | $Message[17] | ";
if ( $ShowDomainsStats =~ /U/i ) {
print
"$Message[11] | ";
}
if ( $ShowDomainsStats =~ /V/i ) {
print
"$Message[10] | ";
}
if ( $ShowDomainsStats =~ /P/i ) {
print
"$Message[56] | ";
}
if ( $ShowDomainsStats =~ /H/i ) {
print
"$Message[57] | ";
}
if ( $ShowDomainsStats =~ /B/i ) {
print
"$Message[75] | ";
}
print " | ";
print "
\n";
$total_u = $total_v = $total_p = $total_h = $total_k = 0;
$max_h = 1;
foreach ( values %_domener_h ) {
if ( $_ > $max_h ) { $max_h = $_; }
}
$max_k = 1;
foreach ( values %_domener_k ) {
if ( $_ > $max_k ) { $max_k = $_; }
}
my $count = 0;
&BuildKeyList( $MaxRowsInHTMLOutput, 1, \%_domener_h,
\%_domener_p );
foreach my $key (@keylist) {
my ( $_domener_u, $_domener_v );
my $bredde_p = 0;
my $bredde_h = 0;
my $bredde_k = 0;
if ( $max_h > 0 ) {
$bredde_p =
int( $BarWidth * $_domener_p{$key} / $max_h ) + 1;
} # use max_h to enable to compare pages with hits
if ( $_domener_p{$key} && $bredde_p == 1 ) { $bredde_p = 2; }
if ( $max_h > 0 ) {
$bredde_h =
int( $BarWidth * $_domener_h{$key} / $max_h ) + 1;
}
if ( $_domener_h{$key} && $bredde_h == 1 ) { $bredde_h = 2; }
if ( $max_k > 0 ) {
$bredde_k =
int( $BarWidth * ( $_domener_k{$key} || 0 ) / $max_k ) +
1;
}
if ( $_domener_k{$key} && $bredde_k == 1 ) { $bredde_k = 2; }
my $newkey = lc($key);
if ( $newkey eq 'ip' || !$DomainsHashIDLib{$newkey} ) {
print
" | $Message[0] | $newkey | ";
}
else {
print
"
 | $DomainsHashIDLib{$newkey} | $newkey | ";
}
## to add unique visitors and number of visits, by Josep Ruano @ CAPSiDE
if ( $ShowDomainsStats =~ /U/i ) {
$_domener_u = (
$_domener_p{$key}
? $_domener_p{$key} / $TotalPages
: 0
);
$_domener_u += ( $_domener_h{$key} / $TotalHits );
$_domener_u =
sprintf( "%.0f", ( $_domener_u * $TotalUnique ) / 2 );
print "$_domener_u ("
. sprintf( "%.1f%", 100 * $_domener_u / $TotalUnique )
. ") | ";
}
if ( $ShowDomainsStats =~ /V/i ) {
$_domener_v = (
$_domener_p{$key}
? $_domener_p{$key} / $TotalPages
: 0
);
$_domener_v += ( $_domener_h{$key} / $TotalHits );
$_domener_v =
sprintf( "%.0f", ( $_domener_v * $TotalVisits ) / 2 );
print "$_domener_v ("
. sprintf( "%.1f%", 100 * $_domener_v / $TotalVisits )
. ") | ";
}
if ( $ShowDomainsStats =~ /P/i ) {
print "$_domener_p{$key} | ";
}
if ( $ShowDomainsStats =~ /H/i ) {
print "$_domener_h{$key} | ";
}
if ( $ShowDomainsStats =~ /B/i ) {
print "" . Format_Bytes( $_domener_k{$key} ) . " | ";
}
print "";
if ( $ShowDomainsStats =~ /P/i ) {
print
" \n";
}
if ( $ShowDomainsStats =~ /H/i ) {
print
" \n";
}
if ( $ShowDomainsStats =~ /B/i ) {
print
" ";
}
print " | ";
print "
\n";
$total_u += $_domener_u;
$total_v += $_domener_v;
$total_p += $_domener_p{$key};
$total_h += $_domener_h{$key};
$total_k += $_domener_k{$key} || 0;
$count++;
}
my $rest_u = $TotalUnique - $total_u;
my $rest_v = $TotalVisits - $total_v;
$rest_p = $TotalPages - $total_p;
$rest_h = $TotalHits - $total_h;
$rest_k = $TotalBytes - $total_k;
if ( $rest_u > 0
|| $rest_v > 0
|| $rest_p > 0
|| $rest_h > 0
|| $rest_k > 0 )
{ # All other domains (known or not)
print
"| | $Message[2] | ";
if ( $ShowDomainsStats =~ /U/i ) { print "$rest_u | "; }
if ( $ShowDomainsStats =~ /V/i ) { print "$rest_v | "; }
if ( $ShowDomainsStats =~ /P/i ) { print "$rest_p | "; }
if ( $ShowDomainsStats =~ /H/i ) { print "$rest_h | "; }
if ( $ShowDomainsStats =~ /B/i ) {
print "" . Format_Bytes($rest_k) . " | ";
}
print " | ";
print "
\n";
}
&tab_end();
&html_end(1);
}
if ( $HTMLOutput{'allhosts'} || $HTMLOutput{'lasthosts'} ) {
print "$Center
\n";
# Show filter form
&ShowFormFilter( "hostfilter", $FilterIn{'host'},
$FilterEx{'host'} );
# Show hosts list
my $title = '';
my $cpt = 0;
if ( $HTMLOutput{'allhosts'} ) {
$title .= "$Message[81]";
$cpt = ( scalar keys %_host_h );
}
if ( $HTMLOutput{'lasthosts'} ) {
$title .= "$Message[9]";
$cpt = ( scalar keys %_host_h );
}
&tab_head( "$title", 19, 0, 'hosts' );
print "";
if ( $FilterIn{'host'} || $FilterEx{'host'} ) { # With filter
if ( $FilterIn{'host'} ) {
print "$Message[79] '$FilterIn{'host'}'";
}
if ( $FilterIn{'host'} && $FilterEx{'host'} ) { print " - "; }
if ( $FilterEx{'host'} ) {
print " Exlude $Message[79] '$FilterEx{'host'}'";
}
if ( $FilterIn{'host'} || $FilterEx{'host'} ) { print ": "; }
print "$cpt $Message[81]";
if ( $MonthRequired ne 'all' ) {
if ( $HTMLOutput{'allhosts'} || $HTMLOutput{'lasthosts'} ) {
print
" $Message[102]: $TotalHostsKnown $Message[82], $TotalHostsUnknown $Message[1] - $TotalUnique $Message[11]";
}
}
}
else { # Without filter
if ( $MonthRequired ne 'all' ) {
print
"$Message[102] : $TotalHostsKnown $Message[82], $TotalHostsUnknown $Message[1] - $TotalUnique $Message[11]";
}
else { print "$Message[102] : " . ( scalar keys %_host_h ); }
}
print " | ";
&ShowHostInfo('__title__');
if ( $ShowHostsStats =~ /P/i ) {
print
"$Message[56] | ";
}
if ( $ShowHostsStats =~ /H/i ) {
print
"$Message[57] | ";
}
if ( $ShowHostsStats =~ /B/i ) {
print
"$Message[75] | ";
}
if ( $ShowHostsStats =~ /L/i ) {
print "$Message[9] | ";
}
print "
\n";
$total_p = $total_h = $total_k = 0;
my $count = 0;
if ( $HTMLOutput{'allhosts'} ) {
&BuildKeyList( $MaxRowsInHTMLOutput, $MinHit{'Host'}, \%_host_h,
\%_host_p );
}
if ( $HTMLOutput{'lasthosts'} ) {
&BuildKeyList( $MaxRowsInHTMLOutput, $MinHit{'Host'}, \%_host_h,
\%_host_l );
}
foreach my $key (@keylist) {
my $host = CleanXSS($key);
print "| "
. ( $_robot_l{$key} ? '' : '' ) . "$host"
. ( $_robot_l{$key} ? '' : '' ) . " | ";
&ShowHostInfo($key);
if ( $ShowHostsStats =~ /P/i ) {
print ""
. ( $_host_p{$key} ? $_host_p{$key} : " " )
. " | ";
}
if ( $ShowHostsStats =~ /H/i ) {
print "$_host_h{$key} | ";
}
if ( $ShowHostsStats =~ /B/i ) {
print "" . Format_Bytes( $_host_k{$key} ) . " | ";
}
if ( $ShowHostsStats =~ /L/i ) {
print ""
. (
$_host_l{$key}
? Format_Date( $_host_l{$key}, 1 )
: '-'
)
. " | ";
}
print "
\n";
$total_p += $_host_p{$key};
$total_h += $_host_h{$key};
$total_k += $_host_k{$key} || 0;
$count++;
}
if ($Debug) {
debug(
"Total real / shown : $TotalPages / $total_p - $TotalHits / $total_h - $TotalBytes / $total_h",
2
);
}
$rest_p = $TotalPages - $total_p;
$rest_h = $TotalHits - $total_h;
$rest_k = $TotalBytes - $total_k;
if ( $rest_p > 0 || $rest_h > 0 || $rest_k > 0 )
{ # All other visitors (known or not)
print
"| $Message[2] | ";
&ShowHostInfo('');
if ( $ShowHostsStats =~ /P/i ) {
print "" . ( $rest_p ? $rest_p : " " ) . " | ";
}
if ( $ShowHostsStats =~ /H/i ) { print "$rest_h | "; }
if ( $ShowHostsStats =~ /B/i ) {
print "" . Format_Bytes($rest_k) . " | ";
}
if ( $ShowHostsStats =~ /L/i ) { print " | "; }
print "
\n";
}
&tab_end();
&html_end(1);
}
if ( $HTMLOutput{'unknownip'} ) {
print "$Center
\n";
&tab_head( "$Message[45]", 19, 0, 'unknownwip' );
print "| "
. ( scalar keys %_host_h )
. " $Message[1] | ";
&ShowHostInfo('__title__');
if ( $ShowHostsStats =~ /P/i ) {
print
"$Message[56] | ";
}
if ( $ShowHostsStats =~ /H/i ) {
print
"$Message[57] | ";
}
if ( $ShowHostsStats =~ /B/i ) {
print
"$Message[75] | ";
}
if ( $ShowHostsStats =~ /L/i ) {
print "$Message[9] | ";
}
print "
\n";
$total_p = $total_h = $total_k = 0;
my $count = 0;
&BuildKeyList( $MaxRowsInHTMLOutput, $MinHit{'Host'}, \%_host_h,
\%_host_p );
foreach my $key (@keylist) {
my $host = CleanXSS($key);
print "| $host | ";
&ShowHostInfo($key);
if ( $ShowHostsStats =~ /P/i ) {
print ""
. ( $_host_p{$key} ? $_host_p{$key} : " " )
. " | ";
}
if ( $ShowHostsStats =~ /H/i ) {
print "$_host_h{$key} | ";
}
if ( $ShowHostsStats =~ /B/i ) {
print "" . Format_Bytes( $_host_k{$key} ) . " | ";
}
if ( $ShowHostsStats =~ /L/i ) {
print ""
. (
$_host_l{$key}
? Format_Date( $_host_l{$key}, 1 )
: '-'
)
. " | ";
}
print "
\n";
$total_p += $_host_p{$key};
$total_h += $_host_h{$key};
$total_k += $_host_k{$key} || 0;
$count++;
}
if ($Debug) {
debug(
"Total real / shown : $TotalPages / $total_p - $TotalHits / $total_h - $TotalBytes / $total_h",
2
);
}
$rest_p = $TotalPages - $total_p;
$rest_h = $TotalHits - $total_h;
$rest_k = $TotalBytes - $total_k;
if ( $rest_p > 0 || $rest_h > 0 || $rest_k > 0 )
{ # All other visitors (known or not)
print
"| $Message[82] | ";
&ShowHostInfo('');
if ( $ShowHostsStats =~ /P/i ) {
print "" . ( $rest_p ? $rest_p : " " ) . " | ";
}
if ( $ShowHostsStats =~ /H/i ) { print "$rest_h | "; }
if ( $ShowHostsStats =~ /B/i ) {
print "" . Format_Bytes($rest_k) . " | ";
}
if ( $ShowHostsStats =~ /L/i ) { print " | "; }
print "
\n";
}
&tab_end();
&html_end(1);
}
if ( $HTMLOutput{'allemails'} || $HTMLOutput{'lastemails'} ) {
&ShowEmailSendersChart( $NewLinkParams, $NewLinkTarget );
&html_end(1);
}
if ( $HTMLOutput{'allemailr'} || $HTMLOutput{'lastemailr'} ) {
&ShowEmailReceiversChart( $NewLinkParams, $NewLinkTarget );
&html_end(1);
}
if ( $HTMLOutput{'alllogins'} || $HTMLOutput{'lastlogins'} ) {
print "$Center
\n";
my $title = '';
if ( $HTMLOutput{'alllogins'} ) { $title .= "$Message[94]"; }
if ( $HTMLOutput{'lastlogins'} ) { $title .= "$Message[9]"; }
&tab_head( "$title", 19, 0, 'logins' );
print "| $Message[94] : "
. ( scalar keys %_login_h ) . " | ";
&ShowUserInfo('__title__');
if ( $ShowAuthenticatedUsers =~ /P/i ) {
print
"$Message[56] | ";
}
if ( $ShowAuthenticatedUsers =~ /H/i ) {
print
"$Message[57] | ";
}
if ( $ShowAuthenticatedUsers =~ /B/i ) {
print
"$Message[75] | ";
}
if ( $ShowAuthenticatedUsers =~ /L/i ) {
print "$Message[9] | ";
}
print "
\n";
$total_p = $total_h = $total_k = 0;
my $count = 0;
if ( $HTMLOutput{'alllogins'} ) {
&BuildKeyList( $MaxRowsInHTMLOutput, $MinHit{'Host'},
\%_login_h, \%_login_p );
}
if ( $HTMLOutput{'lastlogins'} ) {
&BuildKeyList( $MaxRowsInHTMLOutput, $MinHit{'Host'},
\%_login_h, \%_login_l );
}
foreach my $key (@keylist) {
print "| $key | ";
&ShowUserInfo($key);
if ( $ShowAuthenticatedUsers =~ /P/i ) {
print ""
. ( $_login_p{$key} ? $_login_p{$key} : " " )
. " | ";
}
if ( $ShowAuthenticatedUsers =~ /H/i ) {
print "$_login_h{$key} | ";
}
if ( $ShowAuthenticatedUsers =~ /B/i ) {
print "" . Format_Bytes( $_login_k{$key} ) . " | ";
}
if ( $ShowAuthenticatedUsers =~ /L/i ) {
print ""
. (
$_login_l{$key}
? Format_Date( $_login_l{$key}, 1 )
: '-'
)
. " | ";
}
print "
\n";
$total_p += $_login_p{$key} || 0;
$total_h += $_login_h{$key};
$total_k += $_login_k{$key} || 0;
$count++;
}
if ($Debug) {
debug(
"Total real / shown : $TotalPages / $total_p - $TotalHits / $total_h - $TotalBytes / $total_h",
2
);
}
$rest_p = $TotalPages - $total_p;
$rest_h = $TotalHits - $total_h;
$rest_k = $TotalBytes - $total_k;
if ( $rest_p > 0 || $rest_h > 0 || $rest_k > 0 )
{ # All other logins and/or anonymous
print
"| $Message[125] | ";
&ShowUserInfo('');
if ( $ShowAuthenticatedUsers =~ /P/i ) {
print "" . ( $rest_p ? $rest_p : " " ) . " | ";
}
if ( $ShowAuthenticatedUsers =~ /H/i ) {
print "$rest_h | ";
}
if ( $ShowAuthenticatedUsers =~ /B/i ) {
print "" . Format_Bytes($rest_k) . " | ";
}
if ( $ShowAuthenticatedUsers =~ /L/i ) {
print " | ";
}
print "
\n";
}
&tab_end();
&html_end(1);
}
if ( $HTMLOutput{'allrobots'} || $HTMLOutput{'lastrobots'} ) {
print "$Center
\n";
my $title = '';
if ( $HTMLOutput{'allrobots'} ) { $title .= "$Message[53]"; }
if ( $HTMLOutput{'lastrobots'} ) { $title .= "$Message[9]"; }
&tab_head( "$title", 19, 0, 'robots' );
print "| "
. ( scalar keys %_robot_h )
. " $Message[51] | ";
if ( $ShowRobotsStats =~ /H/i ) {
print
"$Message[57] | ";
}
if ( $ShowRobotsStats =~ /B/i ) {
print
"$Message[75] | ";
}
if ( $ShowRobotsStats =~ /L/i ) {
print "$Message[9] | ";
}
print "
\n";
$total_p = $total_h = $total_k = $total_r = 0;
my $count = 0;
if ( $HTMLOutput{'allrobots'} ) {
&BuildKeyList( $MaxRowsInHTMLOutput, $MinHit{'Robot'},
\%_robot_h, \%_robot_h );
}
if ( $HTMLOutput{'lastrobots'} ) {
&BuildKeyList( $MaxRowsInHTMLOutput, $MinHit{'Robot'},
\%_robot_h, \%_robot_l );
}
foreach my $key (@keylist) {
print "| "
. ( $RobotsHashIDLib{$key} ? $RobotsHashIDLib{$key} : $key )
. " | ";
if ( $ShowRobotsStats =~ /H/i ) {
print ""
. ( $_robot_h{$key} - $_robot_r{$key} )
. ( $_robot_r{$key} ? "+$_robot_r{$key}" : "" ) . " | ";
}
if ( $ShowRobotsStats =~ /B/i ) {
print "" . Format_Bytes( $_robot_k{$key} ) . " | ";
}
if ( $ShowRobotsStats =~ /L/i ) {
print ""
. (
$_robot_l{$key}
? Format_Date( $_robot_l{$key}, 1 )
: '-'
)
. " | ";
}
print "
\n";
#$total_p += $_robot_p{$key}||0;
$total_h += $_robot_h{$key};
$total_k += $_robot_k{$key} || 0;
$total_r += $_robot_r{$key} || 0;
$count++;
}
# For bots we need to count Totals
my $TotalPagesRobots =
0; #foreach (values %_robot_p) { $TotalPagesRobots+=$_; }
my $TotalHitsRobots = 0;
foreach ( values %_robot_h ) { $TotalHitsRobots += $_; }
my $TotalBytesRobots = 0;
foreach ( values %_robot_k ) { $TotalBytesRobots += $_; }
my $TotalRRobots = 0;
foreach ( values %_robot_r ) { $TotalRRobots += $_; }
$rest_p = 0; #$rest_p=$TotalPagesRobots-$total_p;
$rest_h = $TotalHitsRobots - $total_h;
$rest_k = $TotalBytesRobots - $total_k;
$rest_r = $TotalRRobots - $total_r;
if ($Debug) {
debug(
"Total real / shown : $TotalPagesRobots / $total_p - $TotalHitsRobots / $total_h - $TotalBytesRobots / $total_k",
2
);
}
if ( $rest_p > 0 || $rest_h > 0 || $rest_k > 0 || $rest_r > 0 )
{ # All other robots
print
"| $Message[2] | ";
if ( $ShowRobotsStats =~ /H/i ) { print "$rest_h | "; }
if ( $ShowRobotsStats =~ /B/i ) {
print "" . ( Format_Bytes($rest_k) ) . " | ";
}
if ( $ShowRobotsStats =~ /L/i ) { print " | "; }
print "
\n";
}
&tab_end(
"* $Message[156]" . ( $TotalRRobots ? " $Message[157]" : "" ) );
&html_end(1);
}
if ( $HTMLOutput{'urldetail'}
|| $HTMLOutput{'urlentry'}
|| $HTMLOutput{'urlexit'} )
{
# Call to plugins' function ShowPagesFilter
foreach
my $pluginname ( keys %{ $PluginsLoaded{'ShowPagesFilter'} } )
{
# my $function="ShowPagesFilter_$pluginname()";
# eval("$function");
my $function = "ShowPagesFilter_$pluginname";
&$function();
}
print "$Center
\n";
# Show filter form
&ShowFormFilter( "urlfilter", $FilterIn{'url'}, $FilterEx{'url'} );
# Show URL list
my $title = '';
my $cpt = 0;
if ( $HTMLOutput{'urldetail'} ) {
$title = $Message[19];
$cpt = ( scalar keys %_url_p );
}
if ( $HTMLOutput{'urlentry'} ) {
$title = $Message[104];
$cpt = ( scalar keys %_url_e );
}
if ( $HTMLOutput{'urlexit'} ) {
$title = $Message[116];
$cpt = ( scalar keys %_url_x );
}
&tab_head( "$title", 19, 0, 'urls' );
print "";
if ( $FilterIn{'url'} || $FilterEx{'url'} ) {
if ( $FilterIn{'url'} ) {
print "$Message[79] $FilterIn{'url'}";
}
if ( $FilterIn{'url'} && $FilterEx{'url'} ) { print " - "; }
if ( $FilterEx{'url'} ) {
print "Exclude $Message[79] $FilterEx{'url'}";
}
if ( $FilterIn{'url'} || $FilterEx{'url'} ) { print ": "; }
print "$cpt $Message[28]";
if ( $MonthRequired ne 'all' ) {
if ( $HTMLOutput{'urldetail'} ) {
print
" $Message[102]: $TotalDifferentPages $Message[28]";
}
}
}
else { print "$Message[102]: $cpt $Message[28]"; }
print " | ";
if ( $ShowPagesStats =~ /P/i ) {
print
"$Message[29] | ";
}
if ( $ShowPagesStats =~ /B/i ) {
print
"$Message[106] | ";
}
if ( $ShowPagesStats =~ /E/i ) {
print
"$Message[104] | ";
}
if ( $ShowPagesStats =~ /X/i ) {
print
"$Message[116] | ";
}
# Call to plugins' function ShowPagesAddField
foreach
my $pluginname ( keys %{ $PluginsLoaded{'ShowPagesAddField'} } )
{
# my $function="ShowPagesAddField_$pluginname('title')";
# eval("$function");
my $function = "ShowPagesAddField_$pluginname";
&$function('title');
}
print " |
\n";
$total_p = $total_k = $total_e = $total_x = 0;
my $count = 0;
if ( $HTMLOutput{'urlentry'} ) {
&BuildKeyList( $MaxRowsInHTMLOutput, $MinHit{'File'}, \%_url_e,
\%_url_e );
}
elsif ( $HTMLOutput{'urlexit'} ) {
&BuildKeyList( $MaxRowsInHTMLOutput, $MinHit{'File'}, \%_url_x,
\%_url_x );
}
else {
&BuildKeyList( $MaxRowsInHTMLOutput, $MinHit{'File'}, \%_url_p,
\%_url_p );
}
$max_p = 1;
$max_k = 1;
foreach my $key (@keylist) {
if ( $_url_p{$key} > $max_p ) { $max_p = $_url_p{$key}; }
if ( $_url_k{$key} / ( $_url_p{$key} || 1 ) > $max_k ) {
$max_k = $_url_k{$key} / ( $_url_p{$key} || 1 );
}
}
foreach my $key (@keylist) {
print "| ";
&ShowURLInfo($key);
print " | ";
my $bredde_p = 0;
my $bredde_e = 0;
my $bredde_x = 0;
my $bredde_k = 0;
if ( $max_p > 0 ) {
$bredde_p =
int( $BarWidth * ( $_url_p{$key} || 0 ) / $max_p ) + 1;
}
if ( ( $bredde_p == 1 ) && $_url_p{$key} ) { $bredde_p = 2; }
if ( $max_p > 0 ) {
$bredde_e =
int( $BarWidth * ( $_url_e{$key} || 0 ) / $max_p ) + 1;
}
if ( ( $bredde_e == 1 ) && $_url_e{$key} ) { $bredde_e = 2; }
if ( $max_p > 0 ) {
$bredde_x =
int( $BarWidth * ( $_url_x{$key} || 0 ) / $max_p ) + 1;
}
if ( ( $bredde_x == 1 ) && $_url_x{$key} ) { $bredde_x = 2; }
if ( $max_k > 0 ) {
$bredde_k =
int( $BarWidth *
( ( $_url_k{$key} || 0 ) / ( $_url_p{$key} || 1 ) ) /
$max_k ) + 1;
}
if ( ( $bredde_k == 1 ) && $_url_k{$key} ) { $bredde_k = 2; }
if ( $ShowPagesStats =~ /P/i ) {
print "$_url_p{$key} | ";
}
if ( $ShowPagesStats =~ /B/i ) {
print ""
. (
$_url_k{$key}
? Format_Bytes(
$_url_k{$key} / ( $_url_p{$key} || 1 )
)
: " "
)
. " | ";
}
if ( $ShowPagesStats =~ /E/i ) {
print ""
. ( $_url_e{$key} ? $_url_e{$key} : " " ) . " | ";
}
if ( $ShowPagesStats =~ /X/i ) {
print ""
. ( $_url_x{$key} ? $_url_x{$key} : " " ) . " | ";
}
# Call to plugins' function ShowPagesAddField
foreach my $pluginname (
keys %{ $PluginsLoaded{'ShowPagesAddField'} } )
{
# my $function="ShowPagesAddField_$pluginname('$key')";
# eval("$function");
my $function = "ShowPagesAddField_$pluginname";
&$function($key);
}
print "";
# alt and title are not provided to reduce page size
if ( $ShowPagesStats =~ /P/i ) {
print
" ";
}
if ( $ShowPagesStats =~ /B/i ) {
print
" ";
}
if ( $ShowPagesStats =~ /E/i ) {
print
" ";
}
if ( $ShowPagesStats =~ /X/i ) {
print
" ";
}
print " |
\n";
$total_p += $_url_p{$key};
$total_e += $_url_e{$key};
$total_x += $_url_x{$key};
$total_k += $_url_k{$key};
$count++;
}
if ($Debug) {
debug(
"Total real / shown : $TotalPages / $total_p - $TotalEntries / $total_e - $TotalExits / $total_x - $TotalBytesPages / $total_k",
2
);
}
$rest_p = $TotalPages - $total_p;
$rest_k = $TotalBytesPages - $total_k;
$rest_e = $TotalEntries - $total_e;
$rest_x = $TotalExits - $total_x;
if ( $rest_p > 0 || $rest_e > 0 || $rest_k > 0 ) {
print
"| $Message[2] | ";
if ( $ShowPagesStats =~ /P/i ) {
print "" . ( $rest_p ? $rest_p : " " ) . " | ";
}
if ( $ShowPagesStats =~ /B/i ) {
print ""
. (
$rest_k
? Format_Bytes( $rest_k / ( $rest_p || 1 ) )
: " "
)
. " | ";
}
if ( $ShowPagesStats =~ /E/i ) {
print "" . ( $rest_e ? $rest_e : " " ) . " | ";
}
if ( $ShowPagesStats =~ /X/i ) {
print "" . ( $rest_x ? $rest_x : " " ) . " | ";
}
# Call to plugins' function ShowPagesAddField
foreach my $pluginname (
keys %{ $PluginsLoaded{'ShowPagesAddField'} } )
{
# my $function="ShowPagesAddField_$pluginname('')";
# eval("$function");
my $function = "ShowPagesAddField_$pluginname";
&$function('');
}
print " |
\n";
}
&tab_end();
&html_end(1);
}
if ( $HTMLOutput{'unknownos'} ) {
print "$Center
\n";
my $title = "$Message[46]";
&tab_head( "$title", 19, 0, 'unknownos' );
print "| User agent ("
. ( scalar keys %_unknownreferer_l )
. ") | $Message[9] |
\n";
$total_l = 0;
my $count = 0;
&BuildKeyList( $MaxRowsInHTMLOutput, 1, \%_unknownreferer_l,
\%_unknownreferer_l );
foreach my $key (@keylist) {
my $useragent = XMLEncode( CleanXSS($key) );
print "| $useragent | ";
print ""
. Format_Date( $_unknownreferer_l{$key}, 1 ) . " | ";
print "
\n";
$total_l += 1;
$count++;
}
$rest_l = ( scalar keys %_unknownreferer_l ) - $total_l;
if ( $rest_l > 0 ) {
print
"| $Message[2] | ";
print "- | ";
print "
\n";
}
&tab_end();
&html_end(1);
}
if ( $HTMLOutput{'unknownbrowser'} ) {
print "$Center
\n";
my $title = "$Message[50]";
&tab_head( "$title", 19, 0, 'unknownbrowser' );
print "| User agent ("
. ( scalar keys %_unknownrefererbrowser_l )
. ") | $Message[9] |
\n";
$total_l = 0;
my $count = 0;
&BuildKeyList( $MaxRowsInHTMLOutput, 1, \%_unknownrefererbrowser_l,
\%_unknownrefererbrowser_l );
foreach my $key (@keylist) {
my $useragent = XMLEncode( CleanXSS($key) );
print
"| $useragent | "
. Format_Date( $_unknownrefererbrowser_l{$key}, 1 )
. " |
\n";
$total_l += 1;
$count++;
}
$rest_l = ( scalar keys %_unknownrefererbrowser_l ) - $total_l;
if ( $rest_l > 0 ) {
print
"| $Message[2] | ";
print "- | ";
print "
\n";
}
&tab_end();
&html_end(1);
}
if ( $HTMLOutput{'osdetail'} ) {
# Show os versions
print "$Center
";
my $title = "$Message[59]";
&tab_head( "$title", 19, 0, 'osversions' );
print
"| $Message[58] | ";
print
"$Message[57] | $Message[15] | ";
print " | ";
print "
\n";
$total_h = 0;
my $count = 0;
&BuildKeyList( MinimumButNoZero( scalar keys %_os_h, 500 ),
1, \%_os_h, \%_os_h );
my %keysinkeylist = ();
$max_h = 1;
# Count total by family
my %totalfamily_h = ();
my $TotalFamily = 0;
OSLOOP: foreach my $key (@keylist) {
$total_h += $_os_h{$key};
if ( $_os_h{$key} > $max_h ) { $max_h = $_os_h{$key}; }
foreach my $family ( keys %OSFamily ) {
if ( $key =~ /^$family/i ) {
$totalfamily_h{$family} += $_os_h{$key};
$TotalFamily += $_os_h{$key};
next OSLOOP;
}
}
}
# Write records grouped in a browser family
foreach my $family ( keys %OSFamily ) {
my $p = ' ';
if ($total_h) {
$p = int( $totalfamily_h{$family} / $total_h * 1000 ) / 10;
$p = "$p %";
}
my $familyheadershown = 0;
foreach my $key ( reverse sort keys %_os_h ) {
if ( $key =~ /^$family(.*)/i ) {
if ( !$familyheadershown ) {
my $family_name = '';
if ( $OSFamily{$family} ) {
$family_name = $OSFamily{$family};
}
print
"| $family_name | ";
print ""
. int( $totalfamily_h{$family} )
. " | $p | | ";
print "
\n";
$familyheadershown = 1;
}
$keysinkeylist{$key} = 1;
my $ver = $1;
my $p = ' ';
if ($total_h) {
$p = int( $_os_h{$key} / $total_h * 1000 ) / 10;
$p = "$p %";
}
print "";
print " | ";
print "$OSHashLib{$key} | ";
my $bredde_h = 0;
if ( $max_h > 0 ) {
$bredde_h =
int( $BarWidth * ( $_os_h{$key} || 0 ) / $max_h )
+ 1;
}
if ( ( $bredde_h == 1 ) && $_os_h{$key} ) {
$bredde_h = 2;
}
print "$_os_h{$key} | $p | ";
print "";
# alt and title are not provided to reduce page size
if ($ShowOSStats) {
print
" ";
}
print " | ";
print "
\n";
$count++;
}
}
}
# Write other records
my $familyheadershown = 0;
foreach my $key (@keylist) {
if ( $keysinkeylist{$key} ) { next; }
if ( !$familyheadershown ) {
my $p = ' ';
if ($total_h) {
$p =
int( ( $total_h - $TotalFamily ) / $total_h * 1000 ) /
10;
$p = "$p %";
}
print
"| $Message[2] | ";
print ""
. ( $total_h - $TotalFamily )
. " | $p | | ";
print "
\n";
$familyheadershown = 1;
}
my $p = ' ';
if ($total_h) {
$p = int( $_os_h{$key} / $total_h * 1000 ) / 10;
$p = "$p %";
}
print "";
if ( $key eq 'Unknown' ) {
print " | $Message[0] | ";
}
else {
my $keywithoutcumul = $key;
$keywithoutcumul =~ s/cumul$//i;
my $libos = $OSHashLib{$keywithoutcumul}
|| $keywithoutcumul;
my $nameicon = $keywithoutcumul;
$nameicon =~ s/[^\w]//g;
print " | $libos | ";
}
my $bredde_h = 0;
if ( $max_h > 0 ) {
$bredde_h =
int( $BarWidth * ( $_os_h{$key} || 0 ) / $max_h ) + 1;
}
if ( ( $bredde_h == 1 ) && $_os_h{$key} ) { $bredde_h = 2; }
print "$_os_h{$key} | $p | ";
print "";
# alt and title are not provided to reduce page size
if ($ShowOSStats) {
print
" ";
}
print " | ";
print "
\n";
}
&tab_end();
&html_end(1);
}
if ( $HTMLOutput{'browserdetail'} ) {
# Show browsers versions
print "$Center
";
my $title = "$Message[21]";
&tab_head( "$title", 19, 0, 'browsersversions' );
print
"| $Message[58] | ";
print
"$Message[111] | $Message[57] | $Message[15] | ";
print " | ";
print "
\n";
$total_h = 0;
my $count = 0;
&BuildKeyList( MinimumButNoZero( scalar keys %_browser_h, 500 ),
1, \%_browser_h, \%_browser_h );
my %keysinkeylist = ();
$max_h = 1;
# Count total by family
my %totalfamily_h = ();
my $TotalFamily = 0;
BROWSERLOOP: foreach my $key (@keylist) {
$total_h += $_browser_h{$key};
if ( $_browser_h{$key} > $max_h ) {
$max_h = $_browser_h{$key};
}
foreach my $family ( keys %BrowsersFamily ) {
if ( $key =~ /^$family/i ) {
$totalfamily_h{$family} += $_browser_h{$key};
$TotalFamily += $_browser_h{$key};
next BROWSERLOOP;
}
}
}
# Write records grouped in a browser family
foreach my $family (
sort { $BrowsersFamily{$a} <=> $BrowsersFamily{$b} }
keys %BrowsersFamily
)
{
my $p = ' ';
if ($total_h) {
$p = int( $totalfamily_h{$family} / $total_h * 1000 ) / 10;
$p = "$p %";
}
my $familyheadershown = 0;
#foreach my $key ( reverse sort keys %_browser_h ) {
foreach my $key ( reverse sort SortBrowsers keys %_browser_h ) {
if ( $key =~ /^$family(.*)/i ) {
if ( !$familyheadershown ) {
print
"| "
. uc($family)
. " | ";
print " | "
. int( $totalfamily_h{$family} )
. " | $p | | ";
print "
\n";
$familyheadershown = 1;
}
$keysinkeylist{$key} = 1;
my $ver = $1;
my $p = ' ';
if ($total_h) {
$p =
int( $_browser_h{$key} / $total_h * 1000 ) / 10;
$p = "$p %";
}
print "";
print " | ";
print ""
. ucfirst($family) . " "
. ( $ver ? "$ver" : "?" ) . " | ";
print ""
. (
$BrowsersHereAreGrabbers{$family}
? "$Message[112]"
: "$Message[113]"
)
. " | ";
my $bredde_h = 0;
if ( $max_h > 0 ) {
$bredde_h =
int( $BarWidth * ( $_browser_h{$key} || 0 ) /
$max_h ) + 1;
}
if ( ( $bredde_h == 1 ) && $_browser_h{$key} ) {
$bredde_h = 2;
}
print "$_browser_h{$key} | $p | ";
print "";
# alt and title are not provided to reduce page size
if ($ShowBrowsersStats) {
print
" ";
}
print " | ";
print "
\n";
$count++;
}
}
}
# Write other records
my $familyheadershown = 0;
foreach my $key (@keylist) {
if ( $keysinkeylist{$key} ) { next; }
if ( !$familyheadershown ) {
my $p = ' ';
if ($total_h) {
$p =
int( ( $total_h - $TotalFamily ) / $total_h * 1000 ) /
10;
$p = "$p %";
}
print
"| $Message[2] | ";
print " | "
. ( $total_h - $TotalFamily )
. " | $p | | ";
print "
\n";
$familyheadershown = 1;
}
my $p = ' ';
if ($total_h) {
$p = int( $_browser_h{$key} / $total_h * 1000 ) / 10;
$p = "$p %";
}
print "";
if ( $key eq 'Unknown' ) {
print " | $Message[0] | ? | ";
}
else {
my $keywithoutcumul = $key;
$keywithoutcumul =~ s/cumul$//i;
my $libbrowser = $BrowsersHashIDLib{$keywithoutcumul}
|| $keywithoutcumul;
my $nameicon = $BrowsersHashIcon{$keywithoutcumul}
|| "notavailable";
print " | $libbrowser | "
. (
$BrowsersHereAreGrabbers{$key}
? "$Message[112]"
: "$Message[113]"
)
. " | ";
}
my $bredde_h = 0;
if ( $max_h > 0 ) {
$bredde_h =
int( $BarWidth * ( $_browser_h{$key} || 0 ) / $max_h ) +
1;
}
if ( ( $bredde_h == 1 ) && $_browser_h{$key} ) {
$bredde_h = 2;
}
print "$_browser_h{$key} | $p | ";
print "";
# alt and title are not provided to reduce page size
if ($ShowBrowsersStats) {
print
" ";
}
print " | ";
print "
\n";
}
&tab_end();
&html_end(1);
}
if ( $HTMLOutput{'refererse'} ) {
print "$Center
\n";
my $title = "$Message[40]";
&tab_head( "$title", 19, 0, 'refererse' );
print
"| $TotalDifferentSearchEngines $Message[122] | ";
print
"$Message[56] | $Message[15] | ";
print
"$Message[57] | $Message[15] | ";
print "
\n";
$total_s = 0;
my $count = 0;
&BuildKeyList(
$MaxRowsInHTMLOutput,
$MinHit{'Refer'},
\%_se_referrals_h,
(
( scalar keys %_se_referrals_p )
? \%_se_referrals_p
: \%_se_referrals_h
)
); # before 5.4 only hits were recorded
foreach my $key (@keylist) {
my $newreferer = $SearchEnginesHashLib{$key} || CleanXSS($key);
my $p_p;
my $p_h;
if ($TotalSearchEnginesPages) {
$p_p =
int( $_se_referrals_p{$key} / $TotalSearchEnginesPages *
1000 ) / 10;
}
if ($TotalSearchEnginesHits) {
$p_h =
int( $_se_referrals_h{$key} / $TotalSearchEnginesHits *
1000 ) / 10;
}
print "| $newreferer | ";
print ""
. (
$_se_referrals_p{$key} ? $_se_referrals_p{$key} : ' ' )
. " | ";
print ""
. ( $_se_referrals_p{$key} ? "$p_p %" : ' ' ) . " | ";
print "$_se_referrals_h{$key} | ";
print "$p_h % | ";
print "
\n";
$total_p += $_se_referrals_p{$key};
$total_h += $_se_referrals_h{$key};
$count++;
}
if ($Debug) {
debug(
"Total real / shown : $TotalSearchEnginesPages / $total_p - $TotalSearchEnginesHits / $total_h",
2
);
}
$rest_p = $TotalSearchEnginesPages - $total_p;
$rest_h = $TotalSearchEnginesHits - $total_h;
if ( $rest_p > 0 || $rest_h > 0 ) {
my $p_p;
my $p_h;
if ($TotalSearchEnginesPages) {
$p_p =
int( $rest_p / $TotalSearchEnginesPages * 1000 ) / 10;
}
if ($TotalSearchEnginesHits) {
$p_h = int( $rest_h / $TotalSearchEnginesHits * 1000 ) / 10;
}
print
"| $Message[2] | ";
print "" . ( $rest_p ? $rest_p : ' ' ) . " | ";
print "" . ( $rest_p ? "$p_p %" : ' ' ) . " | ";
print "$rest_h | ";
print "$p_h % | ";
print "
\n";
}
&tab_end();
&html_end(1);
}
if ( $HTMLOutput{'refererpages'} ) {
print "$Center
\n";
# Show filter form
&ShowFormFilter(
"refererpagesfilter",
$FilterIn{'refererpages'},
$FilterEx{'refererpages'}
);
my $title = "$Message[41]";
my $cpt = 0;
$cpt = ( scalar keys %_pagesrefs_h );
&tab_head( "$title", 19, 0, 'refererpages' );
print "";
if ( $FilterIn{'refererpages'} || $FilterEx{'refererpages'} ) {
if ( $FilterIn{'refererpages'} ) {
print "$Message[79] $FilterIn{'refererpages'}";
}
if ( $FilterIn{'refererpages'} && $FilterEx{'refererpages'} ) {
print " - ";
}
if ( $FilterEx{'refererpages'} ) {
print
"Exclude $Message[79] $FilterEx{'refererpages'}";
}
if ( $FilterIn{'refererpages'} || $FilterEx{'refererpages'} ) {
print ": ";
}
print "$cpt $Message[28]";
#if ($MonthRequired ne 'all') {
# if ($HTMLOutput{'refererpages'}) { print " $Message[102]: $TotalDifferentPages $Message[28]"; }
#}
}
else { print "$Message[102]: $cpt $Message[28]"; }
print " | ";
print
"$Message[56] | $Message[15] | ";
print
"$Message[57] | $Message[15] | ";
print "
\n";
$total_s = 0;
my $count = 0;
&BuildKeyList(
$MaxRowsInHTMLOutput,
$MinHit{'Refer'},
\%_pagesrefs_h,
(
( scalar keys %_pagesrefs_p )
? \%_pagesrefs_p
: \%_pagesrefs_h
)
);
foreach my $key (@keylist) {
my $nompage = CleanXSS($key);
if ( length($nompage) > $MaxLengthOfShownURL ) {
$nompage =
substr( $nompage, 0, $MaxLengthOfShownURL ) . "...";
}
my $p_p;
my $p_h;
if ($TotalRefererPages) {
$p_p =
int( $_pagesrefs_p{$key} / $TotalRefererPages * 1000 ) /
10;
}
if ($TotalRefererHits) {
$p_h =
int( $_pagesrefs_h{$key} / $TotalRefererHits * 1000 ) /
10;
}
print "| ";
&ShowURLInfo($key);
print " | ";
print ""
. ( $_pagesrefs_p{$key} ? $_pagesrefs_p{$key} : ' ' )
. " | "
. ( $_pagesrefs_p{$key} ? "$p_p %" : ' ' ) . " | ";
print ""
. ( $_pagesrefs_h{$key} ? $_pagesrefs_h{$key} : ' ' )
. " | "
. ( $_pagesrefs_h{$key} ? "$p_h %" : ' ' ) . " | ";
print "
\n";
$total_p += $_pagesrefs_p{$key};
$total_h += $_pagesrefs_h{$key};
$count++;
}
if ($Debug) {
debug(
"Total real / shown : $TotalRefererPages / $total_p - $TotalRefererHits / $total_h",
2
);
}
$rest_p = $TotalRefererPages - $total_p;
$rest_h = $TotalRefererHits - $total_h;
if ( $rest_p > 0 || $rest_h > 0 ) {
my $p_p;
my $p_h;
if ($TotalRefererPages) {
$p_p = int( $rest_p / $TotalRefererPages * 1000 ) / 10;
}
if ($TotalRefererHits) {
$p_h = int( $rest_h / $TotalRefererHits * 1000 ) / 10;
}
print
"| $Message[2] | ";
print "" . ( $rest_p ? $rest_p : ' ' ) . " | ";
print "" . ( $rest_p ? "$p_p %" : ' ' ) . " | ";
print "$rest_h | ";
print "$p_h % | ";
print "
\n";
}
&tab_end();
&html_end(1);
}
if ( $HTMLOutput{'keyphrases'} ) {
print "$Center
\n";
&tab_head( $Message[43], 19, 0, 'keyphrases' );
print "| $TotalDifferentKeyphrases $Message[103] | $Message[14] | $Message[15] |
\n";
$total_s = 0;
my $count = 0;
&BuildKeyList(
$MaxRowsInHTMLOutput, $MinHit{'Keyphrase'},
\%_keyphrases, \%_keyphrases
);
foreach my $key (@keylist) {
my $mot;
# Convert coded keywords (utf8,...) to be correctly reported in HTML page.
if ( $PluginsLoaded{'DecodeKey'}{'decodeutfkeys'} ) {
$mot = CleanXSS(
DecodeKey_decodeutfkeys(
$key, $PageCode || 'iso-8859-1'
)
);
}
else { $mot = CleanXSS( DecodeEncodedString($key) ); }
my $p;
if ($TotalKeyphrases) {
$p =
int( $_keyphrases{$key} / $TotalKeyphrases * 1000 ) / 10;
}
print "| "
. XMLEncode($mot)
. " | $_keyphrases{$key} | $p % |
\n";
$total_s += $_keyphrases{$key};
$count++;
}
if ($Debug) {
debug( "Total real / shown : $TotalKeyphrases / $total_s", 2 );
}
$rest_s = $TotalKeyphrases - $total_s;
if ( $rest_s > 0 ) {
my $p;
if ($TotalKeyphrases) {
$p = int( $rest_s / $TotalKeyphrases * 1000 ) / 10;
}
print
"| $Message[124] | $rest_s | ";
print "$p % |
\n";
}
&tab_end();
&html_end(1);
}
if ( $HTMLOutput{'keywords'} ) {
print "$Center
\n";
&tab_head( $Message[44], 19, 0, 'keywords' );
print "| $TotalDifferentKeywords $Message[13] | $Message[14] | $Message[15] |
\n";
$total_s = 0;
my $count = 0;
&BuildKeyList( $MaxRowsInHTMLOutput, $MinHit{'Keyword'},
\%_keywords, \%_keywords );
foreach my $key (@keylist) {
my $mot;
# Convert coded keywords (utf8,...) to be correctly reported in HTML page.
if ( $PluginsLoaded{'DecodeKey'}{'decodeutfkeys'} ) {
$mot = CleanXSS(
DecodeKey_decodeutfkeys(
$key, $PageCode || 'iso-8859-1'
)
);
}
else { $mot = CleanXSS( DecodeEncodedString($key) ); }
my $p;
if ($TotalKeywords) {
$p = int( $_keywords{$key} / $TotalKeywords * 1000 ) / 10;
}
print "| "
. XMLEncode($mot)
. " | $_keywords{$key} | $p % |
\n";
$total_s += $_keywords{$key};
$count++;
}
if ($Debug) {
debug( "Total real / shown : $TotalKeywords / $total_s", 2 );
}
$rest_s = $TotalKeywords - $total_s;
if ( $rest_s > 0 ) {
my $p;
if ($TotalKeywords) {
$p = int( $rest_s / $TotalKeywords * 1000 ) / 10;
}
print
"| $Message[30] | $rest_s | ";
print "$p % |
\n";
}
&tab_end();
&html_end(1);
}
foreach my $code ( keys %TrapInfosForHTTPErrorCodes ) {
if ( $HTMLOutput{"errors$code"} ) {
print "$Center
\n";
&tab_head( $Message[47], 19, 0, "errors$code" );
print "| URL ("
. ( scalar keys %_sider404_h )
. ") | $Message[49] | $Message[23] |
\n";
$total_h = 0;
my $count = 0;
&BuildKeyList( $MaxRowsInHTMLOutput, 1, \%_sider404_h,
\%_sider404_h );
foreach my $key (@keylist) {
my $nompage = XMLEncode( CleanXSS($key) );
#if (length($nompage)>$MaxLengthOfShownURL) { $nompage=substr($nompage,0,$MaxLengthOfShownURL)."..."; }
my $referer = XMLEncode( CleanXSS( $_referer404_h{$key} ) );
print "| $nompage | ";
print "$_sider404_h{$key} | ";
print ""
. ( $referer ? "$referer" : " " ) . " | ";
print "
\n";
$total_s += $_sider404_h{$key};
$count++;
}
# TODO Build TotalErrorHits
# if ($Debug) { debug("Total real / shown : $TotalErrorHits / $total_h",2); }
# $rest_h=$TotalErrorHits-$total_h;
# if ($rest_h > 0) {
# my $p;
# if ($TotalErrorHits) { $p=int($rest_h/$TotalErrorHits*1000)/10; }
# print "| $Message[30] | ";
# print "$rest_h | ";
# print "... | ";
# print "
\n";
# }
&tab_end();
&html_end(1);
}
}
# BY EXTRA SECTIONS
#----------------------------
foreach my $extranum ( 1 .. @ExtraName - 1 ) {
if ( $HTMLOutput{"allextra$extranum"} ) {
if ($Debug) { debug( "ExtraName$extranum", 2 ); }
print "$Center
";
my $title = $ExtraName[$extranum];
&tab_head("$title ($Message[77] $MaxNbOfExtra[$extranum])",19,0,"extra$extranum");
print "";
print "| " . $ExtraFirstColumnTitle[$extranum] . " | ";
if ( $ExtraStatTypes[$extranum] =~ m/P/i ) {
print
"$Message[56] | ";
}
if ( $ExtraStatTypes[$extranum] =~ m/H/i ) {
print
"$Message[57] | ";
}
if ( $ExtraStatTypes[$extranum] =~ m/B/i ) {
print
"$Message[75] | ";
}
if ( $ExtraStatTypes[$extranum] =~ m/L/i ) {
print "$Message[9] | ";
}
print "
\n";
$total_p = $total_h = $total_k = 0;
#$max_h=1; foreach (values %_login_h) { if ($_ > $max_h) { $max_h = $_; } }
#$max_k=1; foreach (values %_login_k) { if ($_ > $max_k) { $max_k = $_; } }
my $count = 0;
if ( $ExtraStatTypes[$extranum] =~ m/P/i ) {
&BuildKeyList(
$MaxRowsInHTMLOutput,
$MinHitExtra[$extranum],
\%{ '_section_' . $extranum . '_h' },
\%{ '_section_' . $extranum . '_p' }
);
}
else {
&BuildKeyList(
$MaxRowsInHTMLOutput,
$MinHitExtra[$extranum],
\%{ '_section_' . $extranum . '_h' },
\%{ '_section_' . $extranum . '_h' }
);
}
my %keysinkeylist = ();
foreach my $key (@keylist) {
$keysinkeylist{$key} = 1;
my $firstcol = CleanXSS( DecodeEncodedString($key) );
$total_p += ${ '_section_' . $extranum . '_p' }{$key};
$total_h += ${ '_section_' . $extranum . '_h' }{$key};
$total_k += ${ '_section_' . $extranum . '_k' }{$key};
print "";
printf(
"| $ExtraFirstColumnFormat[$extranum] | ",
$firstcol, $firstcol, $firstcol, $firstcol, $firstcol );
if ( $ExtraStatTypes[$extranum] =~ m/P/i ) {
print ""
. ${ '_section_' . $extranum . '_p' }{$key} . " | ";
}
if ( $ExtraStatTypes[$extranum] =~ m/H/i ) {
print ""
. ${ '_section_' . $extranum . '_h' }{$key} . " | ";
}
if ( $ExtraStatTypes[$extranum] =~ m/B/i ) {
print ""
. Format_Bytes(
${ '_section_' . $extranum . '_k' }{$key} )
. " | ";
}
if ( $ExtraStatTypes[$extranum] =~ m/L/i ) {
print ""
. (
${ '_section_' . $extranum . '_l' }{$key}
? Format_Date(
${ '_section_' . $extranum . '_l' }{$key}, 1 )
: '-'
)
. " | ";
}
print "
\n";
$count++;
}
# If we ask average or sum, we loop on all other records
if ( $ExtraAddAverageRow[$extranum]
|| $ExtraAddSumRow[$extranum] )
{
foreach ( keys %{ '_section_' . $extranum . '_h' } ) {
if ( $keysinkeylist{$_} ) { next; }
$total_p += ${ '_section_' . $extranum . '_p' }{$_};
$total_h += ${ '_section_' . $extranum . '_h' }{$_};
$total_k += ${ '_section_' . $extranum . '_k' }{$_};
$count++;
}
}
# Add average row
if ( $ExtraAddAverageRow[$extranum] ) {
print "";
print "| $Message[96] | ";
if ( $ExtraStatTypes[$extranum] =~ m/P/i ) {
print ""
. ( $count ? ( $total_p / $count ) : " " )
. " | ";
}
if ( $ExtraStatTypes[$extranum] =~ m/H/i ) {
print ""
. ( $count ? ( $total_h / $count ) : " " )
. " | ";
}
if ( $ExtraStatTypes[$extranum] =~ m/B/i ) {
print ""
. (
$count
? Format_Bytes( $total_k / $count )
: " "
)
. " | ";
}
if ( $ExtraStatTypes[$extranum] =~ m/L/i ) {
print " | ";
}
print "
\n";
}
# Add sum row
if ( $ExtraAddSumRow[$extranum] ) {
print "";
print "| $Message[102] | ";
if ( $ExtraStatTypes[$extranum] =~ m/P/i ) {
print "" . ($total_p) . " | ";
}
if ( $ExtraStatTypes[$extranum] =~ m/H/i ) {
print "" . ($total_h) . " | ";
}
if ( $ExtraStatTypes[$extranum] =~ m/B/i ) {
print "" . Format_Bytes($total_k) . " | ";
}
if ( $ExtraStatTypes[$extranum] =~ m/L/i ) {
print " | ";
}
print "
\n";
}
&tab_end();
&html_end(1);
}
}
if ( $HTMLOutput{'info'} ) {
# Not yet available
print "$Center
";
&html_end(1);
}
my $htmloutput = '';
foreach my $key ( keys %HTMLOutput ) { $htmloutput = $key; }
if ( $htmloutput =~ /^plugin_(\w+)$/ ) {
my $pluginname = $1;
print "$Center
";
# my $function="AddHTMLGraph_$pluginname()";
# eval("$function");
my $function = "AddHTMLGraph_$pluginname";
&$function();
&html_end(1);
}
}
# Output main page
#-----------------
if ( $HTMLOutput{'main'} ) {
# SUMMARY
#---------------------------------------------------------------------
if ($ShowSummary) {
if ($Debug) { debug( "ShowSummary", 2 ); }
#print "$Center
\n";
my $title = "$Message[128]";
&tab_head( "$title", 0, 0, 'month' );
my $NewLinkParams = ${QueryString};
$NewLinkParams =~ s/(^|&|&)update(=\w*|$)//i;
$NewLinkParams =~ s/(^|&|&)staticlinks(=\w*|$)//i;
$NewLinkParams =~ s/(^|&|&)year=[^&]*//i;
$NewLinkParams =~ s/(^|&|&)month=[^&]*//i;
$NewLinkParams =~ s/(^|&|&)framename=[^&]*//i;
$NewLinkParams =~ s/(&|&)+/&/i;
$NewLinkParams =~ s/^&//;
$NewLinkParams =~ s/&$//;
if ($NewLinkParams) { $NewLinkParams = "${NewLinkParams}&"; }
my $NewLinkTarget = '';
if ( $FrameName eq 'mainright' ) {
$NewLinkTarget = " target=\"_parent\"";
}
# Ratio
my $RatioVisits = 0;
my $RatioPages = 0;
my $RatioHits = 0;
my $RatioBytes = 0;
if ( $TotalUnique > 0 ) {
$RatioVisits = int( $TotalVisits / $TotalUnique * 100 ) / 100;
}
if ( $TotalVisits > 0 ) {
$RatioPages = int( $TotalPages / $TotalVisits * 100 ) / 100;
}
if ( $TotalVisits > 0 ) {
$RatioHits = int( $TotalHits / $TotalVisits * 100 ) / 100;
}
if ( $TotalVisits > 0 ) {
$RatioBytes =
int( ( $TotalBytes / 1024 ) * 100 /
( $LogType eq 'M' ? $TotalHits : $TotalVisits ) ) / 100;
}
my $colspan = 5;
my $w = '20';
if ( $LogType eq 'W' || $LogType eq 'S' ) {
$w = '17';
$colspan = 6;
}
# Show first/last
print "";
print
"| $Message[133] | \n";
print( $MonthRequired eq 'all'
? "$Message[6] $YearRequired"
: "$Message[5] "
. $MonthNumLib{$MonthRequired}
. " $YearRequired"
);
print " |
\n";
print "";
print "| $Message[8] | \n";
print ""
. ( $FirstTime ? Format_Date( $FirstTime, 0 ) : "NA" ) . " | ";
print "
\n";
print "";
print "| $Message[9] | \n";
print ""
. ( $LastTime ? Format_Date( $LastTime, 0 ) : "NA" )
. " | \n";
print "
\n";
# Show main indicators title row
print "";
if ( $LogType eq 'W' || $LogType eq 'S' ) {
print "| | ";
}
if ( $ShowSummary =~ /U/i ) {
print "$Message[11] | ";
}
else {
print
" | ";
}
if ( $ShowSummary =~ /V/i ) {
print "$Message[10] | ";
}
else {
print
" | ";
}
if ( $ShowSummary =~ /P/i ) {
print "$Message[56] | ";
}
else {
print
" | ";
}
if ( $ShowSummary =~ /H/i ) {
print "$Message[57] | ";
}
else {
print
" | ";
}
if ( $ShowSummary =~ /B/i ) {
print "$Message[75] | ";
}
else {
print
" | ";
}
print "
\n";
# Show main indicators values for viewed traffic
print "";
if ( $LogType eq 'M' ) {
print "| $Message[165] | ";
print " | \n";
print " | \n";
if ( $ShowSummary =~ /H/i ) {
print "$TotalHits"
. (
$LogType eq 'M'
? ""
: " ($RatioHits "
. lc( $Message[57] . "/" . $Message[12] ) . ")"
)
. " | ";
}
else { print " | "; }
if ( $ShowSummary =~ /B/i ) {
print ""
. Format_Bytes( int($TotalBytes) )
. " ($RatioBytes $Message[108]/"
. $Message[ ( $LogType eq 'M' ? 149 : 12 ) ]
. ") | ";
}
else { print " | "; }
}
else {
if ( $LogType eq 'W' || $LogType eq 'S' ) {
print "$Message[160] * | ";
}
if ( $ShowSummary =~ /U/i ) {
print ""
. (
$MonthRequired eq 'all'
? "<= $TotalUnique $Message[129]"
: "$TotalUnique "
)
. " | ";
}
else { print " | "; }
if ( $ShowSummary =~ /V/i ) {
print
"$TotalVisits ($RatioVisits $Message[52]) | ";
}
else { print " | "; }
if ( $ShowSummary =~ /P/i ) {
print "$TotalPages ($RatioPages "
. $Message[56] . "/"
. $Message[12]
. ") | ";
}
else { print " | "; }
if ( $ShowSummary =~ /H/i ) {
print "$TotalHits"
. (
$LogType eq 'M'
? ""
: " ($RatioHits "
. $Message[57] . "/"
. $Message[12] . ")"
)
. " | ";
}
else { print " | "; }
if ( $ShowSummary =~ /B/i ) {
print ""
. Format_Bytes( int($TotalBytes) )
. " ($RatioBytes $Message[108]/"
. $Message[ ( $LogType eq 'M' ? 149 : 12 ) ]
. ") | ";
}
else { print " | "; }
}
print "
\n";
# Show main indicators values for not viewed traffic values
if ( $LogType eq 'M' || $LogType eq 'W' || $LogType eq 'S' ) {
print "";
if ( $LogType eq 'M' ) {
print "| $Message[166] | ";
print " | \n";
print " | \n";
if ( $ShowSummary =~ /H/i ) {
print "$TotalNotViewedHits | ";
}
else { print " | "; }
if ( $ShowSummary =~ /B/i ) {
print ""
. Format_Bytes( int($TotalNotViewedBytes) )
. " | ";
}
else { print " | "; }
}
else {
if ( $LogType eq 'W' || $LogType eq 'S' ) {
print "$Message[161] * | ";
}
print " | \n";
if ( $ShowSummary =~ /P/i ) {
print "$TotalNotViewedPages | ";
}
else { print " | "; }
if ( $ShowSummary =~ /H/i ) {
print "$TotalNotViewedHits | ";
}
else { print " | "; }
if ( $ShowSummary =~ /B/i ) {
print ""
. Format_Bytes( int($TotalNotViewedBytes) )
. " | ";
}
else { print " | "; }
}
print "
\n";
}
&tab_end($LogType eq 'W'
|| $LogType eq 'S' ? "* $Message[159]" : "" );
}
# BY MONTH
#---------------------------------------------------------------------
if ($ShowMonthStats) {
if ($Debug) { debug( "ShowMonthStats", 2 ); }
print "$Center
\n";
my $title = "$Message[162]";
&tab_head( "$title", 0, 0, 'month' );
print "\n";
print "\n";
$average_nb = $average_u = $average_v = $average_p = $average_h =
$average_k = 0;
$total_u = $total_v = $total_p = $total_h = $total_k = 0;
$max_v = $max_p = $max_h = $max_k = 1;
# Define total and max
for ( my $ix = 1 ; $ix <= 12 ; $ix++ ) {
my $monthix = sprintf( "%02s", $ix );
$total_u += $MonthUnique{ $YearRequired . $monthix } || 0;
$total_v += $MonthVisits{ $YearRequired . $monthix } || 0;
$total_p += $MonthPages{ $YearRequired . $monthix } || 0;
$total_h += $MonthHits{ $YearRequired . $monthix } || 0;
$total_k += $MonthBytes{ $YearRequired . $monthix } || 0;
#if (($MonthUnique{$YearRequired.$monthix}||0) > $max_v) { $max_v=$MonthUnique{$YearRequired.$monthix}; }
if (
( $MonthVisits{ $YearRequired . $monthix } || 0 ) > $max_v )
{
$max_v = $MonthVisits{ $YearRequired . $monthix };
}
#if (($MonthPages{$YearRequired.$monthix}||0) > $max_p) { $max_p=$MonthPages{$YearRequired.$monthix}; }
if ( ( $MonthHits{ $YearRequired . $monthix } || 0 ) > $max_h )
{
$max_h = $MonthHits{ $YearRequired . $monthix };
}
if ( ( $MonthBytes{ $YearRequired . $monthix } || 0 ) > $max_k )
{
$max_k = $MonthBytes{ $YearRequired . $monthix };
}
}
# Define average
# TODO
# Show bars for month
if ( $PluginsLoaded{'ShowGraph'}{'graphapplet'} ) {
my @blocklabel = ();
for ( my $ix = 1 ; $ix <= 12 ; $ix++ ) {
my $monthix = sprintf( "%02s", $ix );
push @blocklabel,
"$MonthNumLib{$monthix}\�$YearRequired";
}
my @vallabel = (
"$Message[11]", "$Message[10]",
"$Message[56]", "$Message[57]",
"$Message[75]"
);
my @valcolor =
( "$color_u", "$color_v", "$color_p", "$color_h",
"$color_k" );
my @valmax = ( $max_v, $max_v, $max_h, $max_h, $max_k );
my @valtotal =
( $total_u, $total_v, $total_p, $total_h, $total_k );
my @valaverage = ();
#my @valaverage=($average_v,$average_p,$average_h,$average_k);
my @valdata = ();
my $xx = 0;
for ( my $ix = 1 ; $ix <= 12 ; $ix++ ) {
my $monthix = sprintf( "%02s", $ix );
$valdata[ $xx++ ] = $MonthUnique{ $YearRequired . $monthix }
|| 0;
$valdata[ $xx++ ] = $MonthVisits{ $YearRequired . $monthix }
|| 0;
$valdata[ $xx++ ] = $MonthPages{ $YearRequired . $monthix }
|| 0;
$valdata[ $xx++ ] = $MonthHits{ $YearRequired . $monthix }
|| 0;
$valdata[ $xx++ ] = $MonthBytes{ $YearRequired . $monthix }
|| 0;
}
ShowGraph_graphapplet(
"$title", "month",
$ShowMonthStats, \@blocklabel,
\@vallabel, \@valcolor,
\@valmax, \@valtotal,
\@valaverage, \@valdata
);
}
else {
print "\n";
print "";
print "| | \n";
for ( my $ix = 1 ; $ix <= 12 ; $ix++ ) {
my $monthix = sprintf( "%02s", $ix );
my $bredde_u = 0;
my $bredde_v = 0;
my $bredde_p = 0;
my $bredde_h = 0;
my $bredde_k = 0;
if ( $max_v > 0 ) {
$bredde_u =
int(
( $MonthUnique{ $YearRequired . $monthix } || 0 ) /
$max_v * $BarHeight ) + 1;
}
if ( $max_v > 0 ) {
$bredde_v =
int(
( $MonthVisits{ $YearRequired . $monthix } || 0 ) /
$max_v * $BarHeight ) + 1;
}
if ( $max_h > 0 ) {
$bredde_p =
int(
( $MonthPages{ $YearRequired . $monthix } || 0 ) /
$max_h * $BarHeight ) + 1;
}
if ( $max_h > 0 ) {
$bredde_h =
int( ( $MonthHits{ $YearRequired . $monthix } || 0 ) /
$max_h * $BarHeight ) + 1;
}
if ( $max_k > 0 ) {
$bredde_k =
int(
( $MonthBytes{ $YearRequired . $monthix } || 0 ) /
$max_k * $BarHeight ) + 1;
}
print "";
if ( $ShowMonthStats =~ /U/i ) {
print
" ";
}
if ( $ShowMonthStats =~ /V/i ) {
print
" ";
}
if ( $ShowMonthStats =~ /P/i ) {
print
" ";
}
if ( $ShowMonthStats =~ /H/i ) {
print
" ";
}
if ( $ShowMonthStats =~ /B/i ) {
print
" ";
}
print " | \n";
}
print " | ";
print " \n";
# Show lib for month
print "";
# if (!$StaticLinks) {
# print "| << | ";
# }
# else {
print " | ";
# }
for ( my $ix = 1 ; $ix <= 12 ; $ix++ ) {
my $monthix = sprintf( "%02s", $ix );
# if (!$StaticLinks) {
# print "$MonthNumLib{$monthix} $YearRequired | ";
# }
# else {
print ""
. (
!$StaticLinks
&& $monthix == $nowmonth
&& $YearRequired == $nowyear
? ''
: ''
);
print "$MonthNumLib{$monthix} $YearRequired";
print( !$StaticLinks
&& $monthix == $nowmonth
&& $YearRequired == $nowyear ? '' : '' );
print " | ";
# }
}
# if (!$StaticLinks) {
# print ">> | ";
# }
# else {
print " | ";
# }
print " \n";
print " \n";
}
print " \n";
# Show data array for month
if ($AddDataArrayMonthStats) {
print "\n";
print
"| $Message[5] | ";
if ( $ShowMonthStats =~ /U/i ) {
print "$Message[11] | ";
}
if ( $ShowMonthStats =~ /V/i ) {
print "$Message[10] | ";
}
if ( $ShowMonthStats =~ /P/i ) {
print "$Message[56] | ";
}
if ( $ShowMonthStats =~ /H/i ) {
print "$Message[57] | ";
}
if ( $ShowMonthStats =~ /B/i ) {
print "$Message[75] | ";
}
print " \n";
for ( my $ix = 1 ; $ix <= 12 ; $ix++ ) {
my $monthix = sprintf( "%02s", $ix );
print "";
print "| "
. (
!$StaticLinks
&& $monthix == $nowmonth
&& $YearRequired == $nowyear
? ''
: ''
);
print "$MonthNumLib{$monthix} $YearRequired";
print( !$StaticLinks
&& $monthix == $nowmonth
&& $YearRequired == $nowyear ? '' : '' );
print " | ";
if ( $ShowMonthStats =~ /U/i ) {
print "",
$MonthUnique{ $YearRequired . $monthix }
? $MonthUnique{ $YearRequired . $monthix }
: "0", " | ";
}
if ( $ShowMonthStats =~ /V/i ) {
print "",
$MonthVisits{ $YearRequired . $monthix }
? $MonthVisits{ $YearRequired . $monthix }
: "0", " | ";
}
if ( $ShowMonthStats =~ /P/i ) {
print "",
$MonthPages{ $YearRequired . $monthix }
? $MonthPages{ $YearRequired . $monthix }
: "0", " | ";
}
if ( $ShowMonthStats =~ /H/i ) {
print "",
$MonthHits{ $YearRequired . $monthix }
? $MonthHits{ $YearRequired . $monthix }
: "0", " | ";
}
if ( $ShowMonthStats =~ /B/i ) {
print "",
Format_Bytes(
int( $MonthBytes{ $YearRequired . $monthix } || 0 )
), " | ";
}
print " \n";
}
# Average row
# TODO
# Total row
print
"| $Message[102] | ";
if ( $ShowMonthStats =~ /U/i ) {
print
"$total_u | ";
}
if ( $ShowMonthStats =~ /V/i ) {
print
"$total_v | ";
}
if ( $ShowMonthStats =~ /P/i ) {
print
"$total_p | ";
}
if ( $ShowMonthStats =~ /H/i ) {
print
"$total_h | ";
}
if ( $ShowMonthStats =~ /B/i ) {
print ""
. Format_Bytes($total_k) . " | ";
}
print " \n";
print " \n \n";
}
print "\n";
print " |
\n";
&tab_end();
}
print "\n \n\n";
# BY DAY OF MONTH
#---------------------------------------------------------------------
if ($ShowDaysOfMonthStats) {
if ($Debug) { debug( "ShowDaysOfMonthStats", 2 ); }
print "$Center
\n";
my $title = "$Message[138]";
&tab_head( "$title", 0, 0, 'daysofmonth' );
print "";
print "\n";
print "\n";
my $NewLinkParams = ${QueryString};
$NewLinkParams =~ s/(^|&|&)update(=\w*|$)//i;
$NewLinkParams =~ s/(^|&|&)staticlinks(=\w*|$)//i;
$NewLinkParams =~ s/(^|&|&)year=[^&]*//i;
$NewLinkParams =~ s/(^|&|&)month=[^&]*//i;
$NewLinkParams =~ s/(^|&|&)framename=[^&]*//i;
$NewLinkParams =~ s/(&|&)+/&/i;
$NewLinkParams =~ s/^&//;
$NewLinkParams =~ s/&$//;
if ($NewLinkParams) { $NewLinkParams = "${NewLinkParams}&"; }
my $NewLinkTarget = '';
if ( $FrameName eq 'mainright' ) {
$NewLinkTarget = " target=\"_parent\"";
}
$average_nb = $average_u = $average_v = $average_p = $average_h =
$average_k = 0;
$total_u = $total_v = $total_p = $total_h = $total_k = 0;
# Define total and max
$max_v = $max_h = $max_k =
0; # Start from 0 because can be lower than 1
foreach my $daycursor ( $firstdaytoshowtime .. $lastdaytoshowtime )
{
$daycursor =~ /^(\d\d\d\d)(\d\d)(\d\d)/;
my $year = $1;
my $month = $2;
my $day = $3;
if ( !DateIsValid( $day, $month, $year ) ) {
next;
} # If not an existing day, go to next
$total_v += $DayVisits{ $year . $month . $day } || 0;
$total_p += $DayPages{ $year . $month . $day } || 0;
$total_h += $DayHits{ $year . $month . $day } || 0;
$total_k += $DayBytes{ $year . $month . $day } || 0;
if ( ( $DayVisits{ $year . $month . $day } || 0 ) > $max_v ) {
$max_v = $DayVisits{ $year . $month . $day };
}
#if (($DayPages{$year.$month.$day}||0) > $max_p) { $max_p=$DayPages{$year.$month.$day}; }
if ( ( $DayHits{ $year . $month . $day } || 0 ) > $max_h ) {
$max_h = $DayHits{ $year . $month . $day };
}
if ( ( $DayBytes{ $year . $month . $day } || 0 ) > $max_k ) {
$max_k = $DayBytes{ $year . $month . $day };
}
}
# Define average
foreach my $daycursor (
$firstdaytocountaverage .. $lastdaytocountaverage )
{
$daycursor =~ /^(\d\d\d\d)(\d\d)(\d\d)/;
my $year = $1;
my $month = $2;
my $day = $3;
if ( !DateIsValid( $day, $month, $year ) ) {
next;
} # If not an existing day, go to next
$average_nb++; # Increase number of day used to count
$average_v += ( $DayVisits{$daycursor} || 0 );
$average_p += ( $DayPages{$daycursor} || 0 );
$average_h += ( $DayHits{$daycursor} || 0 );
$average_k += ( $DayBytes{$daycursor} || 0 );
}
if ($average_nb) {
$average_v = $average_v / $average_nb;
$average_p = $average_p / $average_nb;
$average_h = $average_h / $average_nb;
$average_k = $average_k / $average_nb;
if ( $average_v > $max_v ) { $max_v = $average_v; }
#if ($average_p > $max_p) { $max_p=$average_p; }
if ( $average_h > $max_h ) { $max_h = $average_h; }
if ( $average_k > $max_k ) { $max_k = $average_k; }
}
else {
$average_v = "?";
$average_p = "?";
$average_h = "?";
$average_k = "?";
}
# Show bars for day
if ( $PluginsLoaded{'ShowGraph'}{'graphapplet'} ) {
my @blocklabel = ();
foreach
my $daycursor ( $firstdaytoshowtime .. $lastdaytoshowtime )
{
$daycursor =~ /^(\d\d\d\d)(\d\d)(\d\d)/;
my $year = $1;
my $month = $2;
my $day = $3;
if ( !DateIsValid( $day, $month, $year ) ) {
next;
} # If not an existing day, go to next
my $bold =
( $day == $nowday
&& $month == $nowmonth
&& $year == $nowyear ? ':' : '' );
my $weekend =
( DayOfWeek( $day, $month, $year ) =~ /[06]/ ? '!' : '' );
push @blocklabel,
"$day�$MonthNumLib{$month}$weekend$bold";
}
my @vallabel = (
"$Message[10]", "$Message[56]",
"$Message[57]", "$Message[75]"
);
my @valcolor =
( "$color_v", "$color_p", "$color_h", "$color_k" );
my @valmax = ( $max_v, $max_h, $max_h, $max_k );
my @valtotal = ( $total_v, $total_p, $total_h, $total_k );
$average_v = sprintf( "%.2f", $average_v );
$average_p = sprintf( "%.2f", $average_p );
$average_h = sprintf( "%.2f", $average_h );
$average_k = (
int($average_k)
? Format_Bytes( sprintf( "%.2f", $average_k ) )
: "0.00"
);
my @valaverage =
( $average_v, $average_p, $average_h, $average_k );
my @valdata = ();
my $xx = 0;
foreach
my $daycursor ( $firstdaytoshowtime .. $lastdaytoshowtime )
{
$daycursor =~ /^(\d\d\d\d)(\d\d)(\d\d)/;
my $year = $1;
my $month = $2;
my $day = $3;
if ( !DateIsValid( $day, $month, $year ) ) {
next;
} # If not an existing day, go to next
$valdata[ $xx++ ] = $DayVisits{ $year . $month . $day }
|| 0;
$valdata[ $xx++ ] = $DayPages{ $year . $month . $day } || 0;
$valdata[ $xx++ ] = $DayHits{ $year . $month . $day } || 0;
$valdata[ $xx++ ] = $DayBytes{ $year . $month . $day } || 0;
}
ShowGraph_graphapplet(
"$title", "daysofmonth",
$ShowDaysOfMonthStats, \@blocklabel,
\@vallabel, \@valcolor,
\@valmax, \@valtotal,
\@valaverage, \@valdata
);
}
else {
print "\n";
print "\n";
foreach
my $daycursor ( $firstdaytoshowtime .. $lastdaytoshowtime )
{
$daycursor =~ /^(\d\d\d\d)(\d\d)(\d\d)/;
my $year = $1;
my $month = $2;
my $day = $3;
if ( !DateIsValid( $day, $month, $year ) ) {
next;
} # If not an existing day, go to next
my $bredde_v = 0;
my $bredde_p = 0;
my $bredde_h = 0;
my $bredde_k = 0;
if ( $max_v > 0 ) {
$bredde_v =
int( ( $DayVisits{ $year . $month . $day } || 0 ) /
$max_v * $BarHeight ) + 1;
}
if ( $max_h > 0 ) {
$bredde_p =
int( ( $DayPages{ $year . $month . $day } || 0 ) /
$max_h * $BarHeight ) + 1;
}
if ( $max_h > 0 ) {
$bredde_h =
int( ( $DayHits{ $year . $month . $day } || 0 ) /
$max_h * $BarHeight ) + 1;
}
if ( $max_k > 0 ) {
$bredde_k =
int( ( $DayBytes{ $year . $month . $day } || 0 ) /
$max_k * $BarHeight ) + 1;
}
print "";
if ( $ShowDaysOfMonthStats =~ /V/i ) {
print
" ";
}
if ( $ShowDaysOfMonthStats =~ /P/i ) {
print
" ";
}
if ( $ShowDaysOfMonthStats =~ /H/i ) {
print
" ";
}
if ( $ShowDaysOfMonthStats =~ /B/i ) {
print
" ";
}
print " | \n";
}
print " | ";
# Show average value cell
print "";
my $bredde_v = 0;
my $bredde_p = 0;
my $bredde_h = 0;
my $bredde_k = 0;
if ( $max_v > 0 ) {
$bredde_v = int( $average_v / $max_v * $BarHeight ) + 1;
}
if ( $max_h > 0 ) {
$bredde_p = int( $average_p / $max_h * $BarHeight ) + 1;
}
if ( $max_h > 0 ) {
$bredde_h = int( $average_h / $max_h * $BarHeight ) + 1;
}
if ( $max_k > 0 ) {
$bredde_k = int( $average_k / $max_k * $BarHeight ) + 1;
}
$average_v = sprintf( "%.2f", $average_v );
$average_p = sprintf( "%.2f", $average_p );
$average_h = sprintf( "%.2f", $average_h );
$average_k = (
int($average_k)
? Format_Bytes( sprintf( "%.2f", $average_k ) )
: "0.00"
);
if ( $ShowDaysOfMonthStats =~ /V/i ) {
print
" ";
}
if ( $ShowDaysOfMonthStats =~ /P/i ) {
print
" ";
}
if ( $ShowDaysOfMonthStats =~ /H/i ) {
print
" ";
}
if ( $ShowDaysOfMonthStats =~ /B/i ) {
print
" ";
}
print " | \n";
print " \n";
# Show lib for day
print "";
foreach
my $daycursor ( $firstdaytoshowtime .. $lastdaytoshowtime )
{
$daycursor =~ /^(\d\d\d\d)(\d\d)(\d\d)/;
my $year = $1;
my $month = $2;
my $day = $3;
if ( !DateIsValid( $day, $month, $year ) ) {
next;
} # If not an existing day, go to next
my $dayofweekcursor = DayOfWeek( $day, $month, $year );
print "";
print(
!$StaticLinks
&& $day == $nowday
&& $month == $nowmonth
&& $year == $nowyear
? ''
: ''
);
print "$day "
. $MonthNumLib{$month}
. "";
print( !$StaticLinks
&& $day == $nowday
&& $month == $nowmonth
&& $year == $nowyear ? '' : '' );
print " | \n";
}
print " | ";
print "$Message[96] | \n";
print " \n";
print " \n";
}
print " \n";
# Show data array for days
if ($AddDataArrayShowDaysOfMonthStats) {
print "\n";
print
"| $Message[4] | ";
if ( $ShowDaysOfMonthStats =~ /V/i ) {
print "$Message[10] | ";
}
if ( $ShowDaysOfMonthStats =~ /P/i ) {
print "$Message[56] | ";
}
if ( $ShowDaysOfMonthStats =~ /H/i ) {
print "$Message[57] | ";
}
if ( $ShowDaysOfMonthStats =~ /B/i ) {
print "$Message[75] | ";
}
print " ";
foreach
my $daycursor ( $firstdaytoshowtime .. $lastdaytoshowtime )
{
$daycursor =~ /^(\d\d\d\d)(\d\d)(\d\d)/;
my $year = $1;
my $month = $2;
my $day = $3;
if ( !DateIsValid( $day, $month, $year ) ) {
next;
} # If not an existing day, go to next
my $dayofweekcursor = DayOfWeek( $day, $month, $year );
print "";
print "| "
. (
!$StaticLinks
&& $day == $nowday
&& $month == $nowmonth
&& $year == $nowyear
? ''
: ''
);
print Format_Date( "$year$month$day" . "000000", 2 );
print( !$StaticLinks
&& $day == $nowday
&& $month == $nowmonth
&& $year == $nowyear ? '' : '' );
print " | ";
if ( $ShowDaysOfMonthStats =~ /V/i ) {
print "",
$DayVisits{ $year . $month . $day }
? $DayVisits{ $year . $month . $day }
: "0", " | ";
}
if ( $ShowDaysOfMonthStats =~ /P/i ) {
print "",
$DayPages{ $year . $month . $day }
? $DayPages{ $year . $month . $day }
: "0", " | ";
}
if ( $ShowDaysOfMonthStats =~ /H/i ) {
print "",
$DayHits{ $year . $month . $day }
? $DayHits{ $year . $month . $day }
: "0", " | ";
}
if ( $ShowDaysOfMonthStats =~ /B/i ) {
print "",
Format_Bytes(
int( $DayBytes{ $year . $month . $day } || 0 ) ),
" | ";
}
print " \n";
}
# Average row
print
"| $Message[96] | ";
if ( $ShowDaysOfMonthStats =~ /V/i ) {
print "$average_v | ";
}
if ( $ShowDaysOfMonthStats =~ /P/i ) {
print "$average_p | ";
}
if ( $ShowDaysOfMonthStats =~ /H/i ) {
print "$average_h | ";
}
if ( $ShowDaysOfMonthStats =~ /B/i ) {
print "$average_k | ";
}
print " \n";
# Total row
print
"| $Message[102] | ";
if ( $ShowDaysOfMonthStats =~ /V/i ) {
print "$total_v | ";
}
if ( $ShowDaysOfMonthStats =~ /P/i ) {
print "$total_p | ";
}
if ( $ShowDaysOfMonthStats =~ /H/i ) {
print "$total_h | ";
}
if ( $ShowDaysOfMonthStats =~ /B/i ) {
print "" . Format_Bytes($total_k) . " | ";
}
print " \n";
print " \n ";
}
print "\n";
print " |
\n";
&tab_end();
}
# BY DAY OF WEEK
#-------------------------
if ($ShowDaysOfWeekStats) {
if ($Debug) { debug( "ShowDaysOfWeekStats", 2 ); }
print "$Center
\n";
my $title = "$Message[91]";
&tab_head( "$title", 18, 0, 'daysofweek' );
print "";
print "";
print "\n";
$max_h = $max_k = 0; # Start from 0 because can be lower than 1
# Get average value for day of week
my @avg_dayofweek_nb = ();
my @avg_dayofweek_p = ();
my @avg_dayofweek_h = ();
my @avg_dayofweek_k = ();
foreach my $daycursor (
$firstdaytocountaverage .. $lastdaytocountaverage )
{
$daycursor =~ /^(\d\d\d\d)(\d\d)(\d\d)/;
my $year = $1;
my $month = $2;
my $day = $3;
if ( !DateIsValid( $day, $month, $year ) ) {
next;
} # If not an existing day, go to next
my $dayofweekcursor = DayOfWeek( $day, $month, $year );
$avg_dayofweek_nb[$dayofweekcursor]
++; # Increase number of day used to count for this day of week
$avg_dayofweek_p[$dayofweekcursor] +=
( $DayPages{$daycursor} || 0 );
$avg_dayofweek_h[$dayofweekcursor] +=
( $DayHits{$daycursor} || 0 );
$avg_dayofweek_k[$dayofweekcursor] +=
( $DayBytes{$daycursor} || 0 );
}
for (@DOWIndex) {
if ( $avg_dayofweek_nb[$_] ) {
$avg_dayofweek_p[$_] =
$avg_dayofweek_p[$_] / $avg_dayofweek_nb[$_];
$avg_dayofweek_h[$_] =
$avg_dayofweek_h[$_] / $avg_dayofweek_nb[$_];
$avg_dayofweek_k[$_] =
$avg_dayofweek_k[$_] / $avg_dayofweek_nb[$_];
#if ($avg_dayofweek_p[$_] > $max_p) { $max_p = $avg_dayofweek_p[$_]; }
if ( $avg_dayofweek_h[$_] > $max_h ) {
$max_h = $avg_dayofweek_h[$_];
}
if ( $avg_dayofweek_k[$_] > $max_k ) {
$max_k = $avg_dayofweek_k[$_];
}
}
else {
$avg_dayofweek_p[$_] = "?";
$avg_dayofweek_h[$_] = "?";
$avg_dayofweek_k[$_] = "?";
}
}
# Show bars for days of week
if ( $PluginsLoaded{'ShowGraph'}{'graphapplet'} ) {
my @blocklabel = ();
for (@DOWIndex) {
push @blocklabel,
( $Message[ $_ + 84 ] . ( $_ =~ /[06]/ ? "!" : "" ) );
}
my @vallabel =
( "$Message[56]", "$Message[57]", "$Message[75]" );
my @valcolor = ( "$color_p", "$color_h", "$color_k" );
my @valmax = ( int($max_h), int($max_h), int($max_k) );
my @valtotal = ( $total_p, $total_h, $total_k );
$average_p = sprintf( "%.2f", $average_p );
$average_h = sprintf( "%.2f", $average_h );
$average_k = (
int($average_k)
? Format_Bytes( sprintf( "%.2f", $average_k ) )
: "0.00"
);
my @valaverage = ( $average_p, $average_h, $average_k );
my @valdata = ();
my $xx = 0;
for (@DOWIndex) {
$valdata[ $xx++ ] = $avg_dayofweek_p[$_] || 0;
$valdata[ $xx++ ] = $avg_dayofweek_h[$_] || 0;
$valdata[ $xx++ ] = $avg_dayofweek_k[$_] || 0;
# Round to be ready to show array
$avg_dayofweek_p[$_] =
sprintf( "%.2f", $avg_dayofweek_p[$_] );
$avg_dayofweek_h[$_] =
sprintf( "%.2f", $avg_dayofweek_h[$_] );
$avg_dayofweek_k[$_] =
sprintf( "%.2f", $avg_dayofweek_k[$_] );
# Remove decimal part that are .0
if ( $avg_dayofweek_p[$_] == int( $avg_dayofweek_p[$_] ) ) {
$avg_dayofweek_p[$_] = int( $avg_dayofweek_p[$_] );
}
if ( $avg_dayofweek_h[$_] == int( $avg_dayofweek_h[$_] ) ) {
$avg_dayofweek_h[$_] = int( $avg_dayofweek_h[$_] );
}
}
ShowGraph_graphapplet(
"$title", "daysofweek",
$ShowDaysOfWeekStats, \@blocklabel,
\@vallabel, \@valcolor,
\@valmax, \@valtotal,
\@valaverage, \@valdata
);
}
else {
print "\n";
print "\n";
for (@DOWIndex) {
my $bredde_p = 0;
my $bredde_h = 0;
my $bredde_k = 0;
if ( $max_h > 0 ) {
$bredde_p = int(
(
$avg_dayofweek_p[$_] ne '?'
? $avg_dayofweek_p[$_]
: 0
) / $max_h * $BarHeight
) + 1;
}
if ( $max_h > 0 ) {
$bredde_h = int(
(
$avg_dayofweek_h[$_] ne '?'
? $avg_dayofweek_h[$_]
: 0
) / $max_h * $BarHeight
) + 1;
}
if ( $max_k > 0 ) {
$bredde_k = int(
(
$avg_dayofweek_k[$_] ne '?'
? $avg_dayofweek_k[$_]
: 0
) / $max_k * $BarHeight
) + 1;
}
$avg_dayofweek_p[$_] = sprintf(
"%.2f",
(
$avg_dayofweek_p[$_] ne '?'
? $avg_dayofweek_p[$_]
: 0
)
);
$avg_dayofweek_h[$_] = sprintf(
"%.2f",
(
$avg_dayofweek_h[$_] ne '?'
? $avg_dayofweek_h[$_]
: 0
)
);
$avg_dayofweek_k[$_] = sprintf(
"%.2f",
(
$avg_dayofweek_k[$_] ne '?'
? $avg_dayofweek_k[$_]
: 0
)
);
# Remove decimal part that are .0
if ( $avg_dayofweek_p[$_] == int( $avg_dayofweek_p[$_] ) ) {
$avg_dayofweek_p[$_] = int( $avg_dayofweek_p[$_] );
}
if ( $avg_dayofweek_h[$_] == int( $avg_dayofweek_h[$_] ) ) {
$avg_dayofweek_h[$_] = int( $avg_dayofweek_h[$_] );
}
print "";
if ( $ShowDaysOfWeekStats =~ /P/i ) {
print
" ";
}
if ( $ShowDaysOfWeekStats =~ /H/i ) {
print
" ";
}
if ( $ShowDaysOfWeekStats =~ /B/i ) {
print
" ";
}
print " | \n";
}
print " \n";
print "\n";
for (@DOWIndex) {
print "| "
. (
!$StaticLinks
&& $_ == ( $nowwday - 1 )
&& $MonthRequired == $nowmonth
&& $YearRequired == $nowyear
? ''
: ''
);
print $Message[ $_ + 84 ];
print( !$StaticLinks
&& $_ == ( $nowwday - 1 )
&& $MonthRequired == $nowmonth
&& $YearRequired == $nowyear ? '' : '' );
print " | ";
}
print " \n \n";
}
print " \n";
# Show data array for days of week
if ($AddDataArrayShowDaysOfWeekStats) {
print "\n";
print
"| $Message[4] | ";
if ( $ShowDaysOfWeekStats =~ /P/i ) {
print "$Message[56] | ";
}
if ( $ShowDaysOfWeekStats =~ /H/i ) {
print "$Message[57] | ";
}
if ( $ShowDaysOfWeekStats =~ /B/i ) {
print "$Message[75] | ";
}
for (@DOWIndex) {
print "";
print "| "
. (
!$StaticLinks
&& $_ == ( $nowwday - 1 )
&& $MonthRequired == $nowmonth
&& $YearRequired == $nowyear
? ''
: ''
);
print $Message[ $_ + 84 ];
print( !$StaticLinks
&& $_ == ( $nowwday - 1 )
&& $MonthRequired == $nowmonth
&& $YearRequired == $nowyear ? '' : '' );
print " | ";
if ( $ShowDaysOfWeekStats =~ /P/i ) {
print "", $avg_dayofweek_p[$_], " | ";
}
if ( $ShowDaysOfWeekStats =~ /H/i ) {
print "", $avg_dayofweek_h[$_], " | ";
}
if ( $ShowDaysOfWeekStats =~ /B/i ) {
print "", Format_Bytes( $avg_dayofweek_k[$_] ),
" | ";
}
print " \n";
}
print " \n \n";
}
print " | ";
print "
\n";
&tab_end();
}
# BY HOUR
#----------------------------
if ($ShowHoursStats) {
if ($Debug) { debug( "ShowHoursStats", 2 ); }
print "$Center
\n";
my $title = "$Message[20]";
if ( $PluginsLoaded{'GetTimeZoneTitle'}{'timezone'} ) {
$title .= " (GMT "
. ( GetTimeZoneTitle_timezone() >= 0 ? "+" : "" )
. int( GetTimeZoneTitle_timezone() ) . ")";
}
&tab_head( "$title", 19, 0, 'hours' );
print "\n";
print "\n";
$max_h = $max_k = 1;
for ( my $ix = 0 ; $ix <= 23 ; $ix++ ) {
#if ($_time_p[$ix]>$max_p) { $max_p=$_time_p[$ix]; }
if ( $_time_h[$ix] > $max_h ) { $max_h = $_time_h[$ix]; }
if ( $_time_k[$ix] > $max_k ) { $max_k = $_time_k[$ix]; }
}
# Show bars for hour
if ( $PluginsLoaded{'ShowGraph'}{'graphapplet'} ) {
my @blocklabel = ( 0 .. 23 );
my @vallabel =
( "$Message[56]", "$Message[57]", "$Message[75]" );
my @valcolor = ( "$color_p", "$color_h", "$color_k" );
my @valmax = ( int($max_h), int($max_h), int($max_k) );
my @valtotal = ( $total_p, $total_h, $total_k );
my @valaverage = ( $average_p, $average_h, $average_k );
my @valdata = ();
my $xx = 0;
for ( 0 .. 23 ) {
$valdata[ $xx++ ] = $_time_p[$_] || 0;
$valdata[ $xx++ ] = $_time_h[$_] || 0;
$valdata[ $xx++ ] = $_time_k[$_] || 0;
}
ShowGraph_graphapplet(
"$title", "hours",
$ShowHoursStats, \@blocklabel,
\@vallabel, \@valcolor,
\@valmax, \@valtotal,
\@valaverage, \@valdata
);
}
else {
print "\n";
print "\n";
for ( my $ix = 0 ; $ix <= 23 ; $ix++ ) {
my $bredde_p = 0;
my $bredde_h = 0;
my $bredde_k = 0;
if ( $max_h > 0 ) {
$bredde_p =
int( $BarHeight * $_time_p[$ix] / $max_h ) + 1;
}
if ( $max_h > 0 ) {
$bredde_h =
int( $BarHeight * $_time_h[$ix] / $max_h ) + 1;
}
if ( $max_k > 0 ) {
$bredde_k =
int( $BarHeight * $_time_k[$ix] / $max_k ) + 1;
}
print "";
if ( $ShowHoursStats =~ /P/i ) {
print
" ";
}
if ( $ShowHoursStats =~ /H/i ) {
print
" ";
}
if ( $ShowHoursStats =~ /B/i ) {
print
" ";
}
print " | \n";
}
print " \n";
# Show hour lib
print "";
for ( my $ix = 0 ; $ix <= 23 ; $ix++ ) {
print "| $ix | \n"
; # width=19 instead of 18 to avoid a MacOS browser bug.
}
print " \n";
# Show clock icon
print "\n";
for ( my $ix = 0 ; $ix <= 23 ; $ix++ ) {
my $hrs = ( $ix >= 12 ? $ix - 12 : $ix );
my $hre = ( $ix >= 12 ? $ix - 11 : $ix + 1 );
my $apm = ( $ix >= 12 ? "pm" : "am" );
print
" | \n";
}
print " \n";
print " \n";
}
print " \n";
# Show data array for hours
if ($AddDataArrayShowHoursStats) {
print "\n";
print "\n";
print "\n";
print
"| $Message[20] | ";
if ( $ShowHoursStats =~ /P/i ) {
print "$Message[56] | ";
}
if ( $ShowHoursStats =~ /H/i ) {
print "$Message[57] | ";
}
if ( $ShowHoursStats =~ /B/i ) {
print "$Message[75] | ";
}
print " ";
for ( my $ix = 0 ; $ix <= 11 ; $ix++ ) {
my $monthix = ( $ix < 10 ? "0$ix" : "$ix" );
print "";
print "| $monthix | ";
if ( $ShowHoursStats =~ /P/i ) {
print "",
$_time_p[$monthix] ? $_time_p[$monthix] : "0",
" | ";
}
if ( $ShowHoursStats =~ /H/i ) {
print "",
$_time_h[$monthix] ? $_time_h[$monthix] : "0",
" | ";
}
if ( $ShowHoursStats =~ /B/i ) {
print "", Format_Bytes( int( $_time_k[$monthix] ) ),
" | ";
}
print " \n";
}
print " \n";
print " | ";
print " | ";
print "\n";
print "\n";
print
"| $Message[20] | ";
if ( $ShowHoursStats =~ /P/i ) {
print "$Message[56] | ";
}
if ( $ShowHoursStats =~ /H/i ) {
print "$Message[57] | ";
}
if ( $ShowHoursStats =~ /B/i ) {
print "$Message[75] | ";
}
print " \n";
for ( my $ix = 12 ; $ix <= 23 ; $ix++ ) {
my $monthix = ( $ix < 10 ? "0$ix" : "$ix" );
print "";
print "| $monthix | ";
if ( $ShowHoursStats =~ /P/i ) {
print "",
$_time_p[$monthix] ? $_time_p[$monthix] : "0",
" | ";
}
if ( $ShowHoursStats =~ /H/i ) {
print "",
$_time_h[$monthix] ? $_time_h[$monthix] : "0",
" | ";
}
if ( $ShowHoursStats =~ /B/i ) {
print "", Format_Bytes( int( $_time_k[$monthix] ) ),
" | ";
}
print " \n";
}
print " \n";
print " | \n";
print " \n";
}
print " |
\n";
&tab_end();
}
print "\n \n\n";
# BY COUNTRY/DOMAIN
#---------------------------
if ($ShowDomainsStats) {
if ($Debug) { debug( "ShowDomainsStats", 2 ); }
print "$Center
\n";
my $title =
"$Message[25] ($Message[77] $MaxNbOf{'Domain'}) - $Message[80]";
&tab_head( "$title", 19, 0, 'countries' );
print
"| | $Message[17] | ";
## to add unique visitors and number of visits by calculation of average of the relation with total
## pages and total hits, and total visits and total unique
## by Josep Ruano @ CAPSiDE
if ( $ShowDomainsStats =~ /U/i ) {
print "$Message[11] | ";
}
if ( $ShowDomainsStats =~ /V/i ) {
print "$Message[10] | ";
}
if ( $ShowDomainsStats =~ /P/i ) {
print "$Message[56] | ";
}
if ( $ShowDomainsStats =~ /H/i ) {
print "$Message[57] | ";
}
if ( $ShowDomainsStats =~ /B/i ) {
print "$Message[75] | ";
}
print " | ";
print "
\n";
$total_u = $total_v = $total_p = $total_h = $total_k = 0;
$max_h = 1;
foreach ( values %_domener_h ) {
if ( $_ > $max_h ) { $max_h = $_; }
}
$max_k = 1;
foreach ( values %_domener_k ) {
if ( $_ > $max_k ) { $max_k = $_; }
}
my $count = 0;
&BuildKeyList(
$MaxNbOf{'Domain'}, $MinHit{'Domain'},
\%_domener_h, \%_domener_p
);
foreach my $key (@keylist) {
my ( $_domener_u, $_domener_v );
my $bredde_p = 0;
my $bredde_h = 0;
my $bredde_k = 0;
my $bredde_u = 0;
my $bredde_v = 0;
if ( $max_h > 0 ) {
$bredde_p =
int( $BarWidth * $_domener_p{$key} / $max_h ) + 1;
} # use max_h to enable to compare pages with hits
if ( $_domener_p{$key} && $bredde_p == 1 ) { $bredde_p = 2; }
if ( $max_h > 0 ) {
$bredde_h =
int( $BarWidth * $_domener_h{$key} / $max_h ) + 1;
}
if ( $_domener_h{$key} && $bredde_h == 1 ) { $bredde_h = 2; }
if ( $max_k > 0 ) {
$bredde_k =
int( $BarWidth * ( $_domener_k{$key} || 0 ) / $max_k ) +
1;
}
if ( $_domener_k{$key} && $bredde_k == 1 ) { $bredde_k = 2; }
my $newkey = lc($key);
if ( $newkey eq 'ip' || !$DomainsHashIDLib{$newkey} ) {
print
" | $Message[0] | $newkey | ";
}
else {
print
"
 | $DomainsHashIDLib{$newkey} | $newkey | ";
}
## to add unique visitors and number of visits, by Josep Ruano @ CAPSiDE
if ( $ShowDomainsStats =~ /U/i ) {
$_domener_u = (
$_domener_p{$key}
? $_domener_p{$key} / $TotalPages
: 0
);
$_domener_u += ( $_domener_h{$key} / $TotalHits );
$_domener_u =
sprintf( "%.0f", ( $_domener_u * $TotalUnique ) / 2 );
print "$_domener_u ("
. sprintf( "%.1f%", 100 * $_domener_u / $TotalUnique )
. ") | ";
}
if ( $ShowDomainsStats =~ /V/i ) {
$_domener_v = (
$_domener_p{$key}
? $_domener_p{$key} / $TotalPages
: 0
);
$_domener_v += ( $_domener_h{$key} / $TotalHits );
$_domener_v =
sprintf( "%.0f", ( $_domener_v * $TotalVisits ) / 2 );
print "$_domener_v ("
. sprintf( "%.1f%", 100 * $_domener_v / $TotalVisits )
. ") | ";
}
if ( $ShowDomainsStats =~ /P/i ) {
print ""
. ( $_domener_p{$key} ? $_domener_p{$key} : ' ' )
. " | ";
}
if ( $ShowDomainsStats =~ /H/i ) {
print "$_domener_h{$key} | ";
}
if ( $ShowDomainsStats =~ /B/i ) {
print "" . Format_Bytes( $_domener_k{$key} ) . " | ";
}
print "";
if ( $ShowDomainsStats =~ /P/i ) {
print
" \n";
}
if ( $ShowDomainsStats =~ /H/i ) {
print
" \n";
}
if ( $ShowDomainsStats =~ /B/i ) {
print
" ";
}
print " | ";
print "
\n";
$total_u += $_domener_u;
$total_v += $_domener_v;
$total_p += $_domener_p{$key};
$total_h += $_domener_h{$key};
$total_k += $_domener_k{$key} || 0;
$count++;
}
my $rest_u = $TotalUnique - $total_u;
my $rest_v = $TotalVisits - $total_v;
$rest_p = $TotalPages - $total_p;
$rest_h = $TotalHits - $total_h;
$rest_k = $TotalBytes - $total_k;
if ( $rest_u > 0
|| $rest_v > 0
|| $rest_p > 0
|| $rest_h > 0
|| $rest_k > 0 )
{ # All other domains (known or not)
print
"| | $Message[2] | ";
if ( $ShowDomainsStats =~ /U/i ) { print "$rest_u | "; }
if ( $ShowDomainsStats =~ /V/i ) { print "$rest_v | "; }
if ( $ShowDomainsStats =~ /P/i ) { print "$rest_p | "; }
if ( $ShowDomainsStats =~ /H/i ) { print "$rest_h | "; }
if ( $ShowDomainsStats =~ /B/i ) {
print "" . Format_Bytes($rest_k) . " | ";
}
print " | ";
print "
\n";
}
&tab_end();
}
# BY HOST/VISITOR
#--------------------------
if ($ShowHostsStats) {
if ($Debug) { debug( "ShowHostsStats", 2 ); }
print "$Center
\n";
my $title =
"$Message[81] ($Message[77] $MaxNbOf{'HostsShown'}) - $Message[80] - $Message[9] - $Message[45]";
&tab_head( "$title", 19, 0, 'visitors' );
print "";
print "";
if ( $MonthRequired ne 'all' ) {
print
"$Message[81] : $TotalHostsKnown $Message[82], $TotalHostsUnknown $Message[1] $TotalUnique $Message[11] | ";
}
else {
print "$Message[81] : " . ( scalar keys %_host_h ) . "";
}
&ShowHostInfo('__title__');
if ( $ShowHostsStats =~ /P/i ) {
print "$Message[56] | ";
}
if ( $ShowHostsStats =~ /H/i ) {
print "$Message[57] | ";
}
if ( $ShowHostsStats =~ /B/i ) {
print "$Message[75] | ";
}
if ( $ShowHostsStats =~ /L/i ) {
print "$Message[9] | ";
}
print "
\n";
$total_p = $total_h = $total_k = 0;
my $count = 0;
&BuildKeyList( $MaxNbOf{'HostsShown'}, $MinHit{'Host'}, \%_host_h,
\%_host_p );
foreach my $key (@keylist) {
print "";
print "| $key | ";
&ShowHostInfo($key);
if ( $ShowHostsStats =~ /P/i ) {
print '' . ( $_host_p{$key} || " " ) . ' | ';
}
if ( $ShowHostsStats =~ /H/i ) {
print "$_host_h{$key} | ";
}
if ( $ShowHostsStats =~ /B/i ) {
print '' . Format_Bytes( $_host_k{$key} ) . ' | ';
}
if ( $ShowHostsStats =~ /L/i ) {
print ''
. (
$_host_l{$key}
? Format_Date( $_host_l{$key}, 1 )
: '-'
)
. ' | ';
}
print "
\n";
$total_p += $_host_p{$key};
$total_h += $_host_h{$key};
$total_k += $_host_k{$key} || 0;
$count++;
}
$rest_p = $TotalPages - $total_p;
$rest_h = $TotalHits - $total_h;
$rest_k = $TotalBytes - $total_k;
if ( $rest_p > 0 || $rest_h > 0 || $rest_k > 0 )
{ # All other visitors (known or not)
print "";
print
"| $Message[2] | ";
&ShowHostInfo('');
if ( $ShowHostsStats =~ /P/i ) { print "$rest_p | "; }
if ( $ShowHostsStats =~ /H/i ) { print "$rest_h | "; }
if ( $ShowHostsStats =~ /B/i ) {
print "" . Format_Bytes($rest_k) . " | ";
}
if ( $ShowHostsStats =~ /L/i ) { print " | "; }
print "
\n";
}
&tab_end();
}
# BY SENDER EMAIL
#----------------------------
if ($ShowEMailSenders) {
&ShowEmailSendersChart( $NewLinkParams, $NewLinkTarget );
}
# BY RECEIVER EMAIL
#----------------------------
if ($ShowEMailReceivers) {
&ShowEmailReceiversChart( $NewLinkParams, $NewLinkTarget );
}
# BY LOGIN
#----------------------------
if ($ShowAuthenticatedUsers) {
if ($Debug) { debug( "ShowAuthenticatedUsers", 2 ); }
print "$Center
\n";
my $title =
"$Message[94] ($Message[77] $MaxNbOf{'LoginShown'}) - $Message[80]";
if ( $ShowAuthenticatedUsers =~ /L/i ) {
$title .= " - $Message[9]";
}
&tab_head( "$title", 19, 0, 'logins' );
print "| $Message[94] : "
. ( scalar keys %_login_h ) . " | ";
&ShowUserInfo('__title__');
if ( $ShowAuthenticatedUsers =~ /P/i ) {
print "$Message[56] | ";
}
if ( $ShowAuthenticatedUsers =~ /H/i ) {
print "$Message[57] | ";
}
if ( $ShowAuthenticatedUsers =~ /B/i ) {
print "$Message[75] | ";
}
if ( $ShowAuthenticatedUsers =~ /L/i ) {
print "$Message[9] | ";
}
print "
\n";
$total_p = $total_h = $total_k = 0;
$max_h = 1;
foreach ( values %_login_h ) {
if ( $_ > $max_h ) { $max_h = $_; }
}
$max_k = 1;
foreach ( values %_login_k ) {
if ( $_ > $max_k ) { $max_k = $_; }
}
my $count = 0;
&BuildKeyList( $MaxNbOf{'LoginShown'}, $MinHit{'Login'}, \%_login_h,
\%_login_p );
foreach my $key (@keylist) {
my $bredde_p = 0;
my $bredde_h = 0;
my $bredde_k = 0;
if ( $max_h > 0 ) {
$bredde_p = int( $BarWidth * $_login_p{$key} / $max_h ) + 1;
} # use max_h to enable to compare pages with hits
if ( $max_h > 0 ) {
$bredde_h = int( $BarWidth * $_login_h{$key} / $max_h ) + 1;
}
if ( $max_k > 0 ) {
$bredde_k = int( $BarWidth * $_login_k{$key} / $max_k ) + 1;
}
print "| $key | ";
&ShowUserInfo($key);
if ( $ShowAuthenticatedUsers =~ /P/i ) {
print ""
. ( $_login_p{$key} ? $_login_p{$key} : " " )
. " | ";
}
if ( $ShowAuthenticatedUsers =~ /H/i ) {
print "$_login_h{$key} | ";
}
if ( $ShowAuthenticatedUsers =~ /B/i ) {
print "" . Format_Bytes( $_login_k{$key} ) . " | ";
}
if ( $ShowAuthenticatedUsers =~ /L/i ) {
print ""
. (
$_login_l{$key}
? Format_Date( $_login_l{$key}, 1 )
: '-'
)
. " | ";
}
print "
\n";
$total_p += $_login_p{$key};
$total_h += $_login_h{$key};
$total_k += $_login_k{$key};
$count++;
}
$rest_p = $TotalPages - $total_p;
$rest_h = $TotalHits - $total_h;
$rest_k = $TotalBytes - $total_k;
if ( $rest_p > 0 || $rest_h > 0 || $rest_k > 0 )
{ # All other logins
print
"| "
. ( $PageDir eq 'rtl' ? "" : "" )
. "$Message[125]"
. ( $PageDir eq 'rtl' ? "" : "" )
. " | ";
&ShowUserInfo('');
if ( $ShowAuthenticatedUsers =~ /P/i ) {
print "" . ( $rest_p ? $rest_p : " " ) . " | ";
}
if ( $ShowAuthenticatedUsers =~ /H/i ) {
print "$rest_h | ";
}
if ( $ShowAuthenticatedUsers =~ /B/i ) {
print "" . Format_Bytes($rest_k) . " | ";
}
if ( $ShowAuthenticatedUsers =~ /L/i ) {
print " | ";
}
print "
\n";
}
&tab_end();
}
# BY ROBOTS
#----------------------------
if ($ShowRobotsStats) {
if ($Debug) { debug( "ShowRobotStats", 2 ); }
print "$Center
\n";
&tab_head(
"$Message[53] ($Message[77] $MaxNbOf{'RobotShown'}) - $Message[80] - $Message[9]",
19, 0, 'robots'
);
print "| "
. ( scalar keys %_robot_h )
. " $Message[51]* | ";
if ( $ShowRobotsStats =~ /H/i ) {
print
"$Message[57] | ";
}
if ( $ShowRobotsStats =~ /B/i ) {
print
"$Message[75] | ";
}
if ( $ShowRobotsStats =~ /L/i ) {
print "$Message[9] | ";
}
print "
\n";
$total_p = $total_h = $total_k = $total_r = 0;
my $count = 0;
&BuildKeyList( $MaxNbOf{'RobotShown'}, $MinHit{'Robot'}, \%_robot_h,
\%_robot_h );
foreach my $key (@keylist) {
print "| "
. ( $PageDir eq 'rtl' ? "" : "" )
. ( $RobotsHashIDLib{$key} ? $RobotsHashIDLib{$key} : $key )
. ( $PageDir eq 'rtl' ? "" : "" ) . " | ";
if ( $ShowRobotsStats =~ /H/i ) {
print ""
. ( $_robot_h{$key} - $_robot_r{$key} )
. ( $_robot_r{$key} ? "+$_robot_r{$key}" : "" ) . " | ";
}
if ( $ShowRobotsStats =~ /B/i ) {
print "" . Format_Bytes( $_robot_k{$key} ) . " | ";
}
if ( $ShowRobotsStats =~ /L/i ) {
print ""
. (
$_robot_l{$key}
? Format_Date( $_robot_l{$key}, 1 )
: '-'
)
. " | ";
}
print "
\n";
#$total_p += $_robot_p{$key};
$total_h += $_robot_h{$key};
$total_k += $_robot_k{$key} || 0;
$total_r += $_robot_r{$key} || 0;
$count++;
}
# For bots we need to count Totals
my $TotalPagesRobots =
0; #foreach (values %_robot_p) { $TotalPagesRobots+=$_; }
my $TotalHitsRobots = 0;
foreach ( values %_robot_h ) { $TotalHitsRobots += $_; }
my $TotalBytesRobots = 0;
foreach ( values %_robot_k ) { $TotalBytesRobots += $_; }
my $TotalRRobots = 0;
foreach ( values %_robot_r ) { $TotalRRobots += $_; }
$rest_p = 0; #$rest_p=$TotalPagesRobots-$total_p;
$rest_h = $TotalHitsRobots - $total_h;
$rest_k = $TotalBytesRobots - $total_k;
$rest_r = $TotalRRobots - $total_r;
if ( $rest_p > 0 || $rest_h > 0 || $rest_k > 0 || $rest_r > 0 )
{ # All other robots
print
"| $Message[2] | ";
if ( $ShowRobotsStats =~ /H/i ) {
print ""
. ( $rest_h - $rest_r )
. ( $rest_r ? "+$rest_r" : "" ) . " | ";
}
if ( $ShowRobotsStats =~ /B/i ) {
print "" . ( Format_Bytes($rest_k) ) . " | ";
}
if ( $ShowRobotsStats =~ /L/i ) { print " | "; }
print "
\n";
}
&tab_end(
"* $Message[156]" . ( $TotalRRobots ? " $Message[157]" : "" ) );
}
# BY WORMS
#----------------------------
if ($ShowWormsStats) {
if ($Debug) { debug( "ShowWormsStats", 2 ); }
print "$Center
\n";
&tab_head( "$Message[163] ($Message[77] $MaxNbOf{'WormsShown'})",
19, 0, 'worms' );
print "";
print "| " . ( scalar keys %_worm_h ) . " $Message[164]* | ";
print "$Message[167] | ";
if ( $ShowWormsStats =~ /H/i ) {
print
"$Message[57] | ";
}
if ( $ShowWormsStats =~ /B/i ) {
print
"$Message[75] | ";
}
if ( $ShowWormsStats =~ /L/i ) {
print "$Message[9] | ";
}
print "
\n";
$total_p = $total_h = $total_k = 0;
my $count = 0;
&BuildKeyList( $MaxNbOf{'WormsShown'}, $MinHit{'Worm'}, \%_worm_h,
\%_worm_h );
foreach my $key (@keylist) {
print "";
print "| "
. ( $PageDir eq 'rtl' ? "" : "" )
. ( $WormsHashLib{$key} ? $WormsHashLib{$key} : $key )
. ( $PageDir eq 'rtl' ? "" : "" ) . " | ";
print ""
. ( $PageDir eq 'rtl' ? "" : "" )
. ( $WormsHashTarget{$key} ? $WormsHashTarget{$key} : $key )
. ( $PageDir eq 'rtl' ? "" : "" ) . " | ";
if ( $ShowWormsStats =~ /H/i ) {
print "" . $_worm_h{$key} . " | ";
}
if ( $ShowWormsStats =~ /B/i ) {
print "" . Format_Bytes( $_worm_k{$key} ) . " | ";
}
if ( $ShowWormsStats =~ /L/i ) {
print ""
. (
$_worm_l{$key}
? Format_Date( $_worm_l{$key}, 1 )
: '-'
)
. " | ";
}
print "
\n";
#$total_p += $_worm_p{$key};
$total_h += $_worm_h{$key};
$total_k += $_worm_k{$key} || 0;
$count++;
}
# For worms we need to count Totals
my $TotalPagesWorms =
0; #foreach (values %_worm_p) { $TotalPagesWorms+=$_; }
my $TotalHitsWorms = 0;
foreach ( values %_worm_h ) { $TotalHitsWorms += $_; }
my $TotalBytesWorms = 0;
foreach ( values %_worm_k ) { $TotalBytesWorms += $_; }
$rest_p = 0; #$rest_p=$TotalPagesRobots-$total_p;
$rest_h = $TotalHitsWorms - $total_h;
$rest_k = $TotalBytesWorms - $total_k;
if ( $rest_p > 0 || $rest_h > 0 || $rest_k > 0 ) { # All other worms
print "";
print
"| $Message[2] | ";
print "- | ";
if ( $ShowWormsStats =~ /H/i ) {
print "" . ($rest_h) . " | ";
}
if ( $ShowWormsStats =~ /B/i ) {
print "" . ( Format_Bytes($rest_k) ) . " | ";
}
if ( $ShowWormsStats =~ /L/i ) { print " | "; }
print "
\n";
}
&tab_end("* $Message[158]");
}
print "\n \n\n";
# BY SESSION
#----------------------------
if ($ShowSessionsStats) {
if ($Debug) { debug( "ShowSessionsStats", 2 ); }
print "$Center
\n";
my $title = "$Message[117]";
&tab_head( $title, 19, 0, 'sessions' );
my $Totals = 0;
foreach (@SessionsRange) {
$average_s += ( $_session{$_} || 0 ) * $SessionsAverage{$_};
$Totals += $_session{$_} || 0;
}
if ($Totals) { $average_s = int( $average_s / $Totals ); }
else { $average_s = '?'; }
print "| $Message[10]: $TotalVisits - $Message[96]: $average_s s | $Message[10] | $Message[15] |
\n";
$average_s = 0;
$total_s = 0;
my $count = 0;
foreach my $key (@SessionsRange) {
my $p = 0;
if ($TotalVisits) {
$p = int( $_session{$key} / $TotalVisits * 1000 ) / 10;
}
$total_s += $_session{$key} || 0;
print "| $key | ";
print ""
. ( $_session{$key} ? $_session{$key} : " " ) . " | ";
print ""
. ( $_session{$key} ? "$p %" : " " ) . " | ";
print "
\n";
$count++;
}
$rest_s = $TotalVisits - $total_s;
if ( $rest_s > 0 ) { # All others sessions
my $p = 0;
if ($TotalVisits) {
$p = int( $rest_s / $TotalVisits * 1000 ) / 10;
}
print "| $Message[0] | ";
print "$rest_s | ";
print "" . ( $rest_s ? "$p %" : " " ) . " | ";
print "
\n";
}
&tab_end();
}
# BY FILE TYPE
#-------------------------
if ($ShowFileTypesStats) {
if ($Debug) { debug( "ShowFileTypesStatsCompressionStats", 2 ); }
print "$Center
\n";
my $Totalh = 0;
foreach ( keys %_filetypes_h ) { $Totalh += $_filetypes_h{$_}; }
my $Totalk = 0;
foreach ( keys %_filetypes_k ) { $Totalk += $_filetypes_k{$_}; }
my $title = "$Message[73]";
if ( $ShowFileTypesStats =~ /C/i ) { $title .= " - $Message[98]"; }
&tab_head( "$title", 19, 0, 'filetypes' );
print
"| $Message[73] | ";
if ( $ShowFileTypesStats =~ /H/i ) {
print "$Message[57] | $Message[15] | ";
}
if ( $ShowFileTypesStats =~ /B/i ) {
print "$Message[75] | $Message[15] | ";
}
if ( $ShowFileTypesStats =~ /C/i ) {
print
"$Message[100] | $Message[101] | $Message[99] | ";
}
print "
\n";
my $total_con = 0;
my $total_cre = 0;
my $count = 0;
&BuildKeyList( $MaxRowsInHTMLOutput, 1, \%_filetypes_h,
\%_filetypes_h );
foreach my $key (@keylist) {
my $p_h = ' ';
my $p_k = ' ';
if ($Totalh) {
$p_h = int( $_filetypes_h{$key} / $Totalh * 1000 ) / 10;
$p_h = "$p_h %";
}
if ($Totalk) {
$p_k = int( $_filetypes_k{$key} / $Totalk * 1000 ) / 10;
$p_k = "$p_k %";
}
if ( $key eq 'Unknown' ) {
print " | $Message[0] | ";
}
else {
my $nameicon = $MimeHashIcon{$key} || "notavailable";
my $nametype =
$MimeHashLib{ $MimeHashFamily{$key} || "" } || " ";
print "
 | $key | ";
print "$nametype | ";
}
if ( $ShowFileTypesStats =~ /H/i ) {
print "$_filetypes_h{$key} | $p_h | ";
}
if ( $ShowFileTypesStats =~ /B/i ) {
print ''
. Format_Bytes( $_filetypes_k{$key} )
. " | $p_k | ";
}
if ( $ShowFileTypesStats =~ /C/i ) {
if ( $_filetypes_gz_in{$key} ) {
my $percent = int(
100 * (
1 - $_filetypes_gz_out{$key} /
$_filetypes_gz_in{$key}
)
);
printf(
"%s | %s | %s (%s%) | ",
Format_Bytes( $_filetypes_gz_in{$key} ),
Format_Bytes( $_filetypes_gz_out{$key} ),
Format_Bytes(
$_filetypes_gz_in{$key} -
$_filetypes_gz_out{$key}
),
$percent
);
$total_con += $_filetypes_gz_in{$key};
$total_cre += $_filetypes_gz_out{$key};
}
else {
print " | | | ";
}
}
print "
\n";
$count++;
}
# Add total (only usefull if compression is enabled)
if ( $ShowFileTypesStats =~ /C/i ) {
my $colspan = 3;
if ( $ShowFileTypesStats =~ /H/i ) { $colspan += 2; }
if ( $ShowFileTypesStats =~ /B/i ) { $colspan += 2; }
print "";
print
"| $Message[98] | ";
if ( $ShowFileTypesStats =~ /C/i ) {
if ($total_con) {
my $percent =
int( 100 * ( 1 - $total_cre / $total_con ) );
printf(
"%s | %s | %s (%s%) | ",
Format_Bytes($total_con),
Format_Bytes($total_cre),
Format_Bytes( $total_con - $total_cre ),
$percent
);
}
else {
print " | | | ";
}
}
print "
\n";
}
&tab_end();
}
# BY FILE SIZE
#-------------------------
if ($ShowFileSizesStats) {
}
# BY FILE/URL
#-------------------------
if ($ShowPagesStats) {
if ($Debug) {
debug(
"ShowPagesStats (MaxNbOf{'PageShown'}=$MaxNbOf{'PageShown'} TotalDifferentPages=$TotalDifferentPages)",
2
);
}
print
"$Center
\n";
my $title =
"$Message[19] ($Message[77] $MaxNbOf{'PageShown'}) - $Message[80]";
if ( $ShowPagesStats =~ /E/i ) {
$title .= " - $Message[104]";
}
if ( $ShowPagesStats =~ /X/i ) {
$title .= " - $Message[116]";
}
&tab_head( "$title", 19, 0, 'urls' );
print
"| $TotalDifferentPages $Message[28] | ";
if ( $ShowPagesStats =~ /P/i && $LogType ne 'F' ) {
print
"$Message[29] | ";
}
if ( $ShowPagesStats =~ /[PH]/i && $LogType eq 'F' ) {
print
"$Message[57] | ";
}
if ( $ShowPagesStats =~ /B/i ) {
print
"$Message[106] | ";
}
if ( $ShowPagesStats =~ /E/i ) {
print
"$Message[104] | ";
}
if ( $ShowPagesStats =~ /X/i ) {
print
"$Message[116] | ";
}
# Call to plugins' function ShowPagesAddField
foreach
my $pluginname ( keys %{ $PluginsLoaded{'ShowPagesAddField'} } )
{
# my $function="ShowPagesAddField_$pluginname('title')";
# eval("$function");
my $function = "ShowPagesAddField_$pluginname";
&$function('title');
}
print " |
\n";
$total_p = $total_e = $total_x = $total_k = 0;
$max_p = 1;
$max_k = 1;
my $count = 0;
&BuildKeyList( $MaxNbOf{'PageShown'}, $MinHit{'File'}, \%_url_p,
\%_url_p );
foreach my $key (@keylist) {
if ( $_url_p{$key} > $max_p ) { $max_p = $_url_p{$key}; }
if ( $_url_k{$key} / ( $_url_p{$key} || 1 ) > $max_k ) {
$max_k = $_url_k{$key} / ( $_url_p{$key} || 1 );
}
}
foreach my $key (@keylist) {
print "| ";
&ShowURLInfo($key);
print " | ";
my $bredde_p = 0;
my $bredde_e = 0;
my $bredde_x = 0;
my $bredde_k = 0;
if ( $max_p > 0 ) {
$bredde_p =
int( $BarWidth * ( $_url_p{$key} || 0 ) / $max_p ) + 1;
}
if ( ( $bredde_p == 1 ) && $_url_p{$key} ) { $bredde_p = 2; }
if ( $max_p > 0 ) {
$bredde_e =
int( $BarWidth * ( $_url_e{$key} || 0 ) / $max_p ) + 1;
}
if ( ( $bredde_e == 1 ) && $_url_e{$key} ) { $bredde_e = 2; }
if ( $max_p > 0 ) {
$bredde_x =
int( $BarWidth * ( $_url_x{$key} || 0 ) / $max_p ) + 1;
}
if ( ( $bredde_x == 1 ) && $_url_x{$key} ) { $bredde_x = 2; }
if ( $max_k > 0 ) {
$bredde_k =
int( $BarWidth *
( ( $_url_k{$key} || 0 ) / ( $_url_p{$key} || 1 ) ) /
$max_k ) + 1;
}
if ( ( $bredde_k == 1 ) && $_url_k{$key} ) { $bredde_k = 2; }
if ( $ShowPagesStats =~ /P/i && $LogType ne 'F' ) {
print "$_url_p{$key} | ";
}
if ( $ShowPagesStats =~ /[PH]/i && $LogType eq 'F' ) {
print "$_url_p{$key} | ";
}
if ( $ShowPagesStats =~ /B/i ) {
print ""
. (
$_url_k{$key}
? Format_Bytes(
$_url_k{$key} / ( $_url_p{$key} || 1 )
)
: " "
)
. " | ";
}
if ( $ShowPagesStats =~ /E/i ) {
print ""
. ( $_url_e{$key} ? $_url_e{$key} : " " ) . " | ";
}
if ( $ShowPagesStats =~ /X/i ) {
print ""
. ( $_url_x{$key} ? $_url_x{$key} : " " ) . " | ";
}
# Call to plugins' function ShowPagesAddField
foreach my $pluginname (
keys %{ $PluginsLoaded{'ShowPagesAddField'} } )
{
# my $function="ShowPagesAddField_$pluginname('$key')";
# eval("$function");
my $function = "ShowPagesAddField_$pluginname";
&$function($key);
}
print "";
if ( $ShowPagesStats =~ /P/i && $LogType ne 'F' ) {
print
" ";
}
if ( $ShowPagesStats =~ /[PH]/i && $LogType eq 'F' ) {
print
" ";
}
if ( $ShowPagesStats =~ /B/i ) {
print
" ";
}
if ( $ShowPagesStats =~ /E/i ) {
print
" ";
}
if ( $ShowPagesStats =~ /X/i ) {
print
" ";
}
print " |
\n";
$total_p += $_url_p{$key} || 0;
$total_e += $_url_e{$key} || 0;
$total_x += $_url_x{$key} || 0;
$total_k += $_url_k{$key} || 0;
$count++;
}
$rest_p = $TotalPages - $total_p;
$rest_e = $TotalEntries - $total_e;
$rest_x = $TotalExits - $total_x;
$rest_k = $TotalBytesPages - $total_k;
if ( $rest_p > 0 || $rest_k > 0 || $rest_e > 0 || $rest_x > 0 )
{ # All other urls
print
"| $Message[2] | ";
if ( $ShowPagesStats =~ /P/i && $LogType ne 'F' ) {
print "$rest_p | ";
}
if ( $ShowPagesStats =~ /[PH]/i && $LogType eq 'F' ) {
print "$rest_p | ";
}
if ( $ShowPagesStats =~ /B/i ) {
print ""
. (
$rest_k
? Format_Bytes( $rest_k / ( $rest_p || 1 ) )
: " "
)
. " | ";
}
if ( $ShowPagesStats =~ /E/i ) {
print "" . ( $rest_e ? $rest_e : " " ) . " | ";
}
if ( $ShowPagesStats =~ /X/i ) {
print "" . ( $rest_x ? $rest_x : " " ) . " | ";
}
# Call to plugins' function ShowPagesAddField
foreach my $pluginname (
keys %{ $PluginsLoaded{'ShowPagesAddField'} } )
{
# my $function="ShowPagesAddField_$pluginname('')";
# eval("$function");
my $function = "ShowPagesAddField_$pluginname";
&$function('');
}
print " |
\n";
}
&tab_end();
}
# BY OS
#----------------------------
if ($ShowOSStats) {
if ($Debug) { debug( "ShowOSStats", 2 ); }
print "$Center
\n";
my $Totalh = 0;
my %new_os_h = ();
OSLOOP: foreach my $key ( keys %_os_h ) {
$Totalh += $_os_h{$key};
foreach my $family ( keys %OSFamily ) {
if ( $key =~ /^$family/i ) {
$new_os_h{"${family}cumul"} += $_os_h{$key};
next OSLOOP;
}
}
$new_os_h{$key} += $_os_h{$key};
}
my $title =
"$Message[59] ($Message[77] $MaxNbOf{'OsShown'}) - $Message[80]/$Message[58] - $Message[0]";
&tab_head( "$title", 19, 0, 'os' );
print
"| | $Message[59] | $Message[57] | $Message[15] |
\n";
$total_h = 0;
my $count = 0;
&BuildKeyList( $MaxNbOf{'OsShown'}, $MinHit{'Os'}, \%new_os_h,
\%new_os_h );
foreach my $key (@keylist) {
my $p = ' ';
if ($Totalh) {
$p = int( $new_os_h{$key} / $Totalh * 1000 ) / 10;
$p = "$p %";
}
if ( $key eq 'Unknown' ) {
print " | $Message[0] | $_os_h{$key} | $p |
\n";
}
else {
my $keywithoutcumul = $key;
$keywithoutcumul =~ s/cumul$//i;
my $libos = $OSHashLib{$keywithoutcumul}
|| $keywithoutcumul;
my $nameicon = $keywithoutcumul;
$nameicon =~ s/[^\w]//g;
if ( $OSFamily{$keywithoutcumul} ) {
$libos = "" . $OSFamily{$keywithoutcumul} . "";
}
print " | $libos | $new_os_h{$key} | $p |
\n";
}
$total_h += $new_os_h{$key};
$count++;
}
if ($Debug) {
debug( "Total real / shown : $Totalh / $total_h", 2 );
}
$rest_h = $Totalh - $total_h;
if ( $rest_h > 0 ) {
my $p;
if ($Totalh) { $p = int( $rest_h / $Totalh * 1000 ) / 10; }
print "";
print "| | ";
print
"$Message[2] | $rest_h | ";
print "$p % |
\n";
}
&tab_end();
}
# BY BROWSER
#----------------------------
if ($ShowBrowsersStats) {
if ($Debug) { debug( "ShowBrowsersStats", 2 ); }
print "$Center
\n";
my $Totalh = 0;
my %new_browser_h = ();
BROWSERLOOP: foreach my $key ( keys %_browser_h ) {
$Totalh += $_browser_h{$key};
foreach my $family ( keys %BrowsersFamily ) {
if ( $key =~ /^$family/i ) {
$new_browser_h{"${family}cumul"} += $_browser_h{$key};
next BROWSERLOOP;
}
}
$new_browser_h{$key} += $_browser_h{$key};
}
my $title =
"$Message[21] ($Message[77] $MaxNbOf{'BrowsersShown'}) - $Message[80]/$Message[58] - $Message[0]";
&tab_head( "$title", 19, 0, 'browsers' );
print
"| | $Message[21] | $Message[111] | $Message[57] | $Message[15] |
\n";
$total_h = 0;
my $count = 0;
&BuildKeyList(
$MaxNbOf{'BrowsersShown'}, $MinHit{'Browser'},
\%new_browser_h, \%new_browser_h
);
foreach my $key (@keylist) {
my $p = ' ';
if ($Totalh) {
$p = int( $new_browser_h{$key} / $Totalh * 1000 ) / 10;
$p = "$p %";
}
if ( $key eq 'Unknown' ) {
print " | $Message[0] | ? | $_browser_h{$key} | $p |
\n";
}
else {
my $keywithoutcumul = $key;
$keywithoutcumul =~ s/cumul$//i;
my $libbrowser = $BrowsersHashIDLib{$keywithoutcumul}
|| $keywithoutcumul;
my $nameicon = $BrowsersHashIcon{$keywithoutcumul}
|| "notavailable";
if ( $BrowsersFamily{$keywithoutcumul} ) {
$libbrowser = "$libbrowser";
}
print " | "
. ( $PageDir eq 'rtl' ? "" : "" )
. "$libbrowser"
. ( $PageDir eq 'rtl' ? "" : "" )
. " | "
. (
$BrowsersHereAreGrabbers{$key}
? "$Message[112]"
: "$Message[113]"
)
. " | $new_browser_h{$key} | $p |
\n";
}
$total_h += $new_browser_h{$key};
$count++;
}
if ($Debug) {
debug( "Total real / shown : $Totalh / $total_h", 2 );
}
$rest_h = $Totalh - $total_h;
if ( $rest_h > 0 ) {
my $p;
if ($Totalh) { $p = int( $rest_h / $Totalh * 1000 ) / 10; }
print "";
print "| | ";
print
"$Message[2] | | $rest_h | ";
print "$p % |
\n";
}
&tab_end();
}
# BY SCREEN SIZE
#----------------------------
if ($ShowScreenSizeStats) {
if ($Debug) { debug( "ShowScreenSizeStats", 2 ); }
print "$Center
\n";
my $Totalh = 0;
foreach ( keys %_screensize_h ) { $Totalh += $_screensize_h{$_}; }
my $title =
"$Message[135] ($Message[77] $MaxNbOf{'ScreenSizesShown'})";
&tab_head( "$title", 0, 0, 'screensizes' );
print
"| $Message[135] | $Message[15] |
\n";
my $total_h = 0;
my $count = 0;
&BuildKeyList( $MaxNbOf{'ScreenSizesShown'},
$MinHit{'ScreenSize'}, \%_screensize_h, \%_screensize_h );
foreach my $key (@keylist) {
my $p = ' ';
if ($Totalh) {
$p = int( $_screensize_h{$key} / $Totalh * 1000 ) / 10;
$p = "$p %";
}
$total_h += $_screensize_h{$key} || 0;
print "";
if ( $key eq 'Unknown' ) {
print
"| $Message[0] | ";
print "$p | ";
}
else {
my $screensize = $key;
print "$screensize | ";
print "$p | ";
}
print "
\n";
$count++;
}
$rest_h = $Totalh - $total_h;
if ( $rest_h > 0 ) { # All others sessions
my $p = 0;
if ($Totalh) { $p = int( $rest_h / $Totalh * 1000 ) / 10; }
print
"| $Message[2] | ";
print "" . ( $rest_h ? "$p %" : " " ) . " | ";
print "
\n";
}
&tab_end();
}
print "\n \n\n";
# BY REFERENCE
#---------------------------
if ($ShowOriginStats) {
if ($Debug) { debug( "ShowOriginStats", 2 ); }
print "$Center
\n";
my $Totalp = 0;
foreach ( 0 .. 5 ) {
$Totalp +=
( $_ != 4 || $IncludeInternalLinksInOriginSection )
? $_from_p[$_]
: 0;
}
my $Totalh = 0;
foreach ( 0 .. 5 ) {
$Totalh +=
( $_ != 4 || $IncludeInternalLinksInOriginSection )
? $_from_h[$_]
: 0;
}
&tab_head( $Message[36], 19, 0, 'referer' );
my @p_p = ( 0, 0, 0, 0, 0, 0 );
if ( $Totalp > 0 ) {
$p_p[0] = int( $_from_p[0] / $Totalp * 1000 ) / 10;
$p_p[1] = int( $_from_p[1] / $Totalp * 1000 ) / 10;
$p_p[2] = int( $_from_p[2] / $Totalp * 1000 ) / 10;
$p_p[3] = int( $_from_p[3] / $Totalp * 1000 ) / 10;
$p_p[4] = int( $_from_p[4] / $Totalp * 1000 ) / 10;
$p_p[5] = int( $_from_p[5] / $Totalp * 1000 ) / 10;
}
my @p_h = ( 0, 0, 0, 0, 0, 0 );
if ( $Totalh > 0 ) {
$p_h[0] = int( $_from_h[0] / $Totalh * 1000 ) / 10;
$p_h[1] = int( $_from_h[1] / $Totalh * 1000 ) / 10;
$p_h[2] = int( $_from_h[2] / $Totalh * 1000 ) / 10;
$p_h[3] = int( $_from_h[3] / $Totalh * 1000 ) / 10;
$p_h[4] = int( $_from_h[4] / $Totalh * 1000 ) / 10;
$p_h[5] = int( $_from_h[5] / $Totalh * 1000 ) / 10;
}
print
"| $Message[37] | ";
if ( $ShowOriginStats =~ /P/i ) {
print
"$Message[56] | $Message[15] | ";
}
if ( $ShowOriginStats =~ /H/i ) {
print
"$Message[57] | $Message[15] | ";
}
print "
\n";
#------- Referrals by direct address/bookmark/link in email/etc...
print "| $Message[38] | ";
if ( $ShowOriginStats =~ /P/i ) {
print ""
. ( $_from_p[0] ? $_from_p[0] : " " )
. " | "
. ( $_from_p[0] ? "$p_p[0] %" : " " ) . " | ";
}
if ( $ShowOriginStats =~ /H/i ) {
print ""
. ( $_from_h[0] ? $_from_h[0] : " " )
. " | "
. ( $_from_h[0] ? "$p_h[0] %" : " " ) . " | ";
}
print "
\n";
#------- Referrals by search engines
print "$Message[40] - $Message[80] \n";
if ( scalar keys %_se_referrals_h ) {
print "\n";
$total_p = 0;
$total_h = 0;
my $count = 0;
&BuildKeyList(
$MaxNbOf{'RefererShown'},
$MinHit{'Refer'},
\%_se_referrals_h,
(
( scalar keys %_se_referrals_p )
? \%_se_referrals_p
: \%_se_referrals_h
)
);
foreach my $key (@keylist) {
my $newreferer = $SearchEnginesHashLib{$key}
|| CleanXSS($key);
print "| - $newreferer | ";
print ""
. (
$_se_referrals_p{$key} ? $_se_referrals_p{$key} : '0' )
. " | ";
print "$_se_referrals_h{$key} | ";
print " \n";
$total_p += $_se_referrals_p{$key};
$total_h += $_se_referrals_h{$key};
$count++;
}
if ($Debug) {
debug(
"Total real / shown : $TotalSearchEnginesPages / $total_p - $TotalSearchEnginesHits / $total_h",
2
);
}
$rest_p = $TotalSearchEnginesPages - $total_p;
$rest_h = $TotalSearchEnginesHits - $total_h;
if ( $rest_p > 0 || $rest_h > 0 ) {
print
"| - $Message[2] | ";
print "$rest_p | ";
print "$rest_h | ";
print " \n";
}
print " ";
}
print " | \n";
if ( $ShowOriginStats =~ /P/i ) {
print ""
. ( $_from_p[2] ? $_from_p[2] : " " )
. " | "
. ( $_from_p[2] ? "$p_p[2] %" : " " ) . " | ";
}
if ( $ShowOriginStats =~ /H/i ) {
print ""
. ( $_from_h[2] ? $_from_h[2] : " " )
. " | "
. ( $_from_h[2] ? "$p_h[2] %" : " " ) . " | ";
}
print "
\n";
#------- Referrals by external HTML link
print "$Message[41] - $Message[80] \n";
if ( scalar keys %_pagesrefs_h ) {
print "\n";
$total_p = 0;
$total_h = 0;
my $count = 0;
&BuildKeyList(
$MaxNbOf{'RefererShown'},
$MinHit{'Refer'},
\%_pagesrefs_h,
(
( scalar keys %_pagesrefs_p )
? \%_pagesrefs_p
: \%_pagesrefs_h
)
);
foreach my $key (@keylist) {
print "| - ";
&ShowURLInfo($key);
print " | ";
print ""
. ( $_pagesrefs_p{$key} ? $_pagesrefs_p{$key} : '0' )
. " | ";
print "$_pagesrefs_h{$key} | ";
print " \n";
$total_p += $_pagesrefs_p{$key};
$total_h += $_pagesrefs_h{$key};
$count++;
}
if ($Debug) {
debug(
"Total real / shown : $TotalRefererPages / $total_p - $TotalRefererHits / $total_h",
2
);
}
$rest_p = $TotalRefererPages - $total_p;
$rest_h = $TotalRefererHits - $total_h;
if ( $rest_p > 0 || $rest_h > 0 ) {
print
"| - $Message[2] | ";
print "$rest_p | ";
print "$rest_h | ";
print " \n";
}
print " ";
}
print " | \n";
if ( $ShowOriginStats =~ /P/i ) {
print ""
. ( $_from_p[3] ? $_from_p[3] : " " )
. " | "
. ( $_from_p[3] ? "$p_p[3] %" : " " ) . " | ";
}
if ( $ShowOriginStats =~ /H/i ) {
print ""
. ( $_from_h[3] ? $_from_h[3] : " " )
. " | "
. ( $_from_h[3] ? "$p_h[3] %" : " " ) . " | ";
}
print "
\n";
#------- Referrals by internal HTML link
if ($IncludeInternalLinksInOriginSection) {
print "| $Message[42] | ";
if ( $ShowOriginStats =~ /P/i ) {
print ""
. ( $_from_p[4] ? $_from_p[4] : " " )
. " | "
. ( $_from_p[4] ? "$p_p[4] %" : " " ) . " | ";
}
if ( $ShowOriginStats =~ /H/i ) {
print ""
. ( $_from_h[4] ? $_from_h[4] : " " )
. " | "
. ( $_from_h[4] ? "$p_h[4] %" : " " ) . " | ";
}
print "
\n";
}
#------- Referrals by news group
#print "| $Message[107] | ";
#if ($ShowOriginStats =~ /P/i) { print "".($_from_p[5]?$_from_p[5]:" ")." | ".($_from_p[5]?"$p_p[5] %":" ")." | "; }
#if ($ShowOriginStats =~ /H/i) { print "".($_from_h[5]?$_from_h[5]:" ")." | ".($_from_h[5]?"$p_h[5] %":" ")." | "; }
#print "
\n";
#------- Unknown origin
print "| $Message[39] | ";
if ( $ShowOriginStats =~ /P/i ) {
print ""
. ( $_from_p[1] ? $_from_p[1] : " " )
. " | "
. ( $_from_p[1] ? "$p_p[1] %" : " " ) . " | ";
}
if ( $ShowOriginStats =~ /H/i ) {
print ""
. ( $_from_h[1] ? $_from_h[1] : " " )
. " | "
. ( $_from_h[1] ? "$p_h[1] %" : " " ) . " | ";
}
print "
\n";
&tab_end();
# 0: Direct
# 1: Unknown
# 2: SE
# 3: External link
# 4: Internal link
# 5: Newsgroup (deprecated)
}
print "\n \n\n";
# BY SEARCH KEYWORDS AND/OR KEYPHRASES
#-------------------------------------
if ($ShowKeyphrasesStats) {
print "$Center ";
}
if ($ShowKeywordsStats) {
print "$Center ";
}
if ( $ShowKeyphrasesStats || $ShowKeywordsStats ) { print "
\n"; }
if ( $ShowKeyphrasesStats && $ShowKeywordsStats ) {
print
"";
}
if ($ShowKeyphrasesStats) {
# By Keyphrases
if ( $ShowKeyphrasesStats && $ShowKeywordsStats ) {
print "\n";
}
if ($Debug) { debug( "ShowKeyphrasesStats", 2 ); }
&tab_head(
"$Message[120] ($Message[77] $MaxNbOf{'KeyphrasesShown'}) $Message[80]",
19,
( $ShowKeyphrasesStats && $ShowKeywordsStats ) ? 95 : 70,
'keyphrases'
);
print " |
| $TotalDifferentKeyphrases $Message[103] | $Message[14] | $Message[15] |
\n";
$total_s = 0;
my $count = 0;
&BuildKeyList( $MaxNbOf{'KeyphrasesShown'},
$MinHit{'Keyphrase'}, \%_keyphrases, \%_keyphrases );
foreach my $key (@keylist) {
my $mot;
# Convert coded keywords (utf8,...) to be correctly reported in HTML page.
if ( $PluginsLoaded{'DecodeKey'}{'decodeutfkeys'} ) {
$mot = CleanXSS(
DecodeKey_decodeutfkeys(
$key, $PageCode || 'iso-8859-1'
)
);
}
else { $mot = CleanXSS( DecodeEncodedString($key) ); }
my $p;
if ($TotalKeyphrases) {
$p =
int( $_keyphrases{$key} / $TotalKeyphrases * 1000 ) / 10;
}
print "| "
. XMLEncode($mot)
. " | $_keyphrases{$key} | $p % |
\n";
$total_s += $_keyphrases{$key};
$count++;
}
if ($Debug) {
debug( "Total real / shown : $TotalKeyphrases / $total_s", 2 );
}
$rest_s = $TotalKeyphrases - $total_s;
if ( $rest_s > 0 ) {
my $p;
if ($TotalKeyphrases) {
$p = int( $rest_s / $TotalKeyphrases * 1000 ) / 10;
}
print
"| $Message[124] | $rest_s | ";
print "$p % |
\n";
}
&tab_end();
if ( $ShowKeyphrasesStats && $ShowKeywordsStats ) {
print "\n";
}
}
if ( $ShowKeyphrasesStats && $ShowKeywordsStats ) {
print " | ";
}
if ($ShowKeywordsStats) {
# By Keywords
if ( $ShowKeyphrasesStats && $ShowKeywordsStats ) {
print "\n";
}
if ($Debug) { debug( "ShowKeywordsStats", 2 ); }
&tab_head(
"$Message[121] ($Message[77] $MaxNbOf{'KeywordsShown'}) $Message[80]",
19,
( $ShowKeyphrasesStats && $ShowKeywordsStats ) ? 95 : 70,
'keywords'
);
print " | | $TotalDifferentKeywords $Message[13] | $Message[14] | $Message[15] |
\n";
$total_s = 0;
my $count = 0;
&BuildKeyList( $MaxNbOf{'KeywordsShown'},
$MinHit{'Keyword'}, \%_keywords, \%_keywords );
foreach my $key (@keylist) {
my $mot;
# Convert coded keywords (utf8,...) to be correctly reported in HTML page.
if ( $PluginsLoaded{'DecodeKey'}{'decodeutfkeys'} ) {
$mot = CleanXSS(
DecodeKey_decodeutfkeys(
$key, $PageCode || 'iso-8859-1'
)
);
}
else { $mot = CleanXSS( DecodeEncodedString($key) ); }
my $p;
if ($TotalKeywords) {
$p = int( $_keywords{$key} / $TotalKeywords * 1000 ) / 10;
}
print "| "
. XMLEncode($mot)
. " | $_keywords{$key} | $p % |
\n";
$total_s += $_keywords{$key};
$count++;
}
if ($Debug) {
debug( "Total real / shown : $TotalKeywords / $total_s", 2 );
}
$rest_s = $TotalKeywords - $total_s;
if ( $rest_s > 0 ) {
my $p;
if ($TotalKeywords) {
$p = int( $rest_s / $TotalKeywords * 1000 ) / 10;
}
print
"| $Message[30] | $rest_s | ";
print "$p % |
\n";
}
&tab_end();
if ( $ShowKeyphrasesStats && $ShowKeywordsStats ) {
print "\n";
}
}
if ( $ShowKeyphrasesStats && $ShowKeywordsStats ) {
print "
\n";
}
print "\n \n\n";
# BY MISC
#----------------------------
if ($ShowMiscStats) {
if ($Debug) { debug( "ShowMiscStats", 2 ); }
print "$Center
\n";
my $title = "$Message[139]";
&tab_head( "$title", 19, 0, 'misc' );
print
"| $Message[139] | ";
print " | ";
print " | ";
print "
\n";
my %label = (
'AddToFavourites' => $Message[137],
'JavascriptDisabled' => $Message[168],
'JavaEnabled' => $Message[140],
'DirectorSupport' => $Message[141],
'FlashSupport' => $Message[142],
'RealPlayerSupport' => $Message[143],
'QuickTimeSupport' => $Message[144],
'WindowsMediaPlayerSupport' => $Message[145],
'PDFSupport' => $Message[146]
);
foreach my $key (@MiscListOrder) {
my $mischar = substr( $key, 0, 1 );
if ( $ShowMiscStats !~ /$mischar/i ) { next; }
my $total = 0;
my $p;
if ( $MiscListCalc{$key} eq 'v' ) { $total = $TotalVisits; }
if ( $MiscListCalc{$key} eq 'u' ) { $total = $TotalUnique; }
if ( $MiscListCalc{$key} eq 'hm' ) {
$total = $_misc_h{'TotalMisc'} || 0;
}
if ($total) {
$p =
int( ( $_misc_h{$key} ? $_misc_h{$key} : 0 ) / $total *
1000 ) / 10;
}
print "";
print "| "
. ( $PageDir eq 'rtl' ? "" : "" )
. $label{$key}
. ( $PageDir eq 'rtl' ? "" : "" ) . " | ";
if ( $MiscListCalc{$key} eq 'v' ) {
print ""
. ( $_misc_h{$key} || 0 )
. " / $total $Message[12] | ";
}
if ( $MiscListCalc{$key} eq 'u' ) {
print ""
. ( $_misc_h{$key} || 0 )
. " / $total $Message[18] | ";
}
if ( $MiscListCalc{$key} eq 'hm' ) { print "- | "; }
print "" . ( $total ? "$p %" : " " ) . " | ";
print "
\n";
}
&tab_end();
}
# BY HTTP STATUS
#----------------------------
if ($ShowHTTPErrorsStats) {
if ($Debug) { debug( "ShowHTTPErrorsStats", 2 ); }
print "$Center
\n";
my $title = "$Message[32]";
&tab_head( "$title", 19, 0, 'errors' );
print
"| $Message[32]* | $Message[57] | $Message[15] | $Message[75] |
\n";
$total_h = 0;
my $count = 0;
&BuildKeyList( $MaxRowsInHTMLOutput, 1, \%_errors_h, \%_errors_h );
foreach my $key (@keylist) {
my $p = int( $_errors_h{$key} / $TotalHitsErrors * 1000 ) / 10;
print "";
if ( $TrapInfosForHTTPErrorCodes{$key} ) {
print "| $key | ";
}
else { print "$key | "; }
print ""
. (
$httpcodelib{$key} ? $httpcodelib{$key} : 'Unknown error' )
. " | $_errors_h{$key} | $p % | "
. Format_Bytes( $_errors_k{$key} ) . " | ";
print "
\n";
$total_h += $_errors_h{$key};
$count++;
}
&tab_end("* $Message[154]");
}
# BY SMTP STATUS
#----------------------------
if ($ShowSMTPErrorsStats) {
if ($Debug) { debug( "ShowSMTPErrorsStats", 2 ); }
print "$Center
\n";
my $title = "$Message[147]";
&tab_head( "$title", 19, 0, 'errors' );
print
"| $Message[147] | $Message[57] | $Message[15] | $Message[75] |
\n";
$total_h = 0;
my $count = 0;
&BuildKeyList( $MaxRowsInHTMLOutput, 1, \%_errors_h, \%_errors_h );
foreach my $key (@keylist) {
my $p = int( $_errors_h{$key} / $TotalHitsErrors * 1000 ) / 10;
print "";
print "| $key | ";
print ""
. (
$smtpcodelib{$key} ? $smtpcodelib{$key} : 'Unknown error' )
. " | $_errors_h{$key} | $p % | "
. Format_Bytes( $_errors_k{$key} ) . " | ";
print "
\n";
$total_h += $_errors_h{$key};
$count++;
}
&tab_end();
}
# BY CLUSTER
#----------------------------
if ($ShowClusterStats) {
if ($Debug) { debug( "ShowClusterStats", 2 ); }
print "$Center
\n";
my $title = "$Message[155]";
&tab_head( "$title", 19, 0, 'clusters' );
print
"| $Message[155] | ";
&ShowClusterInfo('__title__');
if ( $ShowClusterStats =~ /P/i ) {
print
"$Message[56] | $Message[15] | ";
}
if ( $ShowClusterStats =~ /H/i ) {
print
"$Message[57] | $Message[15] | ";
}
if ( $ShowClusterStats =~ /B/i ) {
print
"$Message[75] | $Message[15] | ";
}
print "
\n";
$total_p = $total_h = $total_k = 0;
# Cluster feature might have been enable in middle of month so we recalculate
# total for cluster section only, to calculate ratio, instead of using global total
foreach my $key ( keys %_cluster_h ) {
$total_p += int( $_cluster_p{$key} || 0 );
$total_h += int( $_cluster_h{$key} || 0 );
$total_k += int( $_cluster_k{$key} || 0 );
}
my $count = 0;
foreach my $key ( keys %_cluster_h ) {
my $p_p = int( $_cluster_p{$key} / $total_p * 1000 ) / 10;
my $p_h = int( $_cluster_h{$key} / $total_h * 1000 ) / 10;
my $p_k = int( $_cluster_k{$key} / $total_k * 1000 ) / 10;
print "";
print "| Computer $key | ";
&ShowClusterInfo($key);
if ( $ShowClusterStats =~ /P/i ) {
print ""
. ( $_cluster_p{$key} ? $_cluster_p{$key} : " " )
. " | $p_p % | ";
}
if ( $ShowClusterStats =~ /H/i ) {
print "$_cluster_h{$key} | $p_h % | ";
}
if ( $ShowClusterStats =~ /B/i ) {
print ""
. Format_Bytes( $_cluster_k{$key} )
. " | $p_k % | ";
}
print "
\n";
$count++;
}
&tab_end();
}
# BY EXTRA SECTIONS
#----------------------------
foreach my $extranum ( 1 .. @ExtraName - 1 ) {
if ($Debug) { debug( "ExtraName$extranum", 2 ); }
print "$Center
";
my $title = $ExtraName[$extranum];
&tab_head("$title ($Message[77] $MaxNbOfExtra[$extranum])",19,0,"extra$extranum");
print "";
print "| " . $ExtraFirstColumnTitle[$extranum];
print " - $Message[80]";
print " | ";
if ( $ExtraStatTypes[$extranum] =~ m/P/i ) {
print
"$Message[56] | ";
}
if ( $ExtraStatTypes[$extranum] =~ m/H/i ) {
print
"$Message[57] | ";
}
if ( $ExtraStatTypes[$extranum] =~ m/B/i ) {
print
"$Message[75] | ";
}
if ( $ExtraStatTypes[$extranum] =~ m/L/i ) {
print "$Message[9] | ";
}
print "
\n";
$total_p = $total_h = $total_k = 0;
#$max_h=1; foreach (values %_login_h) { if ($_ > $max_h) { $max_h = $_; } }
#$max_k=1; foreach (values %_login_k) { if ($_ > $max_k) { $max_k = $_; } }
my $count = 0;
if ( $MaxNbOfExtra[$extranum] ) {
if ( $ExtraStatTypes[$extranum] =~ m/P/i ) {
&BuildKeyList(
$MaxNbOfExtra[$extranum],
$MinHitExtra[$extranum],
\%{ '_section_' . $extranum . '_h' },
\%{ '_section_' . $extranum . '_p' }
);
}
else {
&BuildKeyList(
$MaxNbOfExtra[$extranum],
$MinHitExtra[$extranum],
\%{ '_section_' . $extranum . '_h' },
\%{ '_section_' . $extranum . '_h' }
);
}
}
else {
@keylist = ();
}
my %keysinkeylist = ();
foreach my $key (@keylist) {
$keysinkeylist{$key} = 1;
my $firstcol = CleanXSS( DecodeEncodedString($key) );
$total_p += ${ '_section_' . $extranum . '_p' }{$key};
$total_h += ${ '_section_' . $extranum . '_h' }{$key};
$total_k += ${ '_section_' . $extranum . '_k' }{$key};
print "";
printf(
"| $ExtraFirstColumnFormat[$extranum] | ",
$firstcol, $firstcol, $firstcol, $firstcol, $firstcol );
if ( $ExtraStatTypes[$extranum] =~ m/P/i ) {
print ""
. ${ '_section_' . $extranum . '_p' }{$key} . " | ";
}
if ( $ExtraStatTypes[$extranum] =~ m/H/i ) {
print ""
. ${ '_section_' . $extranum . '_h' }{$key} . " | ";
}
if ( $ExtraStatTypes[$extranum] =~ m/B/i ) {
print ""
. Format_Bytes(
${ '_section_' . $extranum . '_k' }{$key} )
. " | ";
}
if ( $ExtraStatTypes[$extranum] =~ m/L/i ) {
print ""
. (
${ '_section_' . $extranum . '_l' }{$key}
? Format_Date(
${ '_section_' . $extranum . '_l' }{$key}, 1 )
: '-'
)
. " | ";
}
print "
\n";
$count++;
}
# If we ask average or sum, we loop on all other records
if ( $ExtraAddAverageRow[$extranum] || $ExtraAddSumRow[$extranum] )
{
foreach ( keys %{ '_section_' . $extranum . '_h' } ) {
if ( $keysinkeylist{$_} ) { next; }
$total_p += ${ '_section_' . $extranum . '_p' }{$_};
$total_h += ${ '_section_' . $extranum . '_h' }{$_};
$total_k += ${ '_section_' . $extranum . '_k' }{$_};
$count++;
}
}
# Add average row
if ( $ExtraAddAverageRow[$extranum] ) {
print "";
print "| $Message[96] | ";
if ( $ExtraStatTypes[$extranum] =~ m/P/i ) {
print ""
. ( $count ? ( $total_p / $count ) : " " ) . " | ";
}
if ( $ExtraStatTypes[$extranum] =~ m/H/i ) {
print ""
. ( $count ? ( $total_h / $count ) : " " ) . " | ";
}
if ( $ExtraStatTypes[$extranum] =~ m/B/i ) {
print ""
. (
$count ? Format_Bytes( $total_k / $count ) : " " )
. " | ";
}
if ( $ExtraStatTypes[$extranum] =~ m/L/i ) {
print " | ";
}
print "
\n";
}
# Add sum row
if ( $ExtraAddSumRow[$extranum] ) {
print "";
print "| $Message[102] | ";
if ( $ExtraStatTypes[$extranum] =~ m/P/i ) {
print "" . ($total_p) . " | ";
}
if ( $ExtraStatTypes[$extranum] =~ m/H/i ) {
print "" . ($total_h) . " | ";
}
if ( $ExtraStatTypes[$extranum] =~ m/B/i ) {
print "" . Format_Bytes($total_k) . " | ";
}
if ( $ExtraStatTypes[$extranum] =~ m/L/i ) {
print " | ";
}
print "
\n";
}
&tab_end();
}
&html_end(1);
}
}
else {
print "Jumped lines in file: $lastlinenb\n";
if ($lastlinenb) { print " Found $lastlinenb already parsed records.\n"; }
print "Parsed lines in file: $NbOfLinesParsed\n";
print " Found $NbOfLinesDropped dropped records,\n";
print " Found $NbOfLinesCorrupted corrupted records,\n";
print " Found $NbOfOldLines old records,\n";
print " Found $NbOfNewLines new qualified records.\n";
}
#sleep 10;
0; # Do not remove this line
#-------------------------------------------------------
# ALGORITHM SUMMARY
#
# Read_Config();
# Check_Config() and Init variables
# if 'frame not index'
# &Read_Language_Data($Lang);
# if 'frame not mainleft'
# &Read_Ref_Data();
# &Read_Plugins();
# html_head
#
# If 'migrate'
# We create/update tmp file with
# &Read_History_With_TmpUpdate(year,month,day,hour,UPDATE,NOPURGE,"all");
# Rename the tmp file
# html_end
# Exit
# End of 'migrate'
#
# Get last history file name
# Get value for $LastLine $LastLineNumber $LastLineOffset $LastLineChecksum with
# &Read_History_With_TmpUpdate(lastyearbeforeupdate,lastmonthbeforeupdate,lastdaybeforeupdate,lasthourbeforeupdate,NOUPDATE,NOPURGE,"general");
#
# &Init_HashArray()
#
# If 'update'
# Loop on each new line in log file
# lastlineoffset=lastlineoffsetnext; lastlineoffsetnext=file pointer position
# If line corrupted, skip --> next on loop
# Drop wrong virtual host --> next on loop
# Drop wrong method/protocol --> next on loop
# Check date --> next on loop
# If line older than $LastLine, skip --> next on loop
# So it's new line
# $LastLine = time or record
# Skip if url is /robots.txt --> next on loop
# Skip line for @SkipHosts --> next on loop
# Skip line for @SkipFiles --> next on loop
# Skip line for @SkipUserAgent --> next on loop
# Skip line for not @OnlyHosts --> next on loop
# Skip line for not @OnlyUsers --> next on loop
# Skip line for not @OnlyFiles --> next on loop
# Skip line for not @OnlyUserAgent --> next on loop
# So it's new line approved
# If other month/year, create/update tmp file and purge data arrays with
# &Read_History_With_TmpUpdate(lastprocessedyear,lastprocessedmonth,lastprocessedday,lastprocessedhour,UPDATE,PURGE,"all",lastlinenb,lastlineoffset,CheckSum($_));
# Define a clean Url and Query (set urlwithnoquery, tokenquery and standalonequery and $field[$pos_url])
# Define PageBool and extension
# Analyze: Misc tracker --> complete %misc
# Analyze: Hit on favorite icon --> complete %_misc, countedtraffic=1 (not counted anywhere)
# If (!countedtraffic) Analyze: Worms --> complete %_worms, countedtraffic=2
# If (!countedtraffic) Analyze: Status code --> complete %_error_, %_sider404, %_referrer404 --> countedtraffic=3
# If (!countedtraffic) Analyze: Robots known --> complete %_robot, countedtraffic=4
# If (!countedtraffic) Analyze: Robots unknown on robots.txt --> complete %_robot, countedtraffic=5
# If (!countedtraffic) Analyze: File types - Compression
# If (!countedtraffic) Analyze: Date - Hour - Pages - Hits - Kilo
# If (!countedtraffic) Analyze: Login
# If (!countedtraffic) Do DNS Lookup
# If (!countedtraffic) Analyze: Country
# If (!countedtraffic) Analyze: Host - Url - Session
# If (!countedtraffic) Analyze: Browser - OS
# If (!countedtraffic) Analyze: Referer
# If (!countedtraffic) Analyze: EMail
# Analyze: Cluster
# Analyze: Extra (must be after 'Define a clean Url and Query')
# If too many records, we flush data arrays with
# &Read_History_With_TmpUpdate(lastprocessedyear,lastprocessedmonth,lastprocessedday,lastprocessedhour,UPDATE,PURGE,"all",lastlinenb,lastlineoffset,CheckSum($_));
# End of loop
#
# Create/update tmp file
# Seek to lastlineoffset in logfile to read and get last line into $_
# &Read_History_With_TmpUpdate(lastprocessedyear,lastprocessedmonth,lastprocessedday,lastprocessedhour,UPDATE,PURGE,"all",lastlinenb,lastlineoffset,CheckSum($_))
# Rename all created tmp files
# End of 'update'
#
# &Init_HashArray()
#
# If 'output'
# Loop for each month of required year
# &Read_History_With_TmpUpdate($YearRequired,$monthloop,'','',NOUPDATE,NOPURGE,'all' or 'general time' if not required month)
# End of loop
# Show data arrays in HTML page
# html_end
# End of 'output'
#-------------------------------------------------------
#-------------------------------------------------------
# DNS CACHE FILE FORMATS SUPPORTED BY AWSTATS
# Format /etc/hosts x.y.z.w hostname
# Format analog UT/60 x.y.z.w hostname
#-------------------------------------------------------
#-------------------------------------------------------
# IP Format (d=decimal on 16 bits, x=hexadecimal on 16 bits)
#
# 13.1.68.3 IPv4 (d.d.d.d)
# 0:0:0:0:0:0:13.1.68.3 IPv6 (x:x:x:x:x:x:d.d.d.d)
# ::13.1.68.3
# 0:0:0:0:0:FFFF:13.1.68.3 IPv6 (x:x:x:x:x:x:d.d.d.d)
# ::FFFF:13.1.68.3 IPv6
#
# 1070:0:0:0:0:800:200C:417B IPv6
# 1070:0:0:0:0:800:200C:417B IPv6
# 1070::800:200C:417B IPv6
#-------------------------------------------------------
php5 0000666 00040525320 15077145761 0005377 0 ustar 00 ELF > B @ @ 8 @ @ @ @ @ @ 8 8@ 8@ @ @ 4w 4w w
܁ T T@ T@ D D Ptd r Qtd Rtd w @G
@G
/lib64/ld-linux-x86-64.so.2 GNU GNU *'}0Ԋ[ C
6 X ^ Y * S 7 ` L / G ? * o W
m G W y # * % h K d l w O $
Y , 1
( ) E & + R *
b y m U '
z q " } - k l f 5 X s t N Q 4
-
( 4 c
~ G Q k x T v )
g t H q ) 1 B 8 g ( I K 8 G > [ " a 7 0 d C 7
#
h f ! B V 2 @ ] ? = = % w e V _ ' D | S 1 f { u "
S ; . L &