A Web Page Access Counter

There are a number of qualities that every good web access counter should have. The counter should be:

  • Simple : Why make a complicated web counter?

  • Object-oriented: Everything else is object-oriented these days, why not a counter? (Actually, the counter itself won’t be object-oriented because it doesn’t have to be, but it will use the Broken Image object to display error messages.)

  • Interpreted: We’ll be using Perl, so this shouldn’t be a problem.

  • Robust: It would be nice if the counter had the ability to use different sizes and styles of images for the numbers.

  • Secure: You don’t want other people using your counter on their web page (without your permission).

  • Portable: It shouldn’t be tied to a proprietary web server configuration.

  • High-performance: The counter’s going to be run every time someone hits your page, so it had better be fast.

Sorry, I got my notes mixed up; those are actually the buzzwords for Java, not for web counters. Well, we’ll try to take as many into account as we can anyway. Oh, and if you think you need a counter on your web page, fine, do it. Don’t let other people boss you around, although diehard bandwidth conservationists may make fun of you.

Requirements

The CGI module
The GD module
The BrokenImage module (described earlier)

Solution

The counter will use the GD module described in Chapter 4 to create the image of the numbers. It will actually just pull in precreated GIF images for each of the digits in the number and merge them into ...

Get Programming Web Graphics with Perl and GNU Softwar now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.