#!/usr/bin/perl # author: Jason Quek # company: GT Designs & Concepts # e-mail: jason@jumpsql.com # program: JumpSuperCounter print "Content-type: text/html", "\n\n"; # This line must always be present $requesting_page = $ENV{'REQUEST_URI'}; if ($requesting_page eq '/') { $requesting_page = 'index'; } else { $requesting_page =~ s/^\///; # remove preceeding backslash $requesting_page =~ s/\.([^\.]*)$//; # remove filename extension if ($requesting_page =~ /\/$/) # add 'index' should user access this page using only directory name { # (e.g. http://www.domain.com/folders instead of http://www.domain.com/folders/index.shtml) $requesting_page =~ s/\/$/\/index/; } $requesting_page =~ s/\//_/g; } if ($requesting_page) { use Fcntl; sysopen(FH, "$requesting_page.txt", O_RDWR|O_CREAT, 0644) or die "can't open numfile: $!"; flock(FH, 2) or die "can't flock numfile: $!"; $num = || 0; seek(FH, 0, 0) or die "can't rewind numfile: $!"; truncate(FH, 0) or die "can't truncate numfile: $!"; (print FH $num+1, "\n") or die "can't write numfile: $!"; close FH or die "can't close numfile: $!"; print "$num"; }