ssd's counter page -- perl version

If you haven't read the top level counter page and the counter rules page, please do so now, especially the section on acceptable usage in the rules page.

This page describes the New counter URL format. The old format also works with the script, but the C version will not support it. Other servers may only accept the old format or accept both.

The differences between the old format and the new format are:

  1. The delemiters have changed from // to ?&, and look more like a normal query instead of what it was.
  2. The key is FIRST (it use to be last), and the options follow.
For example, an old style counter URL looked like
http://yoursite/counter/width=4/dONTuSEtHIStAG
The new format looks like
http://yoursite/counter?dONTuSEtHIStAG&width=4
Sorry for changing it again (this is the second time), but this change is hopefully MUCH for the better, and no further incompatable changes are planed to ever be made. (Except for maybe invalidating more stupid keys or adding new options that might collide with old keys, but IMHO those don't count.) (I might move the counter to another server or port, though.)

(The rest of this page is pretty much the same as it was before, but with updates reflecting the new format.)

The current rules for interpreting the counter URL are rather strict. Please read the rules in the documentation section to make sure your counter URL is valid. If you think it is valid and it still doesn't work, send me mail.

If you copy my counter, please mail me and tell me so (or register it), so I can put you on the mailing list announcing updates.

Documentation

The counter format is an initial key followed by various options and switches. For example:
<mg src="/counter?dONTuSEtHIStAG&width=4" height=20 width=60>
Two options are currently defined:
width=
the number of digits in the number; currently the only supported font uses 15x20 character cells
noinc
indicates you wish to view the count without incrementing it. You can put this in a special page so that the count will not increment when that page is viewed.
NOTE: Any other parameters will be considered invalid, and no image will be generated.

The final path component is the "key", which is used to uniquely identify each count. The following special keys exist:

<img src="/counter?1234567890" height=20 width=150> digits only
a specific number
xxx page counter (netscape only!)
The key xxx counts accesses by netscape and other browers that pass an http REFERENCES line.
<img src="/counter?rand"> rand
a random number
index or index.html
this key is invalid and will not generate an image
Note: If no key is present, no image will be generated.

Source code

Note: This program is TOTALLY USELESS to you unless you are webmaster at your site or have permissions to put things in the cgi-bin directories. Please refer to the documentation for your httpd or to your webmaster person before you beg me for help installing this. I am only familiar with servers that I have used, so I can't help you until you know what you're doing.

Note: The current code is really a quick hack. I'm in the process of rewriting this in C (see the C counter page for details) to make it much more efficent.

I wrote this to work with CERN httpd, but others have gotten it to work with NCSA as well. There are some config options in the script that require modification depending on which server you use it with and what path it is on. (Some of them are critical only for the old format URLs to work.)

The program itself is a perl script; it uses ppmtogif to generate the gif format image from the individual digit images, which are stored as pgm image data directly in the perl script. The digits are concatenated as the perl script sends them to ppmtogif.

I believe this to be free of bugs EXCEPT that I do NO file locking. In theory, if two simultaneous accesses to the same key are made, the count could be corrupted. If two new keys are simultaneously created, the whole database may be corrupted. It really depends on how solidly your system's ndbm is implemented.

Also, performance isn't that great, as the perl interpreter must read in the digit data as ascii, and then the perl script has to run ppmtogif to convert it. Performance could be enhanced by either moving the images to a binary format and reading them in, or by converting the whole thing to C, neither of which do I feel like doing this week. :-)

Please feel welcome to fix these bugs and send me back patches.

If you'd like to add a different font, send me the digits (the more you preprocess them to look like the existing perl code the faster it'll get done), and I'll add the font to the script. Note that I think the existing digits are cool--I'm not looking for a replacement. If I add another font, it will be because the new digits are differently cool.

There are several relevant sources, all perl scripts:

Note on netpbm: My current script uses the old October '91 release of pbmplus. I just picked up netpbm, and have not had time to look at it, although I did install it at home, and it should work fine with the existing script. If I were to rewrite this as C, my first step would be to steal the font and gif encoders out of netpbm.

Also, I have written some additional useful accounting scripts but not any separate documentation for them.

If you get the counter script working on your server, please send me e-mail.


SSD 7-Jul-95