in reply to Count of downloads from web site.
That's just example code. Obviously it wouldn't be great to use for production, but you get the idea.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";
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 | |
by joshua (Pilgrim) on Jul 15, 2002 at 17:18 UTC |