|
Simple Hit Counters
Counters, counters everywhere! It seems that the hit counter is just
about as ubiquitous as the web itself! Two simple counters, one text and
one graphical, are presented in the sections below. The textual counter,
was written by Jonathan Lewis. The graphical counter is simply a
modification by Scott Pierce of the textual counter.
Installation
To install the counters, connect to your Virtual Server via
Telnet or SSH and
use the commands below that match your Virtual Server O/S:
|
FreeBSD
% vinstall counter
|
BSD/OS
% cd
% tar xvf /usr/local/contrib/counter.tar
|
|
NOTE: If your Virtual Server was ordered after Nov 22, 1999, you are likely
running FreeBSD. To find out which O/S your Virtual Server is running, use the
uname command:
% uname
If your Virtual Server is not already running FreeBSD,
Upgrade to a New FreeBSD Virtual Server
today!
|
Configuration
To configure the counters, do the following.
Vi's standard input and output must be a terminal.
- Configure your Virtual Server web server to recognize
server side includes. Do this by creating a file called .htaccess in the
same directory where the page with the counter is to reside.
The .htaccess File should contain the following lines.
Options Indexes FollowSymLinks Includes ExecCGI
AddHandler server-parsed .html
You can either use the pico file editor to create the file on your Virtual Server or
you can create it locally on your own PC (using "notepad", for example) and then use an
FTP client to upload it to your Virtual Server (in ASCII mode).
- Initialize your counter with a start value. Do this by
creating a file with the same "basename" as your .html file
that you plan to put the counter on, but with the extension
.count, instead of .html.
For example, for a filed called index.html, create a
file by the name of index.count. Put this file in the same
directory as the index.html file. The .count file will contain
just one number: the value from which you want your counter to begin
(probably "0").
You can create the .count File
locally on your own PC (using "notepad", for example) and then use an
FTP client to upload it to your Virtual Server (in ASCII mode).
Or you can do this while connected to your Virtual Server
by doing the following.
% cat > index.count
0
^D (the control-D character)
Implementation
Now you are ready to implement your new counter. Place the counter server side include in the HTML of the page on which you
want to have a counter.
In the .html file include something like the following in the main
body of HTML.
Textual Counter
<!--#exec cgi="/cgi-bin/library/counter/c4.pl" -->
Graphical Counter
<!--#exec cgi="/cgi-bin/library/counter/c4g.pl" -->
Reload your web page and see if it works.
Once you have completed the installation successfully, you will have a
working counter similar to the one shown below.
Over 1,000,000 Internet Customers Served.
You have the flexibility of specifying a
Graphical Counter Digit Set
to be used to display the count if you are using the graphical counter.
Refer to the instructions within the counter code itself
for more information.
Docmumentation
Each counter is documented within the source code:
For technical documentation of CGI, see:
|