$1\<\/a\>/g;
}
chdir $ARCHIVEROOT or die("couldn't chdir: $!");
my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time);
my @months = ("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December");
chmkdir $year + 1900;
chmkdir sprintf("%02d", $mon + 1);
my $fn; my $max = 0;
opendir DIR, "." or die ("can't opendir: $!");
foreach $fn (readdir(DIR)) {
if ($fn =~ /^([0-9]*)\.html$/i && ($max < $1)) {
$max = $1;
}
}
$fn = sprintf("%05u.html", $max + 1);
open HTML, ">$fn" or die ("couldn't create $fn: $!");
my $subj;
my ($from, $date);
my @headers;
my $havesubj = 0;
do {
$_ = <>; chomp;
fixup $_;
push @headers, $_;
if ($havesubj && /^\s/) {
s/^\s+/ /;
$subj .= $_;
} elsif (/^Subject: (.*)$/) {
$subj = $1;
$havesubj = 1;
} else {
$havesubj = 0;
if (/^From: (.*)$/i) {
$from = $1;
} elsif (/^Date: (.*)$/i) {
$date = $1;
}
}
} while ($_ ne "");
print HTML '
'.$subj.'
'.$subj.'
';
foreach (@headers) { print HTML "$_\n" }
while (<>) {
fixup $_;
print HTML $_;
}
print HTML "\n";
close HTML;
setperm $fn;
unless (-f $INDEX) {
my $title = $TITLE . $months[$mon] . " " . ($year + 1900);
open INDEX, ">$INDEX" or die ("can't create index.html: $!");
setperm $INDEX;
print INDEX '
'.$title.'
'.$title.'
'
} else {
open INDEX, ">>$INDEX" or die ("can't append to index.html: $!");
}
$subj = "(untitled message)" unless $subj;
print INDEX "- $subj from $from on $date\n";
close INDEX;