#!/usr/bin/perl use CGI; $cgi = new CGI; $url = $cgi->url(); print $cgi->header(); my $style= <<"EOT"; A { text-decoration: none; } A.visited { color: #0000ff; } TH { background: #AAAAAA; text-align: left; } .header { background: #CCCCCC; text-align: left; } .wd { background: #ffffff; text-align: left; } EOT my @localtime = localtime(); my ($month, $year, $prev_month, $prev_year, $next_month, $next_year); if (!($month = $cgi->param('month'))) { $month = "*"; } if (!($year = $cgi->param('year'))) { $year = 1900 + $localtime[5]; } if ($month == 1) { $next_month = $month + 1; $next_year = $year; $prev_month = 12; $prev_year = $year - 1; } elsif ($month == 12) { $next_month = 1; $next_year = $year + 1; $prev_month = ($month - 1); $prev_year = $year; } elsif ($month eq "*") { $next_month = $prev_month = 0; $next_year = $prev_year = 0; } else { $next_month = $month + 1; $next_year = $year; $prev_month = ($month - 1); $prev_year = $year; } $prev_month = sprintf("%02d", $prev_month); $next_month = sprintf("%02d", $next_month); @matches = glob ("$year/$month/*/*/index.html"); @match_list = reverse @matches; print $cgi->start_html( -title=>"Detach report for $year/$month"); print "\n"; print "\n"; my $last_month="0"; foreach $detach (@match_list) { my ($yr,$mon,$day,$key,$file) = split('/',$detach); my ($from, $subject, @detach_file_list); # Inject separator as necc. if ($mon != $last_month) { print "\n\n"; print "\n"; print "\n"; print "\n"; } $last_month = $mon; # Scrape the details out of the file. open(DETACH, "$detach"); while () { #next unless /^(Subj|
  • |)/; if ($_ =~ m/^/) { chomp; @from_list = split(/From: /, $_); $from = pop(@from_list); $from =~ s/(.*)\s<(.*)>/$1<\/A>/; } if ($_ =~ m/^Subj: (.*)/) { chomp; $subject = $1; } if ($_ =~ m/^
  • /) { push(@detach_file_list, $_); } } close(DETACH); # Print useful data print "
  • \n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; } print "
    Detachments for: "; if ($prev_month) { print "<<\n"; } print "$mon/$yr\n"; if ($next_month) { print ">>\n"; } print "\n"; for (01..12) { printf("%02d ", $_, $_); } print "
    Date:From:Subject:Files:
    X$mon/$day/$yr$from$subject@detach_file_list
    \n"; print $cgi->end_html();