in reply to Count of downloads from web site.

Write a script to analyze the raw access logs. Or you could use something like this:
LINK: <A HREF="/cgi-bin/download.cgi?file=0111111.exe">Norton Definitions</A +> download.cgi: #!/usr/bin/perl -wT use strict; use CGI; use Fcntl qw|:flock|; my $q = new CGI; my ($file) = $q->param('file') =~ /^(\w+\.\w+)$/; open (FILE, "/path/to/logs/$file.txt") or die("Can't open file: $!"); flock (FILE, LOCK_EX) or die("Can't lock file: $!"); my $count = <FILE> + 1; open (FILE, ">/path/to/logs/$file.txt") or die("Can't open file for wr +iting: $!"); print FILE $count; close (FILE); print "Location: http://site.com/downloads/$file\n\n";
That's just example code. Obviously it wouldn't be great to use for production, but you get the idea.

Joshua

Replies are listed 'Best First'.
Re^2: Count of downloads from web site.
by Aristotle (Chancellor) on Jul 15, 2002 at 16:40 UTC
    ++ with reservations. You don't check to see if your match succeeded, and just let the script run into an invalid redirect or possibly the first of your dies. Giving the user an error page instead would be better. Also, when you reopen the counter file for writing, you lose the lock.
    if(not defined $file) { print $some_error_page; exit; } sysopen FILE, "/path/to/logs/$file.txt", O_RDWR | O_CREAT or die "Can't open $file.txt: $!"; flock (FILE, LOCK_EX) or die("Can't lock $file.txt: $!"); my $count = <FILE> + 1; seek FILE, 0, 0; print FILE $count; truncate FILE, tell FILE; close FILE;
    ____________
    Makeshifts last the longest.
      You don't check to see if your match succeeded, and just let the script run into an invalid redirect or possibly the first of your dies.
      Ah, that's why I said...
      Obviously it wouldn't be great to use for production, but you get the idea.
      I didn't include an error routine just for simplicity sake, though it may have been a good idea to.
      Also, when you reopen the counter file for writing, you lose the lock.
      Thanks for the point there.

      Joshua