#!/usr/bin/perl -w use strict; my $deposit_dir = "/home/public/dog-slow.org/blog"; my $time=time(); my $pid=$$; my $randnum=int(rand 65535)+1; my $file=".$time.$pid.$randnum.txt"; my @files; my $action; $ENV{"TZ"}="EST5EDT"; open (LOG, ">>$deposit_dir/.log"); open (FILE, ">$deposit_dir/$file") or die ("cant write to $deposit_dir/$file $!"); my $header=1; # if header == 1, we are in the header ; header == 0, body while (<>) { print LOG; # log everything, trust noone! if (/^Subject:(.*)/ and $header==1) { $action = $1 || "undef"; } $header=0 if /^$/; # skip header next unless $header==0; # skip header print FILE; } close (FILE); chmod 0644, "$deposit_dir/$file"; if ($action =~ /delete(.*)/) { my $filenum = $1; chomp $filenum; exit 1 unless $filenum =~ /^\.[\.0-9]+.txt$/; # stop any nefarious dir tree traversing and other shenanigans rename ("$deposit_dir/$filenum", "$deposit_dir/.a$filenum") if -f "$deposit_dir/$filenum"; unlink ("$deposit_dir/$file"); } build_daily(); exit 0; sub build_daily { # read dir opendir (DIR, "$deposit_dir") or die ("cant read dir $deposit_dir $!"); @files = grep /^\.[0-9].*\.txt$/, readdir DIR; closedir (DIR); @files = sort {$b cmp $a } (@files); # show only the last 10 days # @files = $files[0..9]; # oop, didn't work. # write index.html open (INDEX, ">$deposit_dir/.$file.index.html") or die ("Can't write temp index.html $!"); # header print INDEX ("\n
\n\n\n\n"); open (MENU, "/home/public/dog-slow.org/.menu") or die; while (