#! /opt/bin/perl
# ________________________________________________________________
# /\ /\ The Web Developer's Virtual Library
# -{-<*>-}- World-Wide Web
# __\/_\/_________________________________________________________
# Author : Lucy Richmond
# Purpose : To create the list of top pages referring visitors
# to The WDVL
# Usage : rtop.pl < rcur.log
# Comment : Very much like top.pl, this program creates an HTML
# page of the pages with the most referrals to The WDVL.
# The number of pages listed (and the output file name)
# are set by $maxp and the output file is created in
# the $tloc directory as refs_xxx.html.
# Disclaimer: This software is provided freely on the understanding
# that the Author will not be held responsible for any
# problems arising from it's use, and that there is no support.
# ________________________________________________________________
require '/opt/u/richmond/WDVL/Software/Perl/ht_subs.pl';
$maxp = 100;
$tloc = "Top";
$v{'Title'} = "The Top $maxp Referals";
$v{'Class'} = 'Plain';
open (CWSW, ">$tloc/refs_$maxp.html")||die$!;
select OUT;
$v{'url'} = "/WDVL/Stats/Top/$maxp.html";
&Head (1);
print CWSW "Referrals this week:
\n";
print CWSW "\n";
while (<>) {
chop ;
$_ .= "\/" unless /\./;
split ;
$hits {$_[1]} += $_[0];
}
foreach (keys %hits) {
$hits[$i++] = join("\t",$hits{$_},$_);
}
local (@hitkeys);
foreach (@hits) { push (@hitkeys, (split(/\t/))[0]); }
sub byhitkeys { $hitkeys[$b] <=> $hitkeys[$a]; }
@hits = @hits[sort byhitkeys $[..$#hits];
$i = 0;
foreach (@hits) {
next if /\?/; # skip search engines
@stat = split (/\t/);
next if $i++ >= $maxp;
$link = "$stat[1]";
print CWSW "- $stat[0] $link\n";
print CWSW "
\n" if $i % 10 == 0;
}
print CWSW "
\n";
&Foot ;