Written by Brian Kolaci (bk@galaxy.net) Feb 15, 1996.Thanks to Thomas Boutell, (boutell@boutell.com) for his wonderful gd graphics library.
Thanks to the DigitMania page at: http://cervantes.comptons.com/digits/digits.htm.
The latest copy of this file may be found at: http://www.galaxy.net/webcounter.html. Questions may be sent to bk@galaxy.net. The latest version of this software may be found at: ftp://ftp.galaxy.net/pub/bk/webcounter.tar.gz.
This package contains the module code to link in with the web server, the executable to manipulate and display the counter as a GIF, and a perl script to display/manipulate the counter log files.
This code uses the gd1.2 library by Tom Boutell, boutell@boutell.com
The whole gd distribution is enclosed in the subdirectory gd1.2, please
see the README file there.
Contents:
The counter software counts web pages, not URL's. This means that whether a page was accessed via a direct URL, a redirected URL, or a directory index (index.html), the same counter is used. Because of this, the counter GIF program must have the same DirectoryIndex parameter compiled into it. When a directory is referenced, then it scans the possibilities of files within the directory to find the page counter.
Since the web server itself keeps track of the counts and not the CGI script, there can be no spoofing on the counter. The page itself must be delivered to the client by the web server to be counted. The GIF counter script (to deliver an image as the counter) uses the web server environment variable HTTP_REFERER to figure out which page counter is to be referenced. Some browsers (like AOL and Prodigy) do not set this field yet, therefore the command "url" to be passed to the count program may be set to specify the page URL to report. Note that calling the CGI program "count" does NOT increase the hit count on the page, only accessing the page itself will do that.
For those that use server side includes, the environment variables URL_COUNT and URL_COUNT_RESET are set to the counter value for the current page, and the last time it was reset. Another variable, URL_COUNT_DB, is set to the counter log database file, for use by CGI scripts.
There is a feature to automatically add pages to the counter log when it has never been referenced before. Also, pages may be individually reset on demand.
Two modes of counter logs are available, per server and per directory. This allows indexing files by file system and by server domain or virtual domain. This allows control of a counter file to be maintained for a virtual domain, and in addition, the webmaster for the whole server may have their own copy indexed on the whole filesystem. This means counter logs may be used server wide, within a virtual host, and also within a Directory directive.
Changes
The following changes have been made since release 1.0:
The only changes you should expect to make would be:
Count is a standalone executable that may be called directly as a CGI program, or called by other CGI programs. It reads values from environment variables to determine where to get the count from, then obtains style modifiers from CGI variables which are parsed from QUERY_STRING (we assume a GET method), then last overridden by any command-line options.
CGI variables may be sent as:
<img src="/cgi-bin/count?type=odb&length=10">
CGI String | Command-line Option | Default | Description |
---|---|---|---|
type | -t | default | Name of digit type to use |
length | -l | 5 | Length of digits to use, left side padded with 0's |
counter | -c | (from database) | Counter value to use |
url | -u | (CGI environment variable HTTP_REFERER) | URL page to count |
This script allows you to add a URL, delete a URL, reset count/date on
a URL, and view a URL or the contents of a file.
Building & Installation
There are essentially 3 items that need to be installed. First,
start with the web server.
Module cntr_module mod_cntr.o
The synopsis is as follows:
countctl [ -cdrv URL ] filenameIf no option is supplied, it essentially dumps the contents of the file. The output is in no particular order. The format of the output is:
-c create URL -d delete URL -r reset counter -v view counter (and reset date)
URL count reset_date