X-Git-Url: https://defaria.com/gitweb/?a=blobdiff_plain;ds=inline;f=maps%2Fbin%2Fdisplay.cgi;h=0a0cfcd9ca38fbecc7ffff3232a7c942373d0fbd;hb=360bd6c4a68de2625d6d09b117bf7b6cffd6cb78;hp=1dbbd1ba8ce7d597ade131451d5269bb60ffab86;hpb=7ad5fd1a2d54b940018de904485ce560562af176;p=clearscm.git diff --git a/maps/bin/display.cgi b/maps/bin/display.cgi index 1dbbd1b..0a0cfcd 100755 --- a/maps/bin/display.cgi +++ b/maps/bin/display.cgi @@ -16,9 +16,10 @@ use strict; use warnings; use FindBin; -$0 = $FindBin::Script; +local $0 = $FindBin::Script; use lib "$FindBin::Bin/../lib"; +use lib "$FindBin::Bin/../../lib"; use MAPS; use MAPSWeb; @@ -30,10 +31,15 @@ use MIME::Parser; use MIME::Base64; use MIME::Words qw(:all); -my $userid = cookie('MAPSUser'); -my $sender = param('sender'); -my $msg_date = param('msg_date'); -my $table_name = 'message'; +my $userid = cookie('MAPSUser'); +my $sender = param('sender'); + +# CGI will replace '+' with ' ', which many mailers are starting to do, +# so add it back +$sender =~ s/ /\+/; + +my $msg_date = param('msg_date'); +my $table_name = 'message'; sub ParseEmail(@) { my (@header) = @_; @@ -68,15 +74,22 @@ sub Body($) { my ($date) = @_; # Find unique message using $date - my $handle = FindEmail $sender, $date; + my ($err, $msg) = FindEmail( + userid => $userid, + sender => $sender, + timestamp => $date, + ); - my ($userid, $sender, $subject, $timestamp, $message) = GetEmail $handle; + my $rec = GetEmail; my $parser = MIME::Parser->new(); + # For some strange reason MIME::Parser has started having some problems + # with writing out tmp files... $parser->output_to_core(1); + $parser->tmp_to_core(1); - my $entity = $parser->parse_data ($message); + my $entity = $parser->parse_data($rec->{data}); my %header = ParseEmail @{($entity->header)[0]}; @@ -88,7 +101,8 @@ sub Body($) { -cellpadding => 0, -width => "100%"}); print start_table ({-align => "center", - -bgcolor => "#d4d0c8", + -bgcolor => 'steelblue', + #-bgcolor => "#d4d0c8", -border => 0, -cellspacing => 2, -cellpadding => 2, @@ -98,7 +112,8 @@ sub Body($) { -border => 0, -cellspacing => 0, -cellpadding => 2, - -bgcolor => "#ece9d8", + -bgcolor => 'black', + #-bgcolor => "#ece9d8", -width => "100%"}) . "\n"; for (keys (%header)) { @@ -107,10 +122,12 @@ sub Body($) { my $str = decode_mimewords($header{$_}); print Tr ([ - th ({-align => "right", - -bgcolor => "#ece9d8", - -width => "8%"}, "$_:") . "\n" . - td ({-bgcolor => "white"}, $str) + th ({-align => 'right', + -bgcolor => 'steelblue', + -style => 'color: white', + #-bgcolor => "#ece9d8", + -width => "8%"}, ucfirst "$_:") . "\n" . + td ({-bgcolor => 'white'}, $str) ]); } # for @@ -118,8 +135,8 @@ sub Body($) { print ""; print end_table; - print start_table ({-align => "center", - -bgcolor => "black", + print start_table ({-align => 'center', + -bgcolor => 'steelblue', -border => 0, -cellspacing => 0, -cellpadding => 2, @@ -129,7 +146,7 @@ sub Body($) { -border => 0, -cellspacing => 0, -cellpadding => 2, - -bgcolor => "white", + -bgcolor => 'white', -width => "100%"}) . "\n"; print "
'; - $entity->print_body; + print $entity->print_body; print ''; } # if } else { @@ -155,9 +172,9 @@ sub Body($) { # There should be an easier way to get this but I couldn't find one. my $encoding = ${$subpart->{mail_inet_head}{mail_hdr_hash}{'Content-Transfer-Encoding'}[0]}; if ($encoding =~ /base64/) { - $subpart->bodyhandle->print(); + $subpart->bodyhandle->print; } else { - $subpart->print_body; + print $subpart->print_body; } # if last; } elsif ($subpart->mime_type eq 'multipart/related') { @@ -180,7 +197,7 @@ sub Body($) { $part->bodyhandle->print(); } else { print '
'; - $part->print_body; + print $part->print_body; print ''; } # if } # if @@ -204,6 +221,8 @@ $userid = Heading( $table_name, ); +$userid //= $ENV{USER}; + SetContext($userid); NavigationBar($userid);