#!/tools/cs/perl5/bin/perl # Modified to handle multiple pages: Adam Griff (griff@cs.colorado.edu) # This is a companion program to the "counter.xbm" script. # When invoked, it responds with some HTML that it builds on # the fly that give usage statistics. # This script was written by Michael Morse (mmorse@nsf.gov) at # the National Science Foundation. Feel free to modify and use # it any way you wish. You will certainly have to modify # initialize(), since most of the NSF-specific stuff is there. # Also, createHTML() has some more NSF-specific stuff (like my # address!), that you'll want to change. # REQUIRED CHANGES # Modified by Griff to handle multiple pages. # Just call the counter followed by a ?unique_page_name. # Change the 3 directory paths that include "griff" to your directory name. &initialize; &getDate; &getNumbers; &createHTML; exit(0); sub createHTML { print<Usage Statistics for $forString

Usage Statistics for $forString


Numbers That May Interest You

As of now ($date)
The odometer counter was adapted and enhanced by Adam J. Griff from a similar program used at NASA Langley Research Center. EOMEOM } sub initialize { $port = $ENV{SERVER_PORT}; $pagename = $ENV{QUERY_STRING}; $serverRoot = "/html/lapack/"; $forString = $pagename; $theString = $pagename; $logFiles = "$serverRoot/logs/counter"; $dbmFile = "$serverRoot/logs/hosts"; $counterFile = "$logFiles.$pagename.txt"; $hostsFile = "$logFiles.$pagename.hosts.txt"; } sub getNumbers { open(COUNTERFILE,"<$counterFile") || die "$0: can\'t open $counterFile: $!\n"; $count = ; chop $count; close(COUNTERFILE); open(COUNTERFILE,"<$hostsFile") || die "$0: can\'t open $hostsFile: $!\n"; $hosts = ; chop $hosts; close(COUNTERFILE); dbmopen(HOSTS,"$dbmFile.$pagename",0666); $who_addr = $ENV{REMOTE_ADDR}; open(TEMP, "/usr/sbin/nslookup $who_addr 2>&1|"); while ((!defined $who) && ($temp = )) { if ($temp =~ /^Name:\s*(\S*)/) { $who = $1; } } close (TEMP); ($who = $host_addr) if (!defined $who); $you = $HOSTS{$who}; dbmclose(HOSTS); $count =~ s/^0+//; $hosts =~ s/^0+//; $you =~ s/^0+//; } sub getDate{ @month_names = ("January","February","March","April","May","June", "July","August","September","October","November","December"); ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time); $date = sprintf("%s $mday, %04d, $hour:%02d",$month_names[$mon],($year+1900),$min); }