#!/usr/local/bin/perl $startdir = "/d1/www/bbrp/counter"; $datadir = "data"; $digitsdir = "digits"; open ( OUTFILE, ">/d1/www/bbrp/counter/instructions.html"); my $oldfh = select OUTFILE; print < LLNL Page Statistics Instructions EOhead &print_introduction(); &print_step1(); &print_all_counters(); &print_step2(); &print_unique_vars(); &print_laststep(); &print_summary(); print "<\/BODY><\/HTML>"; sub print_introduction() { print <LLNL Page Statistics Generator Instructions
by
Tim Harsch

    OK, you want usage information on some page on the site that the world gets to see.  Problem: the powers that be say you can't have any affiliation with a commercial site so those free page stats counters that are hosted by some other site are no good...  Well, I too ran into that and found a nice Page Stats program written by some guy named Dale McNeil and modified it for our purposes.  Take a gander at this:

You are visitor number , since March 11th 1999.
Click here to see the Stats Page.

    Now that you know what you are gonna get, let's figure out how you can get it... EOIntro } sub print_step1() { print <Step 1:
    Choose a set of counter images from this list that you like (note the counter name in parantheses):
- or -
    Go to DigitMania find a counter you want, email me and I will add it to the list. EOstep1 } sub print_step2() { print <Step 2:
    Choose a name to track your page with.   Typically this is the name of the .html file so that if your page name is instructions.html the name you would choose is "instructions".  However, if the name you would like conflicts with any in the list below (in green) choose another one or you will be sharing stats with someone else. EOstep2 } sub print_laststep() { print <Step 3:
    Login to BBRP and execute this command at the prompt:
    /d1/www/bbrp/bin/pagestats command=init filename=(The name you chose for your page)
eg
    /d1/www/bbrp/bin/pagestats command=init filename=instructions

If you can’t logon to BBRP email me and I will do it for you.

Step 4:
    Insert HTML like this into your page:
<img src="http://greengenes.llnl.gov/bbrp/bin/pagestats?command=display&digit=0&filename=(your page name here)&number=(your counter name here)">
eg
<img src="http://greengenes.llnl.gov/bbrp/bin/pagestats?command=count&digit=5&filename=instructions&number=marsil">
<img src="http://greengenes.llnl.gov/bbrp/bin/pagestats?command=display&digit=4&filename=instructions&number=marsil">
<img src="http://greengenes.llnl.gov/bbrp/bin/pagestats?command=display&digit=3&filename=instructions&number=marsil">
<img src="http://greengenes.llnl.gov/bbrp/bin/pagestats?command=display&digit=2&filename=instructions&number=marsil">
<img src="http://greengenes.llnl.gov/bbrp/bin/pagestats?command=display&digit=1&filename=instructions&number=marsil">
<img src="http://greengenes.llnl.gov/bbrp/bin/pagestats?command=display&digit=0&filename=instructions&number=marsil">

    Notice that the first line (digit=5) has command=count and the rest have command=display... that line increments the counter and the rest only display it.

Step 5:
    Check your Page Stats at
    http://greengenes.llnl.gov/bbrp/counter/(your page name).html
eg
    http://greengenes.llnl.gov/bbrp/counter/instructions_stats.html EOlaststep } sub print_summary() { print <Thanks and praise can be sent to Tim Harsch... please send all complaints to /dev/null  :-) EOsummary } close OUTFILE; select $oldfh; `chmod 644 /d1/www/bbrp/counter/instructions.html`; sub print_unique_vars() { my @listofvars = &get_unique_vars(); my $rowcount = -1; print "\n"; foreach $var ( @listofvars ) { $rowcount++; if( !($rowcount%5) ) { print "\n"; } print "\n"; if( ($rowcount%5)==4 ) { print "<\/TR>\n"; } } if( ($rowcount%5)!=4 ) { print "<\/TR>\n"; } print "<\/TABLE>"; } sub print_all_counters() { print "

$var
"; unless (opendir(DIR, "$startdir/$digitsdir")) { die "can't opendir $startdir/$digitsdir: $!"; } my @subdirs = grep { /^[^\.]/ && -d "$startdir/$digitsdir/$_" } readdir(DIR); closedir DIR; my @names = (); foreach $subdir ( @subdirs ) { push @names, ($file = `/bin/cat $startdir/$digitsdir/$subdir/name.txt`); $finddir{ $file } = $subdir; } @names = sort { lc($a) cmp lc($b) } @names; my $count = 0; foreach $subdir ( @subdirs ) { print "
", $count+1, "<\/TD>"; print "$names[$count] ( $finddir{ $names[$count] } )", "<\/FONT>
\n"; &print_counters( $finddir{ $names[$count] } ); print "<\/TD>"; print "<\/TR>"; $count++; } print "<\/TABLE>
\n"; } sub print_counters { my ($subdir) = @_; my $count; for $count ( 0 .. 9 ) { print "\n"; } print "
"; } sub get_unique_vars() { my $mylist; unless (opendir(VARSDIR, "$startdir/$datadir")) { die "can't opendir $startdir/$datadir: $!"; } @subdirs = grep { /\.txt$/ && -f "$startdir/$datadir/$_" } readdir(VARSDIR); foreach $subdir (@subdirs) { $subdir =~ /\.(txt)$/i; $` =~ /_.*$/i; $listofvars{ $` } = 1; } foreach $key ( keys %listofvars ) { push @mylist, $key; } closedir VARSDIR; return @mylist; }