Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

I have a bunch of pages that have downloads on them and I am trying to track how many times the page has been viewed and the number of downloads there has been.

I have the database (DB_File) and stats already set up through another script. My problem is how am I supposed to get all of my .shtml pages to load the script specifically for that page?

I am using an SSI include on the file that I need stats from and I need the script to somehow know what the referer was. I guess that's my question. Through the use of an SSI for a CGI script, will the included CGI be able to tell you the referer of the page that called it?

Replies are listed 'Best First'.
Re: using SSIs from database
by sulfericacid (Deacon) on Jan 23, 2005 at 05:57 UTC
    To tell you the truth, when I first thought about an SSI'd script bringing back a referer I didn't think it would work. But when you think about it, it's no different than a CGI form checking for referer.

    In short, your answer is yes. Here is what I did.

    HTML

    <!--#include virtual="../cgi-bin/stats/test.pl"-->
    test.pl
    #!/usr/bin/perl use warnings; use strict; use CGI qw/:standard/; print header; print "your page is $ENV{'HTTP_REFERER'}";
    Results
    your page is http://www.domain.com/cat/11/index.shtml


    "Age is nothing more than an inaccurate number bestowed upon us at birth as just another means for others to judge and classify us"

    sulfericacid