4 +-----------------------------------------------------------------------+
5 | program/steps/mail/get.inc |
7 | This file is part of the RoundCube Webmail client |
8 | Copyright (C) 2005-2008, RoundCube Dev. - Switzerland |
9 | Licensed under the GNU GPL |
12 | Delivering a specific part of a mail message |
14 +-----------------------------------------------------------------------+
15 | Author: Thomas Bruederli <roundcube@gmail.com> |
16 +-----------------------------------------------------------------------+
18 $Id: get.inc 1400 2008-05-17 17:46:43Z thomasb $
22 require_once('Mail/mimeDecode.php');
26 if (!empty($_GET['_preload'])) {
27 $url = str_replace('&_preload=1', '', $_SERVER['REQUEST_URI']);
28 $message = rcube_label('loadingdata');
30 print "<html>\n<head>\n" .
31 '<meta http-equiv="refresh" content="0; url='.Q($url).'">' .
39 // similar code as in program/steps/mail/show.inc
40 if (!empty($_GET['_uid'])) {
41 $RCMAIL->config->set('prefer_html', true);
42 $MESSAGE = new rcube_message(get_input_value('_uid', RCUBE_INPUT_GET));
47 if (!empty($_GET['_frame'])) {
48 $OUTPUT->send('messagepart');
52 else if ($pid = get_input_value('_part', RCUBE_INPUT_GET)) {
53 if ($part = $MESSAGE->mime_parts[$pid]) {
54 $ctype_primary = strtolower($part->ctype_primary);
55 $ctype_secondary = strtolower($part->ctype_secondary);
56 $mimetype = sprintf('%s/%s', $ctype_primary, $ctype_secondary);
59 header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
60 header("Cache-Control: private", false);
61 header("Content-Transfer-Encoding: binary");
63 // send download headers
64 if ($_GET['_download']) {
65 header("Cache-Control: private", false);
66 header("Content-Type: application/octet-stream");
69 header("Content-Type: $mimetype");
71 // We need to set the following headers to make downloads work using IE in HTTPS mode.
72 if (isset($_SERVER['HTTPS'])) {
74 header('Cache-Control: ');
77 // deliver part content
78 if ($ctype_primary == 'text' && $ctype_secondary == 'html') {
79 // we have to analyze the whole structure again to find inline objects
80 /* what was this good for again ?
81 list($new_parts, $new_attachments) =
82 rcmail_parse_message($MESSAGE['structure'],
83 array('safe' => intval($_GET['_safe']),
84 'prefer_html' => TRUE,
85 'get_url' => $GET_URL.'&_part=%s'));
87 $all_parts = array_merge($new_parts, $new_attachments);
88 for ($partix = 0; $partix < sizeof($all_parts); $partix++)
89 if ($all_parts[$partix]->mime_id == $pid)
90 $part = &$all_parts[$partix];
93 // get part body if not available
95 $part->body = $MESSAGE->get_part_content($part->mime_id);
97 $OUTPUT = new rcube_html_page();
98 $OUTPUT->write(rcmail_print_body($part, $MESSAGE->is_safe));
101 header(sprintf('Content-Disposition: %s; filename="%s";',
102 $_GET['_download'] ? 'attachment' : 'inline',
103 $part->filename ? abbreviate_string($part->filename, 55) : "roundcube.$ctype_secondary"));
105 // turn off output buffering and print part content
106 $IMAP->get_message_part($MESSAGE->uid, $part->mime_id, $part, true);
115 // send correct headers for content type
116 header("Content-Type: text/html");
118 $cont = "<html>\n<head><title></title>\n</head>\n<body>";
119 $cont .= rcmail_message_body(array());
120 $cont .= "\n</body>\n</html>";
122 $OUTPUT = new rcube_html_page();
123 $OUTPUT->write($cont);
129 // if we arrive here, the requested part was not found
130 header('HTTP/1.1 404 Not Found');