# -*- perl -*- ################################################################
#
# AccessWatch HTML Table Generation Functions
# Copyright 1994-1998 David G. Maher. All Rights Reserved.
#
###############################################################################
#-----------------------------------------------------------------------------#
# AccessWatch function - PrintBarHoriz
# Purpose : Prints a horizontal bar with width as specified by argument.
#-----------------------------------------------------------------------------#
sub PrintBarHoriz {
my($pct) = $_[0];
my($colorbar) = $horizbar{$_[1]};
my($scale) = 1;
$scale = ($pct*8)/log $pct + 1 if ($pct > 0);
print "
", $scale);
}
#-----------------------------------------------------------------------------#
# AccessWatch function - PrintBarVert
# Purpose : Prints a vertical bar with height as specified by argument.
#-----------------------------------------------------------------------------#
sub PrintBarVert {
my($pct, $max) = ($_[0], $_[1]);
my($colorbar) = $vertbar{$_[2]};
my($width) = $_[3];
$width = 10 if !($width);
my($scale) = 0;
$scale = $pct / $max * 200 if $max;
print "
", $scale);
}
sub byReverseNumber { $b <=> $a; }
#-----------------------------------------------------------------------------#
# AccessWatch function - PrintTableRefStats
# Purpose : Prints appropriate table.
#-----------------------------------------------------------------------------#
sub PrintTableRefStats {
if (! %refs) {
print "
No reference information is available. Please see the FAQ for more information.
\n";
return;
}
my($ref, $page, $refsTotal, $count);
my(@refOrder) = ();
foreach (keys %refs) {
my($refUrl) = $siteBaseURL;
$refURL =~ s/^http:\/\///i;
$refURL =~ s/^https:\/\///i;
$refURL =~ s/^ftp:\/\///i;
if ($_ =~ /$siteBaseURL\//i || $_ =~ /www\.$sitebaseURL/i) {
delete $refs{$_};
}
else {
$refsTotal += $refs{$_};
}
}
my(@countOrderList) = sort { $b <=> $a } values %refs;
my($refCount) = $maxRefsToList - 1;
$refCount = $#countOrderList
if ($maxRefsToList == -1 ||
($maxRefsToList - 1) > $#countOrderList);
while (@countOrderList) {
while (local($tag, $value) = each %refs) {
if ($countOrderList[0] == $value) {
push (@refOrder, $tag);
shift @countOrderList;
}
}
}
my(@favRefs) = @refOrder[0..$refCount];
my(@othRefs) = @refOrder[@favRefs..$#refOrder];
print <
References
Referring Site / Page | % of total |
EOM
;
foreach (@favRefs) {
/(.*)~~~(.*)/;
($siteurl, $page) = ($1, $2);
($sitename = $siteurl) =~ s/^.*:\/\/([^\/]+)/$1/;
$sitename =~ s/([^\/]+)(.*)/$1$2<\/FONT>/;
$pct = sprintf("%3.1f", $refs{$_}/$refsTotal*100) if $refsTotal;
$pct = "0.0" if ! $refsTotal;
if (! $sample) {
print <$sitename $page | $pct |
EOM
;
}
else {
print <$sitename $page | $pct |
EOM
;
}
}
# print "";
# foreach (@othRefs) {
# /(.*)~~~(.*)/;
# ($siteurl, $page) = ($1, $2);
# ($sitename = $siteurl) =~ s/^.*:\/\/([^\/]+)/$1/;
# $sitename =~ s/([^\/]+)(.*)/$1$2<\/FONT>/;
# print "$sitename ";
# }
# print " |
\n";
print "
\n";
}
#-----------------------------------------------------------------------------#
# AccessWatch function - PrintTableAgentStats
# Purpose : Prints appropriate table.
#-----------------------------------------------------------------------------#
sub PrintTableAgentStats {
my($agent, $agentsTotal, $hour, $browser, $count, %classes, %platforms);
if (! %agents) {
print "No browser information is available. Please see the FAQ for more information.
\n";
return;
}
%classes = ('Netscape Navigator', 0,
'Microsoft Internet Explorer', 0,
'Other', 0
);
%platforms = ('Windows 95', 0,
'Windows 98', 0,
'Windows NT', 0,
'Windows 3.1 or lower', 0,
'Macintosh', 0,
'UNIX', 0,
'OS/2', 0,
'Other', 0
);
%netscapeversions;
%ieversions;
my(@countOrderList) = sort { $b <=> $a } values %agents;
while (($agent, $count) = each %agents) {
if ($agent =~ /MSIE (\S+)/) {
$classes{'Microsoft Internet Explorer'} += $count;
my($version);
if ($1 =~ /(.*)\./) {
$ieversions{"$1\.\*"} += $count;
}
}
elsif ($agent =~ /Mozilla\/(\S+)/ && $agent !~ /compatible/) {
$classes{'Netscape Navigator'} += $count;
my($version);
if ($1 =~ /(.*)\./) {
$netscapeversions{"$1\.\*"} += $count;
}
}
else {
$classes{'Other'} += $count;
}
if ($agent =~ /Macintosh/i || $agent =~ /Mac_PowerPC/
|| $agent =~ /Mac_PPC/) {
$platforms{'Macintosh'} += $count;
}
elsif ($agent =~ /Windows 95/i || $agent =~ /Win95/i) {
$platforms{'Windows 95'} += $count;
}
elsif ($agent =~ /Windows 98/i || $agent =~ /Win98/i) {
$platforms{'Windows 98'} += $count;
}
elsif ($agent =~ /Win16/i
|| $agent =~ /Windows [321]/) {
$platforms{'Windows 3.1 or lower'} += $count;
}
elsif ($agent =~ /Windows NT/i || $agent =~ /WinNT/i) {
$platforms{'Windows NT'} += $count;
}
elsif ($agent =~ /UNIX/i || $agent =~ /X11/ || $agent =~ /Lynx/) {
$platforms{'UNIX'} += $count;
}
elsif ($agent =~ /OS\/2/i || $agent =~ /OS2/) {
$platforms{'OS/2'} += $count;
}
else {
$platforms{'Other'} += $count;
}
$agentsTotal += $count;
}
my(@agentOrder) = ();
my($agentCount) = $maxAgentsToList - 1;
$agentCount = $#countOrderList
if ($maxAgentsToList == -1 ||
($maxAgentsToList - 1) > $#countOrderList);
while (@countOrderList) {
while (local($tag, $value) = each %agents) {
if ($countOrderList[0] == $value) {
push (@agentOrder, $tag);
shift @countOrderList;
}
}
}
my(@favAgents) = @agentOrder[0..$agentCount];
my(@othAgents) = @agentOrder[@favAgents..$#agentOrder];
print <
Browsers
Browser Class | % of total |
EOM
sub byclass {
$classes{$b} <=> $classes{$a};
}
my($class);
foreach $class (sort byclass keys %classes) {
$count = $classes{$class};
my($pct) =
sprintf("%3.1f", $count/$agentsTotal*100)
if $agentsTotal;
$pct = "0.0" if ! $agentsTotal;
print "$class | $pct | \n";
if ($class eq "Netscape Navigator") {
my(@pcts);
print "Versions ";
sub byns {
$netscapeversions{$b} <=> $netscapeversions{$a};
}
my($version);
foreach $version (sort byns keys %netscapeversions) {
$count = $netscapeversions{$version};
my($pct) =
sprintf("%3.1f", $count/$agentsTotal*100)
if $agentsTotal;
$pct = "0.0" if ! $agentsTotal;
if ($pct > 0) {
print "$version \n";
push (@pcts, $pct);
}
}
print " | ";
foreach (@pcts) {
print "$_ \n";
}
print " | \n";
}
elsif ($class eq "Microsoft Internet Explorer") {
my(@pcts);
print "Versions ";
sub byie {
$ieversions{$b} <=> $ieversions{$a};
}
my($version);
foreach $version (sort byie keys %ieversions) {
$count = $ieversions{$version};
my($pct) =
sprintf("%3.1f", $count/$agentsTotal*100)
if $agentsTotal;
$pct = "0.0" if ! $agentsTotal;
if ($pct > 0) {
print "$version \n";
push (@pcts, $pct);
}
}
print " | ";
foreach (@pcts) {
print "$_ \n";
}
print " | \n";
}
}
print <
Platforms | % of total |
EOM
sub byplatform {
$platforms{$b} <=> $platforms{$a};
}
my($platform);
foreach $platform (sort byplatform keys %platforms) {
$count = $platforms{$platform};
my($pct) =
sprintf("%3.1f", $count/$agentsTotal*100)
if $agentsTotal;
$pct = "0.0" if ! $agentsTotal;
print "$platform | $pct | \n";
}
print <
Top $maxAgentsToList Browsers | % of total |
EOM
foreach (@favAgents) {
# print "$_ - $agents{$_} - $agentsTotal\n";
$pct = sprintf("%3.1f", $agents{$_}/$agentsTotal*100) if $agentsTotal;
$pct = "0.0" if ! $agentsTotal;
print <$_ | $pct |
EOM
}
print " \n\n";
}
#-----------------------------------------------------------------------------#
# AccessWatch function - PrintTableDomainStats
# Purpose : Prints table of domains, sorted by number of accesses.
#-----------------------------------------------------------------------------#
sub PrintTableDomainStats {
print <
Accesses by Domain
Domain | Description |
Visits | % of total |
EOM
my(@countOrderList) = sort byReverseNumber values %domains;
my(@domainOrder) = ();
my($domainCount) = $maxDomainsToList - 1;
$domainCount = $#countOrderList
if ($maxDomainsToList == -1 ||
($maxDomainsToList - 1) > $#countOrderList);
while (@countOrderList) {
while (local($tag, $value) = (each %domains)) {
if ($countOrderList[0] == $value) {
push (@domainOrder, $tag);
shift @countOrderList;
}
}
}
my(@favDomains) = @domainOrder[0..$domainCount];
my(@othDomains) = @domainOrder[@favDomains..$#domainOrder];
foreach (@favDomains) {
my($Mdomain) = $_;
my($Mcount) = $domains{$_};
$Mdomain =~ tr/[A-Z]/[a-z]/;
print "$Mdomain | ";
my($description) = &DescribeDomain($Mdomain);
print "$description | ";
print "$Mcount | ";
$pct = 0.00;
$pct = $Mcount / $stats{'visits'} * 100 if ($stats{'visits'} > 0);
printf ("%3.1f | \n", $pct);
print "";
&PrintBarHoriz($pct,0);
print " | \n";
}
print "Additionally, there were visits from the following domains: " if (@othDomains);
my($andCount) = 0;
foreach (@othDomains) {
tr/[A-Z]/[a-z]/;
my($description) = &DescribeDomain($_);
if ($andCount != $#othDomains) {
print "$description [$domains{$_}], ";
}
else {
print "and $description [$domains{$_}].";
}
$andCount++;
}
print " | \n \n";
}
#-----------------------------------------------------------------------------#
# AccessWatch function - PrintTableHostStats
# Purpose : Prints table of hosts, sorted by number of accesses.
#-----------------------------------------------------------------------------#
sub PrintTableHostStats {
print <
Hosts - Common Visitors
Host Address | Hits | % of total |
EOM
my(@countOrderList) = sort byReverseNumber values %hosts;
my(@hostOrder) = ();
my($hostCount) = $maxHostsToList - 1;
$hostCount = $#countOrderList
if ($maxHostsToList == -1 ||
($maxHostsToList - 1) > $#countOrderList);
while (@countOrderList) {
while (local($tag, $value) = (each %hosts)) {
if ($countOrderList[0] == $value) {
push (@hostOrder, $tag);
shift @countOrderList;
}
}
}
my(@favHosts) = @hostOrder[0..$hostCount];
foreach (@favHosts) {
my($Mhost) = $_;
my($Mcount) = $hosts{$_};
print "$Mhost | ";
print "$Mcount | ";
$pct = 0.00;
$pct = $Mcount / $stats{'hits'} * 100 if ($stats{'hits'} > 0);
printf (" %3.2f | \n", $pct);
print "";
&PrintBarHoriz($pct,0);
print " | \n";
}
print <Access Details: A list of individual accesses, sorted by host |
EOM
print " \n";
}
#-----------------------------------------------------------------------------#
# AccessWatch function - PrintTableRegionStats
# Purpose : Prints table of regions, sorted by number of accesses.
#-----------------------------------------------------------------------------#
sub PrintTableRegionStats {
@americas = ('Antigua and Barbuda', 'Argentina', 'Aruba', 'Brazil', 'Canada',
'Chile', 'Dominican Republic', 'Guam', 'Guatemala', 'Mexico',
'Paraguay', 'Peru', 'Philippines', 'Saint Lucia',
'Trinidad and Tobago', 'United States');
@asia = ('Bahrain', 'China', 'Hong Kong', 'Indonesia', 'Japan', 'Kazakhstan',
'Korea (South)', 'Malaysia', 'New Zealand (Aotearoa)', 'Singapore',
'Sri Lanka', 'Taiwan', 'Thailand', 'United Arab Emirates');
@europe = ('Andorra', 'Anguilla', 'Australia', 'Austria', 'Belgium',
'Croatia (Hrvatska)', 'Cyprus', 'Denmark', 'Estonia', 'Finland',
'France', 'Germany', 'Greece', 'Hungary', 'Iceland', 'Ireland',
'Italy', 'Latvia', 'Lithuania', 'Luxembourg', 'Malta', 'Netherlands',
'Norway', 'Poland', 'Portugal', 'Romania', 'Slovenia', 'Spain',
'Sweden', 'Switzerland', 'Turkey', 'Ukraine', 'United Kingdom',
'Yugoslavia');
@rimea = ('Czech Republic', 'Egypt', 'India', 'Israel', 'Jordan', 'Kuwait',
'Lebanon', 'Russian Federation', 'Slovak Republic', 'South Africa',
'USSR (former)');
@other = ('Old-style Arpanet', 'Non-profit organization', 'International',
'IP Address', 'Network');
my($country, $total, $grandtotal);
my(%revdomains) = reverse %domains;
print < Hits by Region
EOM
print "\n";
print "Americas | \n";
print "Country | Hits | \n";
$total = 0;
foreach $country (@americas) {
$count = ($domains{(&DescribeDomain($country))} || 0);
if ($country eq "United States") {
$count += $domains{'edu'} + $domains{'com'}
+ $domains{'gov'} + $domains{'mil'};
}
print "$country | $count | \n" if $count;
$total += $count;
}
print "Total | $total | \n";
print " \n";
print " \n";
print "Asia / Pac | \n";
print "Country | Hits | \n";
$grandtotal += $total;
$total = 0;
foreach $country (@asia) {
$count = ($domains{(&DescribeDomain($country))} || 0);
print "$country | $count | \n" if $count;
$total += $count;
}
print "Total | $total | \n";
print " \n";
print " \n";
print "Europe | \n";
print "Country | Hits | \n";
$grandtotal += $total;
$total = 0;
foreach $country (@europe) {
$count = ($domains{(&DescribeDomain($country))} || 0);
print "$country | $count | \n" if $count;
$total += $count;
}
print "Total | $total | \n";
print " \n";
print " \n";
print "RIMEA | \n";
print "Country | Hits | \n";
$grandtotal += $total;
$total = 0;
foreach $country (@rimea) {
$count = ($domains{(&DescribeDomain($country))} || 0);
print "$country | $count | \n" if $count;
$total += $count;
}
print "Total | $total | \n";
print " \n";
print " \n";
print "Other | \n";
print "Country | Hits | \n";
$grandtotal += $total;
$total = 0;
foreach $country (@other) {
$count = ($domains{(&DescribeDomain($country))} || 0);
print "$country | $count | \n" if $count;
$total += $count;
}
print "Total | $total | \n";
print " \n";
$grandtotal += $total;
print " \n";
print "Grand total | $grandtotal | \n";
print " \n";
print "\n";
}
#-----------------------------------------------------------------------------#
# AccessWatch function - PrintTablePageStats
# Purpose : Prints table of pages, sorted by number of accesses.
#-----------------------------------------------------------------------------#
sub PrintTablePageStats {
# outputs a table of pages accessed, ranked in order of demand
print <
Page Demand
Of the $stats{'visits'} visitors in this time period, each traversed an average of $stats{'pages-visit'} pages and downloaded an average of $stats{'kbytes-visit'} kilobytes.
Page Location | Accesses | \% of total |
EOM
my(@countOrderList) = sort byReverseNumber values %pages;
my(@pageOrder) = ();
my($pageCount) = $maxPagesToList - 1;
$pageCount = $#countOrderList if ($maxPagesToList == -1 ||
($maxPagesToList - 1) > $#countOrderList);
while (@countOrderList) {
while (local($tag, $value) = (each %pages)) {
if ($countOrderList[0] == $value) {
push (@pageOrder, $tag);
shift @countOrderList;
}
}
}
my(@favPages) = @pageOrder[0..$pageCount];
foreach (@favPages) {
my($Mpage) = $_;
my($Mcount) = $pages{$_};
my($pct) = 0.00;
$pct = $Mcount / $stats{'pages'} * 100 if ($stats{'pages'} > 0);
if ($sample) {
print "";
}
else {
print " | ";
}
my($description) = &DescribePage($Mpage);
print "$description | ";
print "$Mcount | \n";
printf (" %3.2f | \n", $pct);
print "";
&PrintBarHoriz($pct,0);
print " | \n";
}
print " \n";
}
#-----------------------------------------------------------------------------#
# AccessWatch function - PrintTableHourlyStats
# Purpose : Prints bar graph of accesses over the course of the current
# day. Thanks very much to Paul Blackman for his work on
# this function.
#-----------------------------------------------------------------------------#
sub PrintTableHourlyStats {
my($hour, $pct);
print <
Hourly Statistics
EOM
my($barwidth) = 10;
foreach $hour ('00'..'23') {
print "";
if ($stats{'hours'}{$hour} > 0.9*$stats{'maxhouraccess'}){
&PrintBarVert($stats{'hours'}{$hour},
$stats{'maxhouraccess'}, 9, $barwidth);
}
elsif ($stats{'hours'}{$hour} > 0.8*$stats{'maxhouraccess'}){
&PrintBarVert($stats{'hours'}{$hour},
$stats{'maxhouraccess'}, 8, $barwidth);
}
elsif ($stats{'hours'}{$hour} > 0.7*$stats{'maxhouraccess'}){
&PrintBarVert($stats{'hours'}{$hour},
$stats{'maxhouraccess'}, 7, $barwidth);
}
elsif ($stats{'hours'}{$hour} > 0.6*$stats{'maxhouraccess'}){
&PrintBarVert($stats{'hours'}{$hour},
$stats{'maxhouraccess'}, 6, $barwidth);
}
elsif ($stats{'hours'}{$hour} > 0.5*$stats{'maxhouraccess'}){
&PrintBarVert($stats{'hours'}{$hour},
$stats{'maxhouraccess'}, 5, $barwidth);
}
elsif ($stats{'hours'}{$hour} > 0.4*$stats{'maxhouraccess'}){
&PrintBarVert($stats{'hours'}{$hour},
$stats{'maxhouraccess'}, 4, $barwidth);
}
elsif ($stats{'hours'}{$hour} > 0.3*$stats{'maxhouraccess'}){
&PrintBarVert($stats{'hours'}{$hour},
$stats{'maxhouraccess'}, 3, $barwidth);
}
elsif ($stats{'hours'}{$hour} > 0.2*$stats{'maxhouraccess'}){
&PrintBarVert($stats{'hours'}{$hour},
$stats{'maxhouraccess'}, 2, $barwidth);
}
elsif ($stats{'hours'}{$hour} > 0.1*$stats{'maxhouraccess'}){
&PrintBarVert($stats{'hours'}{$hour},
$stats{'maxhouraccess'}, 1, $barwidth);
}
elsif ($stats{'hours'}{$hour} > 0) {
&PrintBarVert($stats{'hours'}{$hour},
$stats{'maxhouraccess'}, 0, $barwidth);
}
else {
&PrintBarVert(0, $stats{'maxhouraccess'}, -1, $barwidth);
}
print " | ";
}
print " ";
foreach ('12', '1' .. '12', '1' .. '11') {
print "$_ | ";
}
print <
AM |
PM |
|
Avg Hits/Hour | $stats{'avghouraccess'} |
Max Hits/Hour | $stats{'maxhouraccess'} |
Min Hits/Hour | $stats{'minhouraccess'} |
Avg Hits/Day | $stats{'avgdayaccess'} |
EOM
foreach $pct (0..9) {
$img = 9 - $pct;
print " > ";
printf ("%d%% | ", (9 - $pct)*10);
printf ("%d hits | \n", (1 - $pct/10) * $stats{'maxhouraccess'});
}
print " | \n";
print "";
print "Hour\tHits\n";
foreach $hour ('00'..'23') {
printf("$hour\t%.02f\n", $stats{'hours'}{$hour});
}
print " \n";
}
#-----------------------------------------------------------------------------#
# AccessWatch function - PrintTableMonthWeekStats
# Purpose : Prints bar graph of weekly accesses over the course of the
# month.
#-----------------------------------------------------------------------------#
sub PrintTableMonthWeekStats {
my($week, $pct);
print <
Weeks - Average accesses per week
Accesses $monthweekStats{($computedStats{'maxweekaccess'})} . . . |
EOM
my($barwidth) = 55;
foreach $week (1 .. 5) {
print "";
&PrintBarVert($monthweekStats{$week},
$monthweekStats{($computedStats{'maxweekaccess'})},
9,
$barwidth);
print " | \n";
}
print " \n\n";
print "0 Week: | \n";
foreach $week (1 .. 5) {
my($weekcount) = $monthweekStats{$week};
$weekcount = 0 if $weekcount < 0;
if ($week eq $computedStats{'maxweekaccess'}) {
print "$weekcount $week | \n";
}
else {
print "$weekcount $week | \n";
}
}
print <
|
Average Accesses/Week: | $computedStats{'accessesPerWeek'} |
Maximum Accesses/Week: | $monthweekStats{($computedStats{'maxweekaccess'})} | during week $computedStats{'maxweekaccess'}. |
Minimum Accesses/Week: | $monthweekStats{($computedStats{'minweekaccess'})} | during week $computedStats{'minweekaccess'}. |
|
EOM
}
#-----------------------------------------------------------------------------#
# AccessWatch function - PrintTableMonthDayStats
# Purpose : Prints bar graph of daily accesses over the course of the
# month.
#-----------------------------------------------------------------------------#
sub PrintTableMonthDayStats {
my($day, $pct);
print <
Months - Average hits per month
Hits $monthdayStats{($computedStats{'maxdayaccess'})} . . . |
EOM
my($barwidth) = 8;
my($max) = $monthdayStats{($computedStats{'maxdayaccess'})};
foreach $day ('01' .. '31') {
print "";
if ($monthdayStats{$day} > 0.9 * $max) {
&PrintBarVert($monthdayStats{$day}, $max, 9, $barwidth);
}
elsif ($monthdayStats{$day} > 0.8 * $max) {
&PrintBarVert($monthdayStats{$day}, $max, 8, $barwidth);
}
elsif ($monthdayStats{$day} > 0.7 * $max) {
&PrintBarVert($monthdayStats{$day}, $max, 7, $barwidth);
}
elsif ($monthdayStats{$day} > 0.6 * $max) {
&PrintBarVert($monthdayStats{$day}, $max, 6, $barwidth);
}
elsif ($monthdayStats{$day} > 0.5 * $max) {
&PrintBarVert($monthdayStats{$day}, $max, 5, $barwidth);
}
elsif ($monthdayStats{$day} > 0.4 * $max) {
&PrintBarVert($monthdayStats{$day}, $max, 4, $barwidth);
}
elsif ($monthdayStats{$day} > 0.3 * $max) {
&PrintBarVert($monthdayStats{$day}, $max, 3, $barwidth);
}
elsif ($monthdayStats{$day} > 0.2 * $max) {
&PrintBarVert($monthdayStats{$day}, $max, 2, $barwidth);
}
elsif ($monthdayStats{$day} > 0.1 * $max) {
&PrintBarVert($monthdayStats{$day}, $max, 1, $barwidth);
}
elsif ($monthdayStats{$day} > 0) {
&PrintBarVert($monthdayStats{$day}, $max, 0, $barwidth);
}
else {
&PrintBarVert(0, $max, -1, $barwidth);
}
print " | \n";
}
print " \n\n";
print "0 Day: | \n";
foreach $day ('01' .. '31') {
my($dayval) = $monthdayStats{$day};
$dayval = 0 if ($dayval < 0);
$day = int($day);
if ($day == $computerStats{'maxdayaccess'}) {
print "$day | \n";
}
else {
print "$day | \n";
}
}
print <
|
Average Hits/Day: | $computedStats{'accessesPerDay'} |
Maximum Hits/Day: | $monthdayStats{($computedStats{'maxdayaccess'})} | on day $computedStats{'maxdayaccess'}. |
Minimum Hits/Day: | $monthdayStats{($computedStats{'mindayaccess'})} | on day $computedStats{'mindayaccess'}. |
|
EOM
print "\n \n\n";
print " Day | Hits | \n";
foreach $day ('01' .. '31') {
my($dayval) = $monthdayStats{$day};
$dayval = 0 if ($dayval < 0);
$day = int($day);
print "$day | $dayval | \n";
}
print " \n\n";
}
#-----------------------------------------------------------------------------#
# AccessWatch function - PrintTableDayStats
# Purpose : Prints bar graph of accesses by day.
#-----------------------------------------------------------------------------#
sub PrintTableDayStats {
my($day, $pct);
print <
Daily Statistics
Hits $stats{'maxdayaccess'} . . . |
EOM
my($barwidth) = 8;
my($max) = $stats{'maxdayaccess'};
foreach $day (sort keys %{ $stats{'days'} }) {
print "";
if ($stats{'days'}{$day} > 0.9 * $max) {
&PrintBarVert($stats{'days'}{$day}, $max, 9, $barwidth);
}
elsif ($stats{'days'}{$day} > 0.8 * $max) {
&PrintBarVert($stats{'days'}{$day}, $max, 8, $barwidth);
}
elsif ($stats{'days'}{$day} > 0.7 * $max) {
&PrintBarVert($stats{'days'}{$day}, $max, 7, $barwidth);
}
elsif ($stats{'days'}{$day} > 0.6 * $max) {
&PrintBarVert($stats{'days'}{$day}, $max, 6, $barwidth);
}
elsif ($stats{'days'}{$day} > 0.5 * $max) {
&PrintBarVert($stats{'days'}{$day}, $max, 5, $barwidth);
}
elsif ($stats{'days'}{$day} > 0.4 * $max) {
&PrintBarVert($stats{'days'}{$day}, $max, 4, $barwidth);
}
elsif ($stats{'days'}{$day} > 0.3 * $max) {
&PrintBarVert($stats{'days'}{$day}, $max, 3, $barwidth);
}
elsif ($stats{'days'}{$day} > 0.2 * $max) {
&PrintBarVert($stats{'days'}{$day}, $max, 2, $barwidth);
}
elsif ($stats{'days'}{$day} > 0.1 * $max) {
&PrintBarVert($stats{'days'}{$day}, $max, 1, $barwidth);
}
elsif ($stats{'days'}{$day} > 0) {
&PrintBarVert($stats{'days'}{$day}, $max, 0, $barwidth);
}
else {
&PrintBarVert(0, $max, -1, $barwidth);
}
print " | \n";
}
print " \n\n";
print "0 Day: | \n";
foreach $day (sort keys %{ $stats{'days'} }) {
my($dayval) = $stats{'days'}{$day};
$dayval = 0 if ($dayval < 0);
$day =~ /(\d\d\d\d)(\d\d)(\d\d)/;
$day = int($2) . '/' . int($3) if $2 && $3;
if ($day == $computedStats{'maxdayaccess'}) {
print "$day | \n";
}
else {
print "$day | \n";
}
}
print <
|
Average Hits/Day: | $stats{'avgdayaccess'} |
Maximum Hits/Day: | $stats{'maxdayaccess'} | on day $stats{'maxday'}. |
Minimum Hits/Day: | $stats{'mindayaccess'} | on day $stats{'minday'}. |
|
EOM
print "\n \n\n";
print " Day | Accesses | \n";
foreach $day (sort keys %{ $stats{'days'} }) {
my($dayval) = $stats{'days'}{$day};
$dayval = 0 if ($dayval < 0);
$day = int($day);
print "$day | $dayval | \n";
}
print " \n\n";
}
#-----------------------------------------------------------------------------#
# AccessWatch function - PrintTableSummaryStats
# Purpose : Prints a table which contains general statistics.
#-----------------------------------------------------------------------------#
sub PrintTableSummaryStats {
my($extra);
if ($stats{'pages-visit'} < 1) {
$extra = 'Note: A pages per visit average that is below 1 indicates a large number of non-HTML hits linked outside the site.';
}
print <
Summary
During this period, there were $stats{'pages'} accesses and $stats{'hits'} hits. Each vistor viewed an average of $stats{'pages-visit'} pages and downloaded $stats{'kbytes-visit'} kilobytes. Hosts visited $siteName an average of $stats{'visits-uniq'} times, for a total of $stats{'visits'} unique visits by $stats{'uniquehosts'} unique hosts.
There were $stats{'visits-hour'} visits per hour, and a sustained rate of $stats{'hits-hour'} hits per hour.
Of these visits, $stats{'intvisits'} ($stats{'intvisitspct'}\%) originated from $orgname, and
$stats{'extvisits'} ($stats{'extvisitspct'}\%) were from outside networks.
$siteName served $stats{'mbytes'} megabytes of information during this time period.
$extra
| Count | % of total | |
Accesses from $orgname |
$stats{'intaccesses'} |
$stats{'intaccessespct'}\% |
EOM
print "";
&PrintBarHoriz($stats{'intaccessespct'}/2,0);
print " | ";
print <
Outside Accesses |
$stats{'extaccesses'} |
$stats{'extaccessespct'}\% |
EOM
print "";
&PrintBarHoriz($stats{'extaccessespct'}/2,0);
print " | ";
print <
Total Accesses |
$stats{'pages'} | 100% |
EOM
print "";
&PrintBarHoriz(50,1);
print " | ";
print <
Total hits on site |
$stats{'hits'} |
|
---|
---|
---|
EOM
}
#-----------------------------------------------------------------------------#
# AccessWatch function - PrintTableDetailsStats
# Purpose : Prints verbose table of statistics details.
#-----------------------------------------------------------------------------#
sub PrintTableDetailsStats {
print < Hosts by Subdomain
Count\tHost
EOM
my($subdom, $count, %subdoms);
while (($subdom, $count) = each %hosts) {
$subdom =~ /([^\.]+)\.([^\.]+)$/i;
$subdoms{"$1\.$2"} += $count;
}
my(@hostsAR) = sort byDomain (keys %subdoms);
my($host);
foreach $host (@hostsAR) {
print "$subdoms{$host}\t$host \n";
}
print <
EOM
}
#-----------------------------------------------------------------------------#
# AccessWatch sort routine - byDomain
# Purpose : Sort subroutine for sorting an array by domain suffix.
#-----------------------------------------------------------------------------#
sub byDomain {
my($aHost) = "";
my($bHost) = "";
my(@aTemp, @bTemp) = ();
if ($a =~ /[^0-9].*\.[^0-9].*/) {
@aTemp = reverse split(/\./, $a);
foreach (@aTemp) { $aHost .= $_ };
}
else {
$aHost = "zzzzzzz".$a;
}
if ($b =~ /[^0-9].*\.[^0-9].*/) {
@bTemp = reverse split(/\./, $b);
foreach (@bTemp) { $bHost .= $_ };
}
else {
$bHost = "zzzzzzz".$b;
}
return ($aHost cmp $bHost);
}
#-----------------------------------------------------------------------------#
#-----------------------------------------------------------------------------#
# AccessWatch function - DescribePage
# Purpose : Takes a virtual URL as a parameter, and returns a detailed
# description as specified in the page descriptions file
# provided. Caches file into memory if used more than once.
#-----------------------------------------------------------------------------#
sub DescribePage {
my($url) = $_[0];
my($description) = $url;
if (!(keys %pageDesc)) {
open (DESC, "<$pagedescriptions") || return $url;
# die "Page Desc. Error: Couldn't open $pagedescriptions... $!";
while () {
/^(\S+)\s+\"(.*)\"$/;
$pageDesc{$1} = $2;
}
close(DESC);
}
if ($pageDesc{$url}) {
$description = $pageDesc{$url};
}
if ($truncate && length($url) > $toolong && $description eq $url) {
$description = reverse $url;
while (length($description) > $toolong) { chop $description; }
$description = "..." . reverse $description;
}
return $description;
}
1;
| |