From: stekkel Date: Mon, 19 Aug 2002 14:29:33 +0000 (+0000) Subject: download related fixes X-Git-Url: https://vcs.fsf.org/?p=squirrelmail.git;a=commitdiff_plain;h=ff9d4297a3132d46982095ded7975c2bf8d6694b download related fixes git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@3365 7612ce4b-ef26-0410-bec9-ea0150e637f0 --- diff --git a/functions/attachment_common.php b/functions/attachment_common.php index 939648fc..a6251442 100644 --- a/functions/attachment_common.php +++ b/functions/attachment_common.php @@ -115,7 +115,6 @@ function attachment_common_link_text(&$Args) $Args[6] = $Args[1]['attachment_common']['href']; } - function attachment_common_link_message(&$Args) { $Args[1]['attachment_common']['href'] = '../src/read_body.php?startMessage=' . @@ -145,7 +144,6 @@ function attachment_common_link_html(&$Args) $Args[6] = $Args[1]['attachment_common']['href']; } - function attachment_common_link_image(&$Args) { global $attachment_common_show_images, $attachment_common_show_images_list; @@ -156,14 +154,11 @@ function attachment_common_link_image(&$Args) $attachment_common_show_images_list[] = $info; - $Args[1]['attachment_common']['href'] = '../src/image.php?startMessage=' . - $Args[2] . '&passed_id=' . $Args[3] . '&mailbox=' . $Args[4] . - '&passed_ent_id=' . $Args[5]; - - if ($Args[8] && $Args[9]) { - $Args[1]['attachment_common']['href'] .= '&where=' . - urlencode($Args[8]) . '&what=' . urlencode($Args[9]); - } + global $QUERY_STRING; + $Args[1]['attachment_common']['href'] = '../src/image.php?'. $QUERY_STRING; + $Args[1]['attachment_common']['href'] = + set_url_var($Args[1]['attachment_common']['href'], + 'ent_id',$Args[5]); $Args[1]['attachment_common']['text'] = _("view"); @@ -174,13 +169,11 @@ function attachment_common_link_image(&$Args) function attachment_common_link_vcard(&$Args) { - $Args[1]['attachment_common']['href'] = '../src/vcard.php?startMessage=' . - $Args[2] . '&passed_id=' . $Args[3] . '&mailbox=' . $Args[4] . - '&passed_ent_id=' . $Args[5]; - - if (isset($where) && isset($what)) - $Args[1]['attachment_common']['href'] .= '&where=' . - urlencode($Args[8]) . '&what=' . urlencode($Args[9]); + global $QUERY_STRING; + $Args[1]['attachment_common']['href'] = '../src/vcard.php?'. $QUERY_STRING; + $Args[1]['attachment_common']['href'] = + set_url_var($Args[1]['attachment_common']['href'], + 'ent_id',$Args[5]); $Args[1]['attachment_common']['text'] = _("Business Card"); diff --git a/functions/mime.php b/functions/mime.php index f07d5760..ac3b222a 100644 --- a/functions/mime.php +++ b/functions/mime.php @@ -393,7 +393,7 @@ function formatAttachments($message, $exclude_id, $mailbox, $id) { $name = ''; $Links['download link']['text'] = _("download"); $Links['download link']['href'] = - "../src/download.php?absolute_dl=true&passed_id=$id&mailbox=$urlMailbox&passed_ent_id=$ent"; + "../src/download.php?absolute_dl=true&passed_id=$id&mailbox=$urlMailbox&ent_id=$ent"; $ImageURL = ''; if ($type0 =='message' && $type1 == 'rfc822') { $default_page = '../src/read_body.php'; @@ -438,9 +438,14 @@ function formatAttachments($message, $exclude_id, $mailbox, $id) { } $display_filename = $filename; + if (isset($passed_ent_id)) { + $passed_ent_id_link = '&passed_ent_id='.$passed_ent_id; + } else { + $passed_ent_id_link = ''; + } $DefaultLink = $default_page . "?startMessage=$startMessage" . "&passed_id=$id&mailbox=$urlMailbox" - . "&passed_ent_id=$ent"; + . '&ent_id='.$ent.$passed_ent_id_link; if ($where && $what) { $DefaultLink = '&where='. urlencode($where).'&what='.urlencode($what); } diff --git a/src/download.php b/src/download.php index 8242da6f..899aacaf 100644 --- a/src/download.php +++ b/src/download.php @@ -43,10 +43,16 @@ if (!isset($passed_ent_id)) { } $message = &$messages[$mbx_response['UIDVALIDITY']]["$passed_id"]; -$message = &$message->getEntity($passed_ent_id); - +$subject = $message->rfc822_header->subject; +$message = &$message->getEntity($ent_id); $header = $message->header; -$charset = $header->getParameter('charset'); +if ($message->rfc822_header) { + $subject = $message->rfc822_header->subject; + $charset = $header->content_type->properties['charset']; +} else { + $header = $message->header; + $charset = $header->getParameter('charset'); +} $type0 = $header->type0; $type1 = $header->type1; $encoding = strtolower($header->encoding); @@ -85,34 +91,34 @@ if (isset($override_type0)) { if (isset($override_type1)) { $type1 = $override_type1; } - -$filename = decodeHeader($message->header->getParameter('filename')); - -if (!$filename) { - $filename = decodeHeader($message->header->getParameter('name')); +$filename = ''; +if (is_object($message->header->disposition)) { + $filename = decodeHeader($header->disposition->getProperty('filename')); + if (!$filename) { + $filename = decodeHeader($header->disposition->getProperty('name')); + } } - if (strlen($filename) < 1) { if ($type1 == 'plain' && $type0 == 'text') { $suffix = 'txt'; - $filename = $header->subject . '.txt'; + $filename = $subject . '.txt'; } else if ($type1 == 'richtext' && $type0 == 'text') { $suffix = 'rtf'; - $filename = $header->subject . '.rtf'; + $filename = $subject . '.rtf'; } else if ($type1 == 'postscript' && $type0 == 'application') { $suffix = 'ps'; - $filename = $header->subject . '.ps'; + $filename = $subject . '.ps'; } else if ($type1 == 'rfc822' && $type0 == 'message') { $suffix = 'eml'; - $filename = $header->subject . '.msg'; + $filename = $subject . '.msg'; } else { $suffix = $type1; } if (strlen($filename) < 1) { - $filename = "untitled$passed_ent_id.$suffix"; + $filename = "untitled$ent_id.$suffix"; } else { - $filename = "$filename.$suffix"; + $filename = "$filename.$suffix"; } } @@ -138,12 +144,11 @@ if (isset($absolute_dl) && $absolute_dl == 'true') { } /* be aware that any warning caused by download.php will corrupt the * attachment in case of ERROR reporting = E_ALL and the output is the screen */ -mime_print_body_lines ($imapConnection, $passed_id, $passed_ent_id, $encoding); +mime_print_body_lines ($imapConnection, $passed_id, $ent_id, $encoding); -/* $message = &$message->getEntity(''); $messages[$mbx_response['UIDVALIDITY']]["$passed_id"] = &$message; -*/ + /* * This function is verified to work with Netscape and the *very latest* * version of IE. I don't know if it works with Opera, but it should now. diff --git a/src/image.php b/src/image.php index 559ad12f..776549db 100644 --- a/src/image.php +++ b/src/image.php @@ -14,50 +14,38 @@ require_once('../src/validate.php'); require_once('../functions/date.php'); require_once('../functions/page_header.php'); -require_once('../src/load_prefs.php'); require_once('../functions/html.php'); +require_once('../src/load_prefs.php'); displayPageHeader($color, 'None'); -if (isset($where) && isset($what)) { - // from a search - $ViewMessageLink = '' . _("View message") . ''; -} else { - $ViewMessageLink = '' . _("View message") . ''; -} +echo '
' . + '' . + "\n" . + '' . "\n" . + '
' . + '
' . + _("Viewing an image attachment") . " - "; + +$msg_url = 'read_body.php?' . $QUERY_STRING; +$msg_url = set_url_var($msg_url, 'ent_id', 0); +echo ''. _("View message") . ''; + $DownloadLink = '../src/download.php?passed_id=' . $passed_id . '&mailbox=' . urlencode($mailbox) . - '&passed_ent_id=' . $passed_ent_id . '&absolute_dl=true'; - -echo '
' . - html_tag( 'table', - html_tag( 'tr', - html_tag( 'td', - '' . - _("Viewing an image attachment") . ' - ' . - $ViewMessageLink . '' , - 'center', $color[0] ) - ) . - html_tag( 'tr', - html_tag( 'td', - '' . - _("Download this as a file") . - '
 ' . "\n" , - 'center' ) - ) , - 'center', '', 'border="0" width="100%" cellspacing="0" cellpadding="2"' ) . - - html_tag( 'table', - html_tag( 'tr', - html_tag( 'td', - '' - , 'left', $color[4] ) - ) - , 'center', '', 'border="0" cellspacing="0" cellpadding="2"' ); + '&ent_id=' . $ent_id . '&absolute_dl=true'; + +echo '
' . + _("Download this as a file") . + '
 ' . "\n" . + '
' . "\n" . + + '' . "\n" . + '
' . + '' . + + '
' . "\n"; + '' . "\n"; ?> diff --git a/src/read_body.php b/src/read_body.php index 9ffb30e5..3f6b132d 100644 --- a/src/read_body.php +++ b/src/read_body.php @@ -485,9 +485,9 @@ function formatMenubar($mailbox, $passed_id, $passed_ent_id, $message, $mbx_resp $comp_action_uri = $comp_uri . '&action=forward_as_attachment'; if ($compose_new_win == '1') { $s .= ''._("Forward as Attachment").''; + 'onclick="comp_in_new(\''.$comp_action_uri.'\')">'._("Forward as attachment").''; } else { - $s .= ''._("Forward as Attachment").''; + $s .= ''._("Forward as attachment").''; } $s .= $topbar_delimiter; @@ -586,6 +586,9 @@ $messages[$uidvalidity][$passed_id] = $message; if (isset($passed_ent_id) && $passed_ent_id) { $message = $message->getEntity($passed_ent_id); + if ($message->type0 != 'message' && $message->type1 != 'rfc822') { + $message = $message->parent; + } $read = sqimap_run_command ($imapConnection, "FETCH $passed_id BODY[$passed_ent_id.HEADER]", true, $response, $msg, $uid_support); $rfc822_header = new rfc822_header(); $rfc822_header->parseHeader($read); @@ -681,7 +684,7 @@ if (($attachment_common_show_images) && '?' . 'passed_id=' . urlencode($img['passed_id']) . '&mailbox=' . urlencode($mailbox) . - '&passed_ent_id=' . urlencode($img['ent_id']) . + '&ent_id=' . urlencode($img['ent_id']) . '&absolute_dl=true'; echo html_tag( 'table', "\n" .