www.ccsbbs.com

SSI Text and Graphical Counters

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/c4.pl" -->    (textual)

or

  <!--#exec cgi="/cgi-bin/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
  AddType text/x-server-parsed-html .html

The Source Code for the Counters

The textual based counter is written by Jonathan Lewis. The graphical based counter 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 textual based counter you will need to follow these steps:

  • Create a file called .htaccess in the same directory where the HTML with the server side include is to reside. .htaccess should look like:
      Options Indexes FollowSymLinks Includes
      AddType text/x-server-parsed-html .html
    
  • 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").

  • In your index.html file put something like the following in the BODY section:
    Over <!--#exec cgi="/cgi-bin/c4.pl" --> Internet Customers Served. 
    
  • Reload your web page and see if it works.

    To install the graphical based counter you will need to follow these steps:

    1. Create a file called .htaccess in the same directory where the HTML with the server side include is to reside. .htaccess should look like:
        Options Indexes FollowSymLinks Includes
        AddType text/x-server-parsed-html .html
      
    2. 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").

    3. In your index.html file put something like the following in the BODY section:
        Over <!--#exec cgi="/cgi-bin/c4g.pl" --> Customers Served. 
      
    4. Reload your web page and see if it works.