#!/usr/bin/perl
print "Content-type: text/html\n\n";
$curdir=`pwd`;
chomp $curdir;
$curdir=~s:^/home/www/html::;
print "\n
Contents of $curdir\n";
print "";
print "Contents of $curdir
\n\n";
mkdir("thumbs",0755) if(! -e "thumbs");
opendir(DIR,".");
print "
\n";
$count = 0;
foreach $n (sort readdir DIR) {
if ($n=~/jpe?g$/ ||
$n=~/JPE?G$/) {
$command = "djpeg $n | pnmscale -xysize 100 100 | " .
"cjpeg > thumbs/$n";
} elsif ($n=~/gif$/ ||
$n=~/GIF$/) {
$command = "giftopnm $n | pnmscale -xysize 100 100 | " .
"pnmtogif > thumbs/$n";
} elsif ($n=~/png$/ ||
$n=~/PNG$/) {
$command = "pngtopnm $n | pnmscale -xysize 100 100 | " .
"pnmtopng > thumbs/$n";
} else {
next;
}
print "" if(($count++ % 4) == 0);
print " $n\n";
if ( ! -e "thumbs/$n" ) {
system $command;
next;
}
@ts = stat("thumbs/$n");
@s = stat($n);
system $command if($ts[9]<$s[9]);
}
print " |
\n";
closedir DIR;
print "\n\n";