#! /opt/bin/perl # ________________________________________________________________ # /\ /\ The Web Developer's Virtual Library # -{-<*>-}- World-Wide Web # __\/_\/_________________________________________________________ # Author : Lucy Richmond # Purpose : To create the Top 100 web page or our most frequently viewed pages. # Usage : top.pl < fn.log # where fn.log is the file created by log.pl # Comment : The variable $maxp sets the number of files included in the # output HTML file and also the file name. Output files are # placed in the $tloc directory and called # stars_xxx.html for the normal, publicly viewed file # hits_xxx.html for a private file which included the number of views # where xxx is the value of $maxp. # 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/DEV/Software/Perl/ht_subs.pl'; $maxp = 100; $butbg = "gold"; $tloc = "Top"; $v{'Title'} = "The Top $maxp"; $v{'Class'} = 'WDVL'; $totals = 0; open (OUT, ">$tloc/stars_$maxp.html")||die$!; open (CWSW, ">$tloc/hits_$maxp.html")||die$!; select OUT; $v{'url'} = "/WDVL/Stats/Top/$maxp.html"; &Head (1); print CWSW "Accesses per day:
    \n"; print OUT "
      \n"; print CWSW "
        \n"; while (<>) { # Stuff to ignore. next if /Resumes\.html/; next if /X-WWW/; 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) { @stat = split (/\t/); $_ = $stat[1]; $hits = $stat[0] ; next if $i++ >= $maxp; s/\/index.html/\//; split (/\//); $cat = $_[1]; $URL = $_; $file = "/opt/u/richmond/DEV$URL"; $file .= "index.html" if /\/$/; if (open (IN, "<$file")) { $_ = &GetTitle (1); } else { $URL =~ s/\/opt\/u\/richmond\/DEV//; $_ = $URL; } $_ = $URL if /\.wrl$/; s/^\s*//; close (IN); $link = "$_"; print OUT "
      1. $link\n"; print CWSW "
      2. $hits  $link\n"; print OUT "

        \n" if $i % 10 == 0; print CWSW "

        \n" if $i % 10 == 0; } print OUT "


      \n"; print CWSW "

    \n"; &Foot ;