#!/usr/bin/perl -w
use CGI::Carp qw(fatalsToBrowser);
use CGI qw(:standard);
use Net::FTP;
use Fcntl qw/:flock :DEFAULT/;
$query = CGI->new();
print "Content-type: text/html\n\n";
$tmpdir = $query->param("tmpdir");
print "
WebZip Directory Mover
This tool will only work with files that are unzipped by WebZip
NOTE: Directory DOES NOT have to previously exist.
";
my $counter = "dirmover-counter.txt";
sysopen(COUNT, $counter, O_RDWR|O_CREAT)
or die "Can't OPEN data file for READING and WRITING: $!";
flock(COUNT, LOCK_EX) or die "Cannot get
an EXCLUSIVE LOCK on data file: $!";
my $num = || 0;
chomp $num;
$num++;
seek(COUNT, 0, 0) or die "can't REWIND to
beginning of data file: $!";
truncate(COUNT, 0) or die "can't TRUNCATE data file: $!";
print COUNT "$num\n";
## Take out the line below if you don't
## want commas in your numbers.
1 while $num =~ s/(.*\d)(\d\d\d)/$1,$2/;
close COUNT or warn $!;
print <
$num
EOL