#!/usr/bin/perl
# http://jacob.slompinfo.nl
use CGI;
$Arguments = $ENV{'QUERY_STRING'};
$LOCK_EX = 2;
$LOCK_UN = 8;
#print "Content-type: text/html\n\n";
print "Content-type: application/x-javascript\n";
print "Pragma: no-cache\n\n";
@ab = split(/=/, $Arguments);
$value=0;
unless (open(A, $ab[1]))
{
print "document.write(\'err\')\;";
die ("File not found $ab[1]");
}
close(A);
open(A, "<$ab[1]");
$value = <A>;
chomp($value);
$value += 1;
if ($value < $ab[0]) { $value = $ab[0]; }
print "document.write(\'$value\')\;";
close(A);
open(A, ">$ab[1]");
flock (A, $LOCK_EX);
print A $value;
flock (A, $LOCK_UN);
close(A);