Using the Delorie Counter

To use the Delorie Counter, you must create a control file. The control file is a file in your web directory (along with all your HTML files) with a suffix of ``.cnt'' (for ``counter''). Inside this file, you define the parameters for the counter. A file can define more than one counter (each counter has a name within the file); or you can have different control files for different counters. This file is a text file. Here is an example:

The following lines are allowed:

# anything
Any blank line, or anything on any line following a # symbol, is completely ignored.

owner=hostname
This line identifies the owner of the files by hostname. For example, if your ISP's web server is www.isp.com and your machine is mypc.isp.com, you'd put owner=mypc.isp.com here. This line restricts the counter to only accepting commands from your machine. If someone from another machine attempts to reset of change your counters, they will get an error message.

For users with dynamic IPs, you'll need to update the owner field each time you dial in to your ISP. If you don't know your host name, just try to access the counter - it will tell you who it thinks you are, and you can use FTP (or whatever) to update the control file.

For users that share an account with other users, just comment out the owner line when you're not using it (or set it to something meaningless, like "hey,there").

ignore=hostname
These lines (there may be as many as you need) designate a number of client host names that will be ignored; their accesses will not cause the counter to increment. This is in addition to other anti-counter-terrorism methods. Wildcards are not allowed; exact matches only. Ask your server administrator if they can provide you with the names of client machines accessing your counters.

charset=charset
The default character set to use. Choose one of the installed charsets, which you can browse from the main page. The default is default.

You may provide your own character set if you want. To do this, create a gif file in the same directory as the counter control file, with the same format as the character sets. Specify the base name of the image in your control file (i.e. for myborder.gif, specify myborder). The counter will automatically use the one in your directory if it finds it.

border=borderimage
The border to use by default (the default is no border). Note that the border will be resized to fit your image.

You may provide your own border image if you want. To do this, create a gif file in the same directory as the counter control file. Specify the base name of the image in your control file (i.e. for myborder.gif, specify myborder). The counter will automatically use the one in your directory if it finds it.

format=format
The default format. This is a printf-like string, such as these examples: Some character sets have additional fixed images that are part of the graphic. For example, the abacus set (realaba) has a left and right edge that use the characters `l' and `r', so its format would be l%06dr.

Note that it's possible to use the counter to display a time by setting the format to a string with no percent signs, like this:

This, of course, is more useful as a parameter to a specific counter tag (below).

random=number
Picks a random number. Keeps an accurate count in the database, but chooses a number from zero to number (not including number itself) and returns that to the viewer.

tag [options]
For each separate counter that you want, you give the name of the counter (like "index" or "puppy") on a line, followed by optional overrides for the charset, border, and format parameters. These overrides may be abbreviated, like this:

You may also specify a "tag" parameter here, which indicates that you should use the count from another tag. This lets you have two counters, with different character sets and borders, that share a single count for both of them:

In the above example, count1 is the one that keeps the actual count, and count2 will use count1's count but its own parameters.

To reference your counter, you simply add an IMG tag, with a hypertext reference to your control file, followed by the tag you want the count of, like this: In addition to reading and incrementing the counters, there are three more URLs that you can use only from a browser on the ``owner'' machine:
file.cnt?tag+reset
If you add +reset to your URL, the counter for that tag will be reset.

file.cnt?tag+set+number
If you add +set+number to your URL, the counter for that tag will be set to the number you specified.

file.cnt?tag+get
This will report the value of the counter in a text message, suitable for automated statistics gathering and whatnot.

file.cnt?mapfile+make
Use this to make a custom character set.


The Delorie Counter is Copyright © 1996 DJ Delorie