)
{ @hits = split (/\|/,$line);
$page = $hits[0];
if ($page =~ /(.+)\+(.+)/) { $group =$1; }
foreach $day (1..$dyinMon[$month])
{ $Tbl{$page}{$day} += $hits[$day];
$PageTtl{$page} += $hits[$day];
if ($group)
{ $Tbl{$group}{$day} += $hits[$day];
$GroupTtl{$group} += $hits[$day];
}
$DayTtl{$day} += $hits[$day];
}
$total += $PageTtl{$page};
}
close (DAT);
@pages = sort {$PageTtl{$b} <=> $PageTtl{$a}} keys %PageTtl;
@groups = sort {$GroupTtl{$b} <=> $GroupTtl{$a}} keys %GroupTtl;
print qq|
Completed on $timeStamp\n\n|;
}
else # group or page
{
print "Hits By ";
if ($1 eq "G")
{ $group = $2;
print "GROUP for "$group"";
} else
{ $page = $2;
print "PAGE for "$page"";
}
print "
\n";
# Read all data into hashes
$total = 0;
foreach $month (1..12)
{ $MonthTtl{$month} =0;
$HITDAT = "$HITMON$month.dat";
open (DAT,"<$HITDAT") || &endMan ("Read: $HITDAT");
flock (DAT,1); seek (DAT,0,0);
while ($line = )
{ @hits = split (/\|/,$line);
if ($hits[0] eq $page || $hits[0] =~ /^$group\+/)
{ foreach $day (1..31)
{ $Tbl{$month}{$day} += $hits[$day];
$DayTtl{$day} += $hits[$day];
$MonthTtl{$month} += $Tbl{$month}{$day};
}
}
}
close (DAT);
$total += $MonthTtl{$month};
}
print "
Completed on $timeStamp\n\n";
}
}
else # default by year
{
print "Hits By YEAR as of $timeStamp
\n";
# Read all data into hashes
$total = 0;
foreach $month (1..12)
{ $MonthTtl{$month} =0;
$HITDAT = "$HITMON$month.dat";
open (DAT,"<$HITDAT") || &endMan ("Read: $HITDAT");
flock (DAT,1); seek (DAT,0,0);
while ($line = )
{ @hits = split (/\|/,$line);
$page = $hits[0];
if ($page =~ /(.+)\+(.+)/) { $group =$1; }
$Tbl{$month}{$page} =0;
foreach $day (1..31)
{ $Tbl{$month}{$page} += $hits[$day];
}
$PageTtl{$page} += $Tbl{$month}{$page};
$MonthTtl{$month} += $Tbl{$month}{$page};
if ($group)
{ $Tbl{$month}{$group} += $Tbl{$month}{$page};
$GroupTtl{$group} += $Tbl{$month}{$page};
}
}
close (DAT);
$total += $MonthTtl{$month};
}
# Sort by descending page total
@pages = sort {$PageTtl{$b} <=> $PageTtl{$a}} keys %PageTtl;
@groups = sort {$GroupTtl{$b} <=> $GroupTtl{$a}} keys %GroupTtl;
print "\n";
} # end default by year
print <<__HITFORM;
__HITFORM
&manFooter;
} # end case hittable
########################################################################
# Case: Flag to reset hitcount at next daily maintenance
elsif ($Form{'resetcount'})
{
open (LOCK,">$HITFLK") || &endMan ("Write: $HITFLK");
if (!flock (LOCK,2)) { &endMan ("Lock: $HITFLK"); }
# Write new cnt date to CFG
open (CFG,"+<$HITCFG") || &endMan ("Read\/Write: $HITCFG");
flock (CFG,2); seek (CFG,0,0);
$cfgFile = ;
($logDay,$datMonth,$cntMonth,$cntFlag,$eol) = split (/\|/,$cfgFile);
$cntMonth = $Form{'setmonth'} +0;
$cntFlag = 'Y';
$cfgFile = join ("\|",$logDay,$datMonth,$cntMonth,$cntFlag,$eol);
seek (CFG,0,0);
print (CFG $cfgFile);
truncate (CFG,tell(CFG)); close (CFG);
close (LOCK);
print "Hit Counter will be reset at next daily maintenance
\n to $labels[$cntMonth] 1, $year\n\n";
&hitCount;
&manFooter;
} # end resetcount
########################################################################
# Default Case: Display hitcount
else
{ &hitCount;
&manFooter;
} # end default
} # end hitman
########################################################################
sub hitCount # Display hitcount
{
open (CNT,"<$HITCNT") || &endMan ("Read: $HITCNT");
flock (CNT,1); seek (CNT,0,0);
@hitFile = ;
close (CNT);
print "\nHITS | by PAGECODE | \n";
$hitTtl =0;
for ($x=0; $x<=$#hitFile; $x++)
{ print "\n
\n";
($count,$code,$eol) = split (/\|/,$hitFile[$x]);
if ($code =~/\+/)
{ ($group,$page) = split (/\+/,$code);
$GroupTtl{$group} += $count;
}
print "$count | $code | ";
$hitTtl = $hitTtl + $count;
}
print "\n
\n";
if ($group)
{ print "
\nHITS | by GROUP | \n";
@groups = sort {$GroupTtl{$b} <=> $GroupTtl{$a}} keys %GroupTtl;
foreach $group (@groups)
{ print "\n
\n";
print "$GroupTtl{$group} | $group | ";
}
print "\n
\n";
}
open (CFG,"<$HITCFG") || &endMan ("Read: $HITCNT");
flock (CFG,1); seek (CFG,0,0);
$cfgFile = ;
close (CFG);
($logDay,$datMonth,$cntMonth,$cntFlag,$eol) = split (/\|/,$cfgFile);
print "Total: $hitTtl hits for $x pages since $labels[$cntMonth] 1, ";
if ($monthStamp >= $cntMonth) {$year = $yearStamp +0;} else {$year = $yearStamp -1;}
print "$year\n
Completed at $timeStamp\n\n";
print qq|
\n|;
} # end hitCount
sub manFooter # print hitman footer
{
print qq|