SFU Web page Access Counter and Clock!

Table of Contents

  1. Introduction
  2. How To Use
  3. Options
  4. Counter Options
  5. Clock Options
  6. Date Options
  7. Colors

1. Introduction

This is a CGI program to keep a record of the hits on a web page. It generates a GIF image of the number of hits which it returns to the browser as an in-lined image. The program also has a run-time option not to show the count image, this way a count of the hits on a page can be kept without displaying it. The hits can also be monitored without incrementing from a separate page. Almost all of the features are run-time options. The hits are no way accurate. Someone can reload the page again and again to increase the hits. However, people like to see how many times someone visited their page.

The program can also be used to display time or date. The time or date of any place in the word can be displayed by specifying a timezone string for that location. The date can be formatted in any combination of MMDDYY (Month-Day-Year).

For an interactive page to try out the various options for the counter program, try out the demo page.

The counter program was written by M. Muquit. Information on the program can be found here

2. How To Use

To include a counter in your HTML document, you use an img command like the following:

<img src="http://www.sfu.ca/cgi-bin/count.cgi?" align=absmiddle>

The part of the command within quotes is the name of the counter CGI program itself. The question mark can be followed by various options. Make sure there are no spaces between the quotes.

3. Options

You can use the count.cgi program to display a hit counter, a clock, or a date. Options are specified after the question mark in the img command. The options are separated by either ampersand (&) or vertical bar (|) characters.

The following options can be used with any of these.

  1. Frame thickness.
  2. The counter image can be wrapped in an ornamental frame. The frame thickness is specified with the ft option. A frame thickness of zero is used to specify no frame. The default frame thickness is ft=6. The following example will give a counter with no frame:

    <img src="http://www.sfu.ca/cgi-bin/count.cgi?ft=0">

  3. Frame color.
  4. The color of the frame can be changed with the frgb option. The default color for the frame is frgb=100;139;216. The following example will give a counter with a green frame:

    <img src="http://www.sfu.ca/cgi-bin/count.cgi?frgb=green">

  5. Digit style.
  6. The style (font, character set) of the digits used in the counter can be changed. The dd option is used to select a style. A number of styles are currently available including the following standard ones. The default is style A.

    See the demo page for more font styles.
    Style A  styleA 
    Style B  styleB 
    Style C  styleC 
    Style D  styleD 
    Style E  styleE 
    The following example will give a counter with style B characters:

    <img src="http://www.sfu.ca/cgi-bin/count.cgi?dd=B">

  7. Transparency options
  8. One of the colors of the counter image can be made transparent. This is useful if you want the background of the counter image to be "clear". Transparency can be turned on with the option tr=Y. The default color to be made transparent is black. If you want to make a different color transparent, you would use the trgb option. If you use the trgb option you do not need to use the tr=Y option as well.

    The following example will give a counter with the color green made transparent:

    <img src="http://www.sfu.ca/cgi-bin/count.cgi?trgb=green">

  9. Color change options
  10. Any one color of the counter image can be changed to another color. There are three options that can be used for changing colors. The option chcolor=Y can be used to change green to cyan. If you wish to specify the colors directly, you would use the srgb option for the color to change and prgb for the color to use as a replacement. If you use the srgb or prgb options you don't need to use the chcolor=Y option as well.

    The following example will substitute red for blue in the counter image:

    <img src="http://www.sfu.ca/cgi-bin/count.cgi?srgb=blue|prgb=red">

  11. Negate color
  12. The colors of the counter image (excluding the frame) can be negated. If this option is selected, black becomes white, red becomes cyan etc. The option negate=Y is used to turn on this option.

    The following example will negate the colors of the counter image:

    <img src="http://www.sfu.ca/cgi-bin/count.cgi?negate=Y">

  13. Rotate image options
  14. The counter image can be rotated 90, 180 or 270 degrees. The option rotate=Y can be used to rotate the image the default 270 degrees. To rotate the image a specified number of degrees, use the degrees option.

    The following example will rotate the counter image 90 degrees:

    <img src="http://www.sfu.ca/cgi-bin/count.cgi?degrees=90">

4. Counter Options

By default the count.cgi program will display a counter of the number of times the page that contains it has been hit. Although it is not strictly necessary, it is a good idea to specify the page you are counting. You do this with the df option (this is also used to specify counting another page. See the description below).

For example, if you are putting a page counter in the page:
http://www.sfu.ca/~jdoe/index.html
you would put the following in that page:
<img src="http://www.sfu.ca/cgi-bin/count.cgi?df=www.sfu.ca/~jdoe/index.html">

