#!/usr/local/bin/perl # 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. &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):

How the Numbers are Created

The "odometer" on the Beer Page is generated by a Perl program that counts the number of times it is invoked, keeping track, each time, of the IP address of the client. This page is generated by another program (also in Perl) that reads the data produced by the odometer program. Actually, the odometer is incremented only when your browser tries to retrieve the odometer image. If you're using a text-mode browser (e.g., Lynx), the counter is NOT incremented. If you really want to be counted, select this link.

The odometer counter was adapted from a similar program used at NASA Langley Research Center. You can also retrieve a copy of the odometer program or the the script that produces this page.

Note that in order to use these scripts for your own page, you must be able to install "CGI" scripts. The scripts are written in perl, so you need to have perl installed, too. The log files used by the scripts must be readable and writable by the user-id used by the HTTP daemon, and so must the directory in which they are stored.


Back to the Beer Page. EOMEOM } sub initialize { $port = $ENV{SERVER_PORT}; $serverRoot = "/www"; $forString = "the Beer Page"; $theString = "The Beer Page"; $counterFile = "$serverRoot/logs/counter.txt"; $hostsFile = "$serverRoot/logs/counthosts.txt"; $dbmFile = "$serverRoot/logs/hosts"; } 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,0666); $who = $ENV{REMOTE_ADDR}; $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, 19$year, $hour:%02d",$month_names[$mon],$min); }