Configurable GIF Hit Counter Demonstration Page

Here is an example of the default counter style and settings (white digits on a black odometer-style background):

This page has been visited ********* times since May 10, 2005.

The HTML code that is used to display the counter digits shown above is:

<IMG SRC="http://webcgi.oit.umass.edu/~foodsci/count/ghc.cgi?CF=hc0.ctr" ALT="*********">

Click on the follwing link to see an example of the default settings of an alternate counter style (black Helvetica 18-point text on a transparent background) but with the Ordinal Suffix enabled: Alternate Style GIF Hit Counter Demonstration Page

The delay time before another consecutive hit from the same IP address will be counted as a new hit is set to its normal (default) setting of 1800 seconds (1/2 hour).

Clicking your web browser's Reload or Refresh button to hit this page (ghcdemo.html) again will not change the counter unless 1/2 hour has elapsed or unless the page has been hit in the meantime from some other IP address.


Configuring a Counter

The SRC attribute in the tag contains a URL that calls a Perl CGI script (ghc.cgi) that returns the GIF counter image. The counter is set to use nine decimal digits and so counts to a maximum value of 999,999,999 before resetting to zero. The counter file (hc0.ctr) stores the counter value along with the IP address and date and time (in seconds) of the last time it was incremented. If the current IP address is the same as that saved in the counter file, the counter is only incremented again if at least 1800 seconds (1/2 hour) have elapsed since the last time the page was accessed.

Several parameters can be included in the URL to configure the appearance and function of the counter.

The only required parameter is:

Other optional parameters are:


Error Message Images

If an error occurs, one of the following six GIF images containing an error message will be displayed instead of the GIF image containing the counter digits:

If the calling URL refers to a counter file that does not yet exist or is inaccessible for some reason, the follwing GIF error message image will be displayed:

noctrmsg.gif

As the message implies, counters are not created automatically but must be requested by e-mail. A new counter file will be created with the counter set to its maximum value so that the first time you view the counter with a web browser it will be incremented to a displayed value of zero.

The following GIF error message image will be displayed if any unrecognized data are included in the calling URL:

badurlmsg.gif

One of the following GIF error message images will be displayed if an error is found in opening or closing the counter file, in data found in the counter file, in changing directories or in getting the user's IP address, respectively:

ctraccmsg.gif

ctrdatmsg.gif

cdmsg.gif

noipmsg.gif


Examining a Counter File

It is possible to view the current contents of a counter file without loading the page on which the counter is displayed and possibly incrementing the counter again. The following URL displays the current contents of the counter file shown on this page in your browser's window:

http://webcgi.oit.umass.edu/~foodsci/count/ctrs/hc0.ctr

You'll need to substitute the name of the counter file of interest to you for 'hc0.ctr' to view the contents of that file. The value of the counter is the first nine digits on the line to the left of the first colon. The IP address that last incremented the counter is shown next to the left of the second colon followed by the UNIX date and time (in seconds) at which the counter was last incremented. If you set a bookmark to the counter file's URL, you can use it to check the value of the counter again at any time without incrementing it.


Last updated: April 4, 2008