The following options can be used to modify the behavior of the counter.

  1. Maximum number of digits.
  2. The maximum number of digits to display in the counter can be set with the md option. The default maximum is six. The maximum number of digits to display can range from five to ten inclusive. If the actual count is longer than the maximum, the number will be truncated. Note: Using this option will turn on padding with leading zeros (see next item). If you don't want padding with leading zeros, you will have to turn it off.

    The following command will restrict the counter to a maximum of five digits:

    <img src="http://www.sfu.ca/cgi-bin/count.cgi?md=5">

  3. Leading zeros
  4. The number of digits displayed can vary with the size of the counter, up to the maximum set by the previous option, or the number of digits displayed can be set to the maximum by padding with leading zeros. Leading zero padding is turned on by default. If you don't want leading zeros displayed, you can use the option pad=N.

    The following command will turn off the display of leading zeros:

    <img src="http://www.sfu.ca/cgi-bin/count.cgi?pad=N">

  5. Display commas.
  6. To make longer numbers easier to read, commas can be placed at every third digit. To turn on the display of commas, use the comma=Y. Note: Using the comma option will turn off the display of leading zeros described above.

    The following command will turn on the display of commas:

    <img src="http:www.sfu.ca/cgi-bin/count.cgi?comma=Y">

  7. Start Count.
  8. A counter for a page will be set to one the first time it is used, and will be incremented by one for each use afterward. The counter for a page can be set to a particular value using the st option. This option can be most effectively used in conjunction with the df option described below.

    The following command will reset the counter for the page "default.html" to zero.

    <img src="http:www.sfu.ca/cgi-bin/count.cgi?st=0|df=default.html">

  9. Show Digits.
  10. Normally the counter image is displayed on the page. It is possible to turn off the display of the counter while still having the counter incremented for each hit on the page. It would then be possible to use the df and incr=F options to look at the counter from another page. The option sh=N is used to disable the display of the image.

    The following command will disable the display of the counter:

    <img src="http:www.sfu.ca/cgi-bin/count.cgi?sh=N">

  11. Increment Count.
  12. Normally the counter is incremented by one each time the image is redrawn. There are times when it is useful to view the count without incrementing it, as when viewing the counter from another page. The incr=F option will disable the incrementing of the count.

    The following command will display the page count without incrementing it:

    <img src="http://www.sfu.ca/cgi-bin/count.cgi?incr=F">

  13. Page to Count.
  14. Normally the count is the number of hits on the page that contains the img command. It is possible to have the counter display the count for another page in the same directory as the page containing the img command. The df option is used to specify another page for the counter. This is most useful when used in conjunction with the incr=F option described above to look at the counter for another page without incrementing it.

    The following command will display the count for the page test.html in the same directory as the page containing the command. It will not increment the counter of that page:

    <img src="http://www.sfu.ca/cgi-bin/count.cgi?df=test.html|incr=F">

  15. Display Random Count.
  16. Instead of displaying the hit count for this page or another page, the counter can display a random number. Use the option df=random to display a random number rather than the count of this or some other page.

    The following command will display a random number as the count:

    <img src="http://www.sfu.ca/cgi-bin/count.cgi?df=random">

  17. Display Literal String.
  18. Instead of displaying the hit count for this or another page, the counter can display a specified number. Use the lit option to display a literal string of digits.

    The following command will display the string "1234567890" as the count:

    <img src="http://www.sfu.ca/cgi-bin/count.cgi?lit=1234567890">

5. Clock Options

You can use the counter program to display a clock on your web page. To get it to display a clock you would use the display=clock option.

The following options can be used to modify the behavior of the clock.

  1. Time Format
  2. The clock can display the time in 12 or 24-hour format. The default format is 12. The tformat=24 option is used to change to 24 hour format.

    The following command will display a clock in 24-hour format:

    <img src="http://www.sfu.ca/cgi-bin/count.cgi?display=clock&tformat=24">

  3. Timezone
  4. If you want to display the time of another timezone you can use the timezone option. The timezone must be specified with a negative or positive four digit offset from GMT, for example: timezone=GMT-0500.

6. Date Options

You can use the counter program do display the current date on your web page. To display the date, you would use the display=date option.

The following options can be used to modify the behavior of the clock.

  1. Timezone
  2. If you want to display the date of another timezone you can use the timezone option. The timezone must be specified with a negative or positive four digit offset from GMT, for example: timezone=GMT-0500.

7. Using Colors

Various options, such as setting the color of the frame, require a color specification. Colors can be specified in one of three ways.

The first is RGB, where you give a number for each of the Red, Green and Blue components of a color. The numbers represent the intensity of the color and range from zero (for off) to 255 (for full intensity). Setting all three to zero will produce black. Setting all three to 255 will give white. The three values are separated by semi colons. For example, to set the frame color to green, you would use the parameter frgb=0;255;0.

The second is a hex string where each of the Red, Green and Blue values are represented by a hex value between 00 (for off) and FF (for full intensity). The three hex values are concatenated together. For example, to specify a frame color of green using hex values, you would use the parameter frgb=00ff00.

The third way to specify a color is by name. For example, to specify a frame color of green using a color name, you would use the parameter frgb=green.