Look around the WWW Lab
<IMG SRC="/cgi-bin/counter?cnt=counter">Also other options can be added, such as: font to use, increment or don't increment, type of image to output, format of number (EG: number of digits, include leading 0's, space's or nothing, and if number is decimal, hexadecimal, roman!).
<IMG SRC="/cgi-bin/counter?cnt=counter&font=odometer&noinc">
Note however that GET arguments for images are also confusing to the early web clients (Why would an image need such arguments?). Also with get arguments, unless you add a suffix to the end of the option list these clients also will NOT know what type of image they are downloading. Here is a IMAGE URL which should work on most clients.
<IMG SRC="/cgi-bin/counter?cnt=counter&type=.gif">
Using this method the URL's can become very long, with lots and lots of arguments. Also if the counter program allows you to specify the amount to increment, or worse, set the counter to a specific value,your counter will not be secure as someone in the world could just reset your counter on a whim. Thus destroying its usfulness as a counter.
This method however will work with both cgi-bin counters and cgi scripts outside cgi-bin directories. The other method will only work with the former.
For Example:
<IMG SRC="/cgi-bin/counter/~user/counter.cnt">can be used to tell a counter CGI program to increment the counter stored in the file ``counter.cnt'' within the home pages of ``user''.
Note however that this will not work on older web clients for the reasons mentioned above. As such I recommend that the img tag be chnaged to...
<IMG SRC="/cgi-bin/counter/~user/counter.gif">to keep older web clients happy, the counter program then only needs substitute ``.cnt'' for the ``.gif'' suffix to find the counter data file.
Other options for the counter, like font, number format, length, etc. could be added to the above with...
I myself wrote a program using this path method. My own Counter the counter data is stored with the suffixes ``.cnt'' while the number format (as a printf format string) and the directory to get the font images to use is stored in another ``.dat'' file.
<IMG SRC="/cgi-bin/counter">
This is relatively easy to setup and if your server allows CGI execution outside ``cgi bins'' you can even use a local counter script.
<IMG SRC="counter.cgi">
This simple form of script however has no means of specifing which counter you are using. This can be remindied by adding options to the script.
The simplest of these is for a SSI to call a simple script to increment
a counter file, and output the value as text.
EG: the SSI (which looks like a HTML comment)...
<!--exec cmd="inc_counter.pl" -->is replaced with...
793 AccessesMore complex SSI output <IMG> tags for the counter.
<IMG SRC="digit/7.gif"><IMG SRC="digit/9.gif"><IMG SRC="digit/3.gif">OR: create a temporary image file (to be removed/updated later) and point to it.
<IMG SRC="tmp/cnt.gif">
The advantage of server side include counters are
However the disadvanages are
The advantages, are that the one server can handle all the counters required, for any machine around the world, unlike most other counters methods above which can only use locally stored counters.
For example:
http://counterhost.domain:port/font/counter.typecould be used to request the counter `counter', on the `counterhost' (could be the same machine) at the port given. This server would output the current count in the requested `image type' using the font `font' (optional). Also any client program would never know that anything was out of the ordinary, except that the image came from a different WWW server.
The counter server itself does not need to run continuously like a real WWW server but could be run on request by the `Inetd'. In fact by using inetd, you don't even have to bother with sockets and ports, etc. as inetd automatically connects standard input and output to the connected socket. In other words, you just recieve the Mime request from STDIN and output the final Mime Image to STDOUT.
I had created a simple version of a counter server. Mine however only understood how to generate X bitmaps. Actually it was a perl'ed copy of the first ever counter program I had ever seen. This counter program was created long before the advent of CGI, when script were still getting arguments insecurally on the command line!
Such servers however can be quite complex, as it does have to understand the HTTP protocol and normally would require superuser access to set up. As such while these were the first such counters they are rarely seen today.