Vintners.net: Page counter

At this time we have a single text-based counter on the system (directions on using it follow). If you want a nifty graphic odometer type, it's just a matter of finding one on the web, there are several decent free ones. If you find one you like, email me the URL and I'll look into it.

It's really easy to add a counter, there are two steps:

  1. To use "server side includes" and "server side scripts" the Microsoft IIS server we use requires that your file be named ".shtml" instead of ".html". So if you want your main entry page to have a counter, simply rename it to be "index.shtml". Remember that visitors never have to remember to type this filename as it's the default.

    If on a Unix box, renaming to .shtml works, or you can simply add the following to your .htaccess file:

        AddHandler server-parsed .html
        
    We'd prefer that you don't do this if your site has a notable size as it is much more work intensive for the server.
  2. Add the line that calls the script anywhere in the doc. You'll probably have to go into your layout program's HTML mode to do this. Here's the line directly from MikeL's WA Winery Guide entry page.
            [Uses since 19-Oct-95: <!--#exec cgi="/cgi-bin/counter.pl"-->]
                                   ^ ----- this part is the magic ----- ^
    

Once started it just counts up once every time anyone fetches the page. You cannot change this value, it's kept in a system area -- this is to prevent "cheating" -- artificially inflating the number of visitors. Once you've gotten your page set up and tested, if you wish to have it restarted from zero, it can be changed by an administrator if necessary.

You won't be able to test this on your local machine as your web browser won't know how to run the script. When testing on your machine, the page should come up just fine, except that where the counter will show up on our main server will either be a terse error msg, or perhaps it'll just be blank. When you upload it though, it'll work fine.

How it works:
Whenever the page is loaded through the web server, the server gets the file, sees that it's name ends in ".shtml", so it actually reads the page instead of just handing it over to the visitor.

As it reads through, it looks for less-than/greater-than pairs. When it finds the notation: <!--#exec ...> or: <!--#include ...> it does soemthing special. In the case of 'exec', it runs a script whose name follows and inserts the text output by the script. In the case of 'include', it simply inserts the text of the file name following.

Lemme know if you have problems with it. Contact us.

Page last updated: 19-Feb-1999

Counter test: 5181


Copyright © 1997-2024 Vintners.Net (running on host bayanus)