#!/usr/bin/perl -w
print "Content-type: text/html\n\n";
use CGI::Carp qw(fatalsToBrowser);
use CGI qw(:standard);
use LWP::Simple;
use LWP::UserAgent;
use HTTP::Request;
use HTTP::Cookies;
use HTTP::Headers;
use File::Find;
use File::stat;
use Fcntl qw/:flock :DEFAULT/;
BEGIN {
$ENV{PATH} = "/usr/bin:/bin:/usr/local/bin";
}
my $dir = "wkdir";
opendir(DIR, $dir) || die "can't opendir $dir: $!";
my @dirs = grep { /^(\d{4})$/
&& -d "$dir/$_" } readdir(DIR); closedir DIR;
foreach my $f (@dirs) {
$f =~ /^(\d{4})$/ or die "$f is tainted: $! \n";
$f = $1;
my $age = time() - 2*3600;
my $stats = stat("$dir/$f") or die "Can't stat: $!";
if ( $stats->mtime < $age ) {
system("rm", "-r", "$dir/$f");
};
};
sub fdie {
my($ero) = @_;
print <
ERROR: $ero
Having Problems? Send the URL that you tried to the webmaster at
dennis100\@webtv.netfor help.
HTML Mail OR Mail without a URL will be discarded.
EOL
$path = "unzipper-log.txt";
open(LOG, ">> $path");
sysopen(LOG, $path, O_WRONLY | O_APPEND | O_CREAT);
print LOG "$ero\n";
close LOG;
exit;
}
if ($ENV{REQUEST_METHOD} ne "POST")
{
print <WebZip UNZIPPER
Copyright 2-1-2001 by
whataman\@home.com /
dennis100\@webtv.net
De-compress any of these file types -
.zip, .gz, .tar, .tgz, .tar.gz, .tar.Z, .bz2 and tar.bz2
After your zip file has been unzipped here, your unzipped file(s) may not be viewable from this site, or you may only see the raw codes; but the file should be fine after you upload or download it. Note that .exe files are not allowed, and are thrown away. You can now also upload a file from your computer. Further, zipped webmail or any other zip file that requires authorization (user, password) will not work with this tool. Type or paste your zipfile URL into the box below. Your URL must begin with either http:// or ftp:// and end with one of the zip extensions listed above, such as .tgz
EOL
$query = new CGI;
print headers;
$JSCRIPT=<function upL() {
if ( navigator.appName.indexOf('WebTV') != -1 )
{
document.write("");
};
};
print end_html;
END
#Tell the browser to expect some JavaScript
print "";
$value = $query->param('upfile');
print $value;
@value = $query->param('upfile');
print "$value ZZ";
print <
EOL
my $counter = "unzipper-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 <