ccounter.cgi Version 1.2
Written by Nick Donaldson - email@example.com
Created 12/12/96 Last Modified 4/28/97
Copyright 1997 CLIQ Services Coop www.cliq.com
This program is provided as freeware and may be freely used, as
long as all banners are left intact.
All that I ask in return for use of this program is that if you are
using this program in your site, please let me know so I can check it
counter.cgi is a simple program to generate a graphical web site
visitor is counted once only per session, and contains provision for
playing an embedded sound file on the first hit, and either displaying
the count without incrementing, or incrementing without displaying.
The zip archive ccounter.zip should include the following files:
readme.txt (this file)
The alt_gifs.zip contains alternate gifs from 0-9.
Expand the ccounter.cgi program into the directory where you wish to
run it from (it may be easiest to make this your root html dir). The
gif files can be placed in your graphics/images dir, but you must
change the $graphicsdir string to reflect their location. The
ccounter.cgi program file must be set to executable with a chmod 755
command, ie 'chmod 755 ccounter.cgi'.
Place the two html files in your root webspace - you will find out how
to use them later.
I have included a second set of conventional number gifs in the
alt_gifs.zip archive contained within the main archive.
That's pretty much it!
After installation, I have one favour to ask of you; in return for
free use of the counter, please send me an email letting me know that
you are using my program, and also put a link to my ccounter page using
the countertile.gif image.
The html code looks like this:
<img src=/graphics/countertile.gif border=0></a>
It will produce a linked button that looks like this -->
Each page to be counted must be assigned a unique name. For instance,
if you are counting hits to index.shtml, assign the name "index".
Create two new text files in the same directory as the file to be
NAME.ctr (in this example, "index.ctr")
NAME.bak (in this example, "index.bak")
And set their attributes to group r/w. This way, the cgi can write to
Next, copy the digit gif files to a graphics directory (the default is
The counter is called as a server side include. You should check how
your server handles SSIs, but the call will generally be contained in a
*.shtml file and should look something like:
<!--#exec cmd="/cgi-bin/counter.cgi PAGENAME COMMAND"-->
Where PAGENAME = the unique name assigned to the page
COMMAND = additional parameter passed to program
In our example, the basic call would look like:
<!--#exec cmd="/cgi-bin/counter.cgi index"-->
COMMAND allows three seperate options:
nocount : Display the count but do not increment
noshow : Increment the count but do not display
SOUNDFILE : path/name of soundfile to embed.
examples would be:
<!--#exec cmd="/cgi-bin/counter.cgi index nocount"-->
<!--#exec cmd="/cgi-bin/counter.cgi index noshow"-->
<!--#exec cmd="/cgi-bin/counter.cgi index sounds/sound.au"-->
If you want to take advantage of the cookie functions, you must add
meta tags into your html pages to set the cookies. The top of your
html should look like this:
<META HTTP-EQUIV="Set-Cookie" Content="my_cookie=PAGENAME">
Where PAGENAME = the unique name assigned to the page.
In our example, the meta tag would be:
<META HTTP-EQUIV="Set-Cookie" Content="my_cookie=index">
Now, each time the page is loaded, a temporary cookie will be set that
expires at the end of the session, ie when Netscape is closed.
The program checks for the existence of this cookie, and if it exists,
displays the count only, without incrementing. This ensures that each
visitor is counted once only, even if they reload the page.
If you wish to use the locking routines, you must uncomment the line
marked and add a directory called 'lockdir' to each html directory that
you are using the counter with. Change the permissions on the
'lockdir' directories to 777 - ie, group and world writable. Now, each
time that the program is run, it checks for the existence of the lock
file corresponding to the page that it was called from. If the lock
file exists, it means that another user is incrementing the count, and
writing to the counter file may corrupt it. The programs waits until
the lockfile disappears and increments, or times out after 3 seconds
and displays the count with no increment.