X-Git-Url: https://defaria.com/gitweb/?a=blobdiff_plain;ds=sidebyside;f=maps%2Fbin%2Fdisplay.cgi;h=0a0cfcd9ca38fbecc7ffff3232a7c942373d0fbd;hb=a9acda90df2ba4a4777fe263005a5d45ffd869e0;hp=02379e647fa3d72388e2ccca89abe1a4fee86b2a;hpb=b546b9bddc58099ce1c401e28f8039b3ba282b3e;p=clearscm.git diff --git a/maps/bin/display.cgi b/maps/bin/display.cgi index 02379e6..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,15 +31,15 @@ use MIME::Parser; use MIME::Base64; use MIME::Words qw(:all); -my $userid = cookie('MAPSUser'); -my $sender = param('sender'); +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_nbr = param('msg_nbr'); -my $table_name = 'message'; +my $msg_date = param('msg_date'); +my $table_name = 'message'; sub ParseEmail(@) { my (@header) = @_; @@ -70,24 +71,25 @@ sub ParseEmail(@) { } # ParseEmail sub Body($) { - my ($count) = @_; + my ($date) = @_; - $count ||= 1; + # Find unique message using $date + my ($err, $msg) = FindEmail( + userid => $userid, + sender => $sender, + timestamp => $date, + ); - my $handle = FindEmail $sender; - - my ($userid, $sender, $subject, $timestamp, $message); - - # Need to handle multiple messages - for (my $i = 0; $i < $count; $i++) { - ($userid, $sender, $subject, $timestamp, $message) = GetEmail $handle; - } # for + my $rec = GetEmail; my $parser = MIME::Parser->new(); - $parser->output_to_core (1); + # 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]}; @@ -99,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, @@ -109,28 +112,31 @@ sub Body($) { -border => 0, -cellspacing => 0, -cellpadding => 2, - -bgcolor => "#ece9d8", + -bgcolor => 'black', + #-bgcolor => "#ece9d8", -width => "100%"}) . "\n"; - foreach (keys (%header)) { + for (keys (%header)) { next if /base64/; - my $str = decode_mimewords ($header{$_}); + 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) ]); - } # if + } # for print end_table; print ""; print end_table; - print start_table ({-align => "center", - -bgcolor => "black", + print start_table ({-align => 'center', + -bgcolor => 'steelblue', -border => 0, -cellspacing => 0, -cellpadding => 2, @@ -140,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 { @@ -166,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') { @@ -179,7 +185,7 @@ sub Body($) { } # for } elsif ($part->mime_type eq 'multipart/related') { # Sometimes parts are 'multipart/relative'... - $part->print_body; + $part->print_body; } else { if ($part->mime_type =~ /text/) { my $encoding = ''; @@ -191,7 +197,7 @@ sub Body($) { $part->bodyhandle->print(); } else { print '
'; - $part->print_body; + print $part->print_body; print ''; } # if } # if @@ -215,9 +221,11 @@ $userid = Heading( $table_name, ); +$userid //= $ENV{USER}; + SetContext($userid); NavigationBar($userid); -Body($msg_nbr); +Body($msg_date); Footing($table_name);