X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=src%2Fdownload.php;h=6a24ce183e72b1b4f4796def32fcb7b7d8a94efd;hb=e4c6fe416876dabfcddf636bb7dd8af11cd064a6;hp=f6235fab658b2418a3e32700ae317b541c09aebe;hpb=97d7da3b6fde0d4a8e8a392fdc3c24ee2b7f8293;p=squirrelmail.git diff --git a/src/download.php b/src/download.php index f6235fab..6a24ce18 100644 --- a/src/download.php +++ b/src/download.php @@ -16,75 +16,148 @@ require_once('../src/validate.php'); require_once('../functions/imap.php'); require_once('../functions/mime.php'); require_once('../functions/date.php'); +require_once('../functions/html.php'); header('Pragma: '); header('Cache-Control: cache'); -function viewText($color, $body, $id, $entid, $mailbox, $type1, $wrap_at) { +function viewText($color, $body, $id, $entid, $mailbox, $type1, $wrap_at, $imapConnection) { global $where, $what, $charset; global $startMessage; displayPageHeader($color, 'None'); - echo "
". - "
". - _("Viewing a text attachment") . " - "; if ($where && $what) { // from a search - echo "". _("View message") . ""; + $message_link_str = "". _("View message") . ""; } else { - echo "". _("View message") . ""; + $message_link_str = "". _("View message") . ""; } - $urlmailbox = urlencode($mailbox); - echo "
". - _("Download this as a file"). - "

". - "". - "
". - "
". - "
"; + + echo '
' . + html_tag( 'table', + html_tag( 'tr', + html_tag( 'td', + '
' . + _("Viewing a text attachment") . ' - ' . $message_link_str . '
', + 'left', $color[0] ) + ) . + html_tag( 'tr', + html_tag( 'td', + '
' . + "". + _("Download this as a file"). + "

", + 'left' ) + ), + 'center', '', 'width="100%" border="0" cellspacing="0" cellpadding="2"' ); if ($type1 == 'html') { - $body = MagicHTML( $body, $id ); + $msg = sqimap_get_message($imapConnection, $id, $mailbox); + $body = MagicHTML( $body, $id, $msg ); } else { translateText($body, $wrap_at, $charset); } flush(); - echo $body . - "
"; + + html_tag( 'table', + html_tag( 'tr', + html_tag( 'td', '' . $body . '', 'left', $color[4] ) + ) , + 'center', '', 'width="98%" border="0" cellspacing="0" cellpadding="2"' ); } -function viewMessage($imapConnection, $id, $mailbox, $ent_id, $msg, $color, $wrap_at) { +function viewMessage($imapConnection, $id, $mailbox, $ent_id, $color, $wrap_at, $extracted) { global $startMessage; + + + $msg = sqimap_get_message($imapConnection, $id, $mailbox); + $msg = getEntity($msg, $ent_id); + $header = sqimap_get_ent_header($imapConnection,$id,$mailbox,$ent_id); + $header->id = $id; $msg->header = $header; - $msg->header->id = $id; - $body = formatBody($imapConnection, $msg, $color, $wrap_at); - $bodyheader = viewHeader($header, $color); + $ent_ar = findDisplayEntity($msg, 0); + $body = ''; + for ($i = 0; $i < count($ent_ar); $i++) { + $body .= formatBody($imapConnection, $msg, $color, $wrap_at, $ent_ar[$i], false); + } + + $bodyheader = viewHeader($header, $color); displayPageHeader($color, 'None'); - echo "
". - "
". _("Viewing a message attachment") . " - "; - - echo "". _("View message") . ""; - + echo '
' . + html_tag( 'table', '', 'center', '', 'width="100%" border="0" cellspacing="0" cellpadding="2"' ); + + if ($extracted) { + echo html_tag( 'tr', + html_tag( 'td', '

Message succesfully extracted

', 'left', '', 'width="100%"' ) + ); + } + + $td_str = "
". _("Viewing a message attachment") . " - "; + $td_str .= "". _("View message") . "
"; + echo html_tag( 'tr', + html_tag( 'td', $td_str, 'left', $color[0] ) + ); + $urlmailbox = urlencode($mailbox); - - echo "
". + $td_str = "
". _("Download this as a file"). - "

". - "
". - "
"; - echo "
". - "
"; - echo "$bodyheader
"; - - echo "
". - "
"; - echo "$body
"; + "
". + ""; + echo html_tag( 'tr', + html_tag( 'td', $td_str, 'left' ) + ) . + + "\n" . + html_tag( 'table', + html_tag( 'tr', + html_tag( 'td', $bodyheader, 'left', $color[4] ) + ) , + 'center', '', 'width="100%" border="0" cellspacing="0" cellpadding="2"' ) . "\n" . + html_tag( 'table', + html_tag( 'tr', + html_tag( 'td', '
' . $body . '
', 'left', $color[4] ) + ) , + 'center', '', 'width="98%" border="0" cellspacing="0" cellpadding="2"' ) . "
\n"; + + echo html_tag( 'table', '', '', '', 'width="100%"' ) . + html_tag( 'tr' ) . + html_tag( 'td', '', 'center', $color[9], 'width="100%"' ) . + '
'. + "". + "". + "". + "". + "". + _("Save to:") . + ' '.' '. + ''. + ''. + '
'. + ''; + +} + +function get_extract_to_target_list($imapConnection) { + + $boxes = sqimap_mailbox_list($imapConnection); + for ($i = 0; $i < count($boxes); $i++) { + if (!in_array('noselect', $boxes[$i]['flags'])) { + $box = $boxes[$i]['unformatted']; + $box2 = str_replace(' ', ' ', $boxes[$i]['unformatted-disp']); + if ( $box2 == 'INBOX' ) { + $box2 = _("INBOX"); + } + echo "\n"; + } + } } @@ -136,8 +209,10 @@ function viewHeader($header,$color) { } function makeTableEntry($str, $str_name, $color) { - $entry = ''."$str_name".''."$str".' '."\n"; + $entry = html_tag( 'tr', + html_tag( 'td', $str_name, 'right', $color[0], 'valign="top"' ) . + html_tag( 'td', '' . $str .' ', 'left', $color[0], 'valign="top" colspan="2"' ) + ); return $entry; } @@ -236,22 +311,37 @@ function formatRecipientString($recipients, $item ) { $imapConnection = sqimap_login($username, $key, $imapServerAddress, $imapPort, 0); sqimap_mailbox_select($imapConnection, $mailbox); -/* - * $message contains all information about the message - * including header and body - */ -$message = sqimap_get_message($imapConnection, $passed_id, $mailbox); - -$top_header = $message->header; - +$extracted = false; +if (isset($extract_message) && $extract_message) { + $cmd = "FETCH $passed_id BODY[$passed_ent_id]"; + $read = sqimap_run_command ($imapConnection, $cmd, true, $response, $message); + $cnt = count($read); + $body = ''; + $length = 0; + for ($i=1;$i<$cnt;$i++) { + $length = $length + strlen($read[$i]); + $body .= $read[$i]; + } + if (isset($targetMailbox) && $length>0) { + sqimap_append ($imapConnection, $targetMailbox, $length); + fputs($imapConnection,$body); + sqimap_append_done ($imapConnection); + $extracted = true; + } +} + +if (isset($showHeaders)) { + $top_header = sqimap_get_message_header ($imapConnection, $passed_id, $mailbox); +} /* * lets redefine message as this particular entity that we wish to display. * it should hold only the header for this entity. We need to fetch the body * yet before we can display anything. */ -$message = getEntity($message, $passed_ent_id); -$header = $message->header; +$header = sqimap_get_mime_ent_header ($imapConnection, $passed_id, $mailbox, $passed_ent_id); +$header->entity_id = $passed_ent_id; +$header->mailbox = $mailbox; $charset = $header->charset; $type0 = $header->type0; @@ -311,15 +401,18 @@ if (isset($absolute_dl) && $absolute_dl == 'true') { " " . _("To") . ": " . decodeHeader(getLineOfAddrs($top_header->to)) . "\n". " " . _("Date") . ": " . getLongDateString($top_header->date) . "\n\n"; } elseif ($type1 == 'html' && isset($showHeaders)) { - echo '\n\n\n\n
' . _("Subject"). - ':' . decodeHeader($top_header->subject). - "
" . _("From"). - ':' . decodeHeader($top_header->from). - "
" . _("To"). - ':' . decodeHeader(getLineOfAddrs($top_header->to)). - "
" . _("Date"). - ':' . getLongDateString($top_header->date). - "
\n
\n"; + echo html_tag( 'table', + html_tag( 'tr', + html_tag( 'th', _("Subject") . ':', 'right' ) . + html_tag( 'th', decodeHeader($top_header->subject), 'left' ) . "\n" . + html_tag( 'th', _("From") . ':', 'right' ) . + html_tag( 'th', decodeHeader($top_header->from), 'left' ) . "\n" . + html_tag( 'th', _("To") . ':', 'right' ) . + html_tag( 'th', decodeHeader(getLineOfAddrs($top_header->to)), 'left' ) . "\n" . + html_tag( 'th', _("Date") . ':', 'right' ) . + html_tag( 'th', getLongDateString($top_header->date), 'left' ) . "\n" + ) + ) . "\n
\n"; } echo $body; break; @@ -335,7 +428,7 @@ if (isset($absolute_dl) && $absolute_dl == 'true') { if ($type1 == 'plain' || $type1 == 'html') { $body = mime_fetch_body($imapConnection, $passed_id, $passed_ent_id); $body = decodeBody($body, $header->encoding); - viewText($color, $body, $passed_id, $passed_ent_id, $mailbox, $type1, $wrap_at); + viewText($color, $body, $passed_id, $passed_ent_id, $mailbox, $type1, $wrap_at, $imapConnection); } else { DumpHeaders($type0, $type1, $filename, 0); $body = mime_fetch_body($imapConnection, $passed_id, $passed_ent_id); @@ -345,11 +438,11 @@ if (isset($absolute_dl) && $absolute_dl == 'true') { break; case 'message': if ($type1 == 'rfc822' ) { - viewMessage($imapConnection, $passed_id, $mailbox, $passed_ent_id, $message, $color, $wrap_at); + viewMessage($imapConnection, $passed_id, $mailbox, $passed_ent_id, $color, $wrap_at, $extracted); } else { $body = mime_fetch_body($imapConnection, $passed_id, $passed_ent_id); $body = decodeBody($body, $msgheader->encoding); - viewText($color, $body, $passed_id, $passed_ent_id, $mailbox, $type1, $wrap_at); + viewText($color, $body, $passed_id, $passed_ent_id, $mailbox, $type1, $wrap_at, $imapConnection); } break; default: