diff -r a3447b510e13 -r 62de1ff671d7 upload.pl --- a/upload.pl Wed Oct 20 07:21:56 2010 +0200 +++ b/upload.pl Wed Oct 20 23:20:42 2010 +0200 @@ -11,10 +11,13 @@ # Je nach Permission-Lage kann es gut sein, daß das upload.d-Verzeichnis # mit der Hand angelegt werden muß und dem Webserver-Nutzer „geschenkt“ # werden muß. +# +# Das Upload-Verzeichnis sollte natuerlich vor der Indizierung geschuetzt +# werden - siehe Beispiel .htaccess. # # Eventuell in der Apache-Config sowas wie # ScriptAlias /ud /home/ud/XXX/upload.pl -# Alias /d /home/ud/d/ +# Alias /d /home/ud/XXX/d/ # gesetzt werden. use strict; @@ -29,6 +32,9 @@ my $DIR = "d"; my $DIR_URI = "/$DIR"; +delete @ENV{grep /PATH/, keys %ENV}; +$ENV{PATH} = "/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/sbin"; + -d $DIR or mkdir $DIR => 0750 or die "Can't mkdir $DIR: $!\n"; @@ -48,11 +54,14 @@ } if (length(my $file = param("upload"))) { - my $expires = param("expires"); + my $days = param("expires"); + my $expires; # sanitize expires - $expires =~ /.*?(\d+).*/; - $expires = time + (defined $1 ? $1 : 10) * 86400; + $days =~ /.*?(\d+).*/; + $days = defined $1 ? $1 : 10; + $expires = time + $days * 86400; + # sanitizing the filename (my $filename = $file) =~ tr /\\/\//; @@ -64,6 +73,15 @@ my $outfh = new IO::File ">$dir/$filename" or die "Can't create $dir/$filename: $!\n"; print {$outfh} <$file>; + + if (my $atfh = new IO::File("|at now + $days days")) { + print {$atfh} + "rm -f \"$dir/$filename\"\n", + "rmdir \"$dir\"\n"; + close $atfh; + system("cat /tmp/log"); + } + } print hr;