College of Engineering Logo Web Server Logs Student Server Logs Orange bar Main Page General Information Special Events Programs Research Student Information Computer Facility Outreach Xtreme Engineering Jobs Available

Counters on our server

In response to many requests by our users for an "officially-supported" counter program, we have written a small program to increment a counter each time a page is accessed. In order to do this, however, your page needs to be set to do server-side includes.

What to do

Once you have set up your page(s) to have server side includes, include this server side include directive in your html file.

<!--#exec cgi="/cgi-bin/count" -->
Each time your page is accessed, the server replaces the above directive with a number representing the number of times that page has been accessed.

But where does this number come from?

Each users' count is stored in the server's /var/tmp/counters directory, under a file name related to the file being referenced. For example, if your home page is located at ~johndoe/Html/home.html, the corresponding file in /var/tmp/counters is located in the file, johndoe-Html-home. In addition, there is also another file which lists the hosts from which your page was accessed from, using the above example, johndoe-Html-home.list. You may edit and view the contents of this file by logging in to the web server (www.eng.hawaii.edu) itself. (Although the file is not owned by you, you may edit it, thanks to Access Control Lists, a feature found in Hewlett-Packard's version of Unix. If you would like to remove a file, please notify the webmaster to have it removed.)

What else does this counter program do?

In addition to simply allowing a numerical counter, this program has several options which allow you to customize its output. By changing the name of the program slightly, you can change the way the output appears. Here is a list of the different versions of the same program:
NameDescription
count The regular version of the program, and it counts the number of accesses using arabic numerals. (1, 2, 3 ...)
count-inv An "invisible" version which produces no output, but updates the counter.
count-spell A version which spells out the number of accesses. (one, two, three ...)
count-ord A version which spells out the ordinal number of accesses. (first, second, third ...)
count-pord A version which counts using ordinal numbers with arabic numerals. (1st, 2nd, 3rd ...)

Configuring some things

Borrowing some of the configurability from the Apache server program, you can set some options to the counter. The counter's configuration file has the same name as the file with the counter in it, aside from the suffix cntr instead of html (for example, home.cntr for home.html) added things you can add to the cntr file. logfmt option. Each of the following letter is preceded by a percent sign, and the default value for this option is "%n %h".
OptionDescription
digits Specifies path where gif images for digits are stored
digopt Changes the way the digits are concatenated
link.

Author: Ben Yoshino (ben@wiliki.eng.hawaii.edu)

Comments, Questions? | E-mail: webmaster@wiliki.eng.hawaii.edu


Last updated on Monday, February 05, 2001
Copyright © 2001 University of Hawai`i, College of Engineering, Computer Facility
All rights reserved.