Features include:
With SSI operation the script outputs ordinary text/html to the server, which then parses it into the web page. For the text counter style this output is plain text, with an optional preset hyperlink around the hit count. The text style is very handy , since ordinary HTML markup can then be used to change the font. (See the examples below.) For the graphical counter styles (LED, odometer, ...) the script replaces the hit count with an HTML image tag pointing to the GIF image of the counter, saved as another file on the server.
For the graphical counter styles the single counter image is created from individual images of the counter digits. Each digit style is contained in a separate subdirectory (of the same name as the style). Hundreds of digit styles are available from the Digit Mania archive. New styles can be added at any time by simply placing them in the proper directories.
For non-SSI operation an HTML image tag can be placed in the web document pointing to the VersaCounter script. The GIF image of the counter is then output directly to the browser. In this mode of operation, the text style is unavailable.
When logging is enabled a log file is created for each HTML document. This contains the time/date, remote host, referring page (SSI only), and user agent/platform associated with each hit. I am currently working on a site statistics program which utilizes these logs. Here is a demo of the current program.
<!--#include virtual="/path/vcounter?option1=value1&option2=value2... " -->
path is the directory path from the top of the web site to the VersaCounter script, with filename vcounter (change to vcounter.cgi as necessary). The available options are
options | defaults | possible values |
---|---|---|
page | URL | name or if unspecified, the URL of the page is used (with /'s changed to _'s) |
show | counter | counter, date, all ("<counter> hits since <date>"), nothing |
style | text | text, odometer, LED, ... names of the installed digit directories ... |
digits | 0 | N - minimum number of digits to display |
trans | - | r,g,b - color number to make transparent (r,g,b each run 0 ... 255) |
link | 0 | 0, 1 - turn off, on the preset hyperlink |
align | bottom | top, middle, bottom - alignment of text after graphical counter image |
block | 360 | sec - number of seconds to block consecutive reloads from incrementing |
increment | 1 | 0, 1 - turn off, on counter incrementation ("counting") |
log | 1 | 0, 1 - turn off, on logging of visitor statistics |
start | 0 | count - initialize counter to start at the value count * |
start_date | creation | date - initialize counter as if started on date (any format) * |
* these options only need to be supplied upon initial creation (if ever) | ||
<!--#include virtual="cgi-bin/vcounter?style=odometer" -->
<B> Welcome! <B> You are visitor number <!--#include virtual="cgi-bin/vcounter?style=text" -->.
Welcome! You are visitor number 4,710,532.
<!--#include virtual="cgi-bin/vcounter?style=text&show=all" -->
4,710,532 hits since May 31, 1998
<H1> <!--#include virtual="cgi-bin/vcounter? style=text&commas=0&show=all&link=1" --> </H1>
<FONT SIZE="5">
<!--#include virtual="cgi-bin/vcounter?
show=counter&style=text&link=1" -->
</FONT> < BR >
<I> visitors since
<!--#include virtual="cgi-bin/vcounter?show=date" --> </I>
4,710,532
visitors since May 31, 1998
<!--#include virtual="cgi-bin/vcounter?show=counter&style=rosewood" -->
<FONT SIZE="7">satisfied customers</FONT>,
since
<B>
<!--#include virtual="cgi-bin/vcounter?show=date" -->
</B>
satisfied customers, since May 31, 1998
<IMG SRC="http://www.wherever.com/path/vcounter?option1=value1&option2=value2... ">
Here, www.wherever.com is the hypothetical name of the server running the VersaCounter script. The available options are
options | defaults | possible values |
---|---|---|
page | URL | name or if unspecified, the URL of the page is used (with /'s changed to _'s) |
show | counter | counter, nothing |
style | odometer | odometer, LED, ... names of the installed digit directories ... |
digits | 0 | N - minimum number of digits to display |
trans | - | r,g,b - color number to make transparent (r,g,b each run 0 ... 255) |
block | 360 | sec - number of seconds to block consecutive reloads from incrementing |
increment | 1 | 0, 1 - turn off, on counter incrementation ("counting") |
log | 1 | 0, 1 - turn off, on logging of visitor statistics |
start | 0 | count - initialize counter to start at the value count * |
start_date | creation | date - initialize counter as if started on date (any format) * |
* these options only need to be supplied upon initial creation (if ever) | ||
<IMG ALT="Counter Image" SRC="cgi-bin/vcounter?style=odometer">
<IMG ALT="Counter Image" SRC="cgi-bin/vcounter?style=LED_green&digits=10">
<A HREF="http://www.aquilo.net/stats.cgi">
<IMG ALT="Counter Image" SRC="cgi-bin/vcounter?style=curly">
</A>
Printing an HTML image tag:
#!/usr/bin/perl print "Content-type: text/html\n\n"; # output http header print "<HTML>\n"; print "<HEAD><TITLE>Virtual Web Page</TITLE></HEAD>\n"; print "<BODY>\n"; print "Hello, you are visitor number"; print "<IMG SRC=\"/cgi-bin/vcounter?style=odometer&header=0\">\n"; print "</BODY>\n"; print "</HTML>\n";
With this method the counter works the same as in normal non-SSI operation. Hence, no text output is available. A better method is to emulate SSI operation, as in the following example.
Explicit system call:
#!/usr/bin/perl print "Content-type: text/html\n\n"; # output http header print "<HTML>\n"; print "<HEAD><TITLE>Virtual Web Page</TITLE></HEAD>\n"; print "<BODY>\n"; print "Hello, you are visitor number" { local $ENV{'DOCUMENT_URI'} = '/cgi-bin/$0'; # pass page name local $ENV{'REQUEST_METHOD'} = 'GET'; # ensure GET method local $ENV{'QUERY_STRING'} = 'style=odometer&header=0'; # pass counter options print `/usr/local/www/cgi-bin/vcounter`; # call counter } print "</BODY>\n"; print "</HTML>\n";
As in SSI operation, all VersaCounter options are now available.