Click here to return to Newclient Main Help Page


Simple Counters

Last Updated: February 11, 1997

Counters, counters everywhere! It seems that the web counter is just about a ubiquitous as the web itself! Two simple counters (one text and one graphical) are presented in three sections below.

  1. The Server Side Include for the counters
  2. The source code for the counters
  3. Installation instructions


The Server Side Include for the Counters

the HTML source below represents a the server side include necessary To call either the textual or graphical counter CGI.

    <!--#exec cgi="/cgi-bin/library/counter/c4.pl" -->    (textual)
    
    or
    
    <!--#exec cgi="/cgi-bin/library/counter/c4g.pl" -->   (graphical)
       

In order for Server Side Includes to work, they must be allowed to execute. This can be done globally with the server configuration files or locally with a file named ".htaccess" (assuming typical installation of NCSA httpd applies). A ".htaccess" file overrides global server configuration for the directory in which it resides. An example of a ".htaccess" file is shown below:

     Options Indexes FollowSymLinks Includes ExecCGI
     AddType text/x-server-parsed-html .html


The Source Code for the Counters

The textual based counter, c4.pl, is written by Jonathan Lewis. The graphical based counter, c4g.pl, is simply a modification of the textual counter- modifications were made by Scott Pierce.

If you are unfamiliar with the CGI standard, or would like to learn more about the Common Gateway Interface, the following URL is an excellent resource:

http://hoohoo.ncsa.uiuc.edu/cgi/


How to Install the Counters

    To install the counters you will need to follow these steps:
    1. Install the CGI source files including the textual counter source file, c4.pl, the graphical counter source file, c4g.pl, and the lock.pl file. You will also need to download one or more graphical digit sets which are used in conjunction with the graphical counter.

            If you are a Beck Web AW Server Customer

      1. login to your Virtual Server.
      2. change directories to your home directory (type "cd" and hit return)
      3. type "tar -xvf /usr/local/contrib/counter.tar"

            If you are not a Beck Web AW Server Customer (sign up!)

      1. Verify that a directory path "library/counter" exists in your "cgi-bin" area.
      2. Download the three source files into your "cgi-bin/library/counter" directory and make sure the mode is set so that they will execute (chmod +x).

    2. Create a file called .htaccess in the same directory where the HTML with the server side include is to reside. The .htaccess file should look like:
            Options Indexes FollowSymLinks Includes ExecCGI
            AddType text/x-server-parsed-html .html
    3. Create a file with the same "basename" as your .html file that you plan to put the counter on, but with the extension .count, rather than .html. For example, for index.html, you would create a file by the name of index.count. Put this file in the same directory as index.html. In this file put the beginning count in it (i.e. "0"). An easy way to do this step is as follows:
            % cat > index.count
            0
            ^D (the control-D character)
    4. In your .html file put something like the following in the BODY section:
            <!--#exec cgi="/cgi-bin/library/counter/c4.pl" -->
      or for a graphical counter:
            <!--#exec cgi="/cgi-bin/library/counter/c4g.pl" -->
      With graphical counters, you have the flexibility of specifying a graphical digit set to be used to display the count. Refer to the instructions at the top of the c4g.pl source file for more information.

    5. Reload your web page and see if it works.

    Once you have completed the installation successfully, you will have a working counter like the one shown below.

      Over    Internet Customers Served.

      bd