source: github/program/steps/mail/get.inc @ d311d80

HEADcourier-fixdev-browser-capabilitiespdorelease-0.6release-0.7release-0.8
Last change on this file since d311d80 was d311d80, checked in by alecpl <alec@…>, 3 years ago
  • Fix forwarding of messages with winmail attachments
  • Remove some redundant code for winmail handling in get.inc, move tnef_decode() to rcube_message
  • Fix handling of uuencoded attachments in message body (#1485839)
  • Extend rc_mime_content_type() to work with string buffer
  • Property mode set to 100644
File size: 4.3 KB
Line 
1<?php
2
3/*
4 +-----------------------------------------------------------------------+
5 | program/steps/mail/get.inc                                            |
6 |                                                                       |
7 | This file is part of the RoundCube Webmail client                     |
8 | Copyright (C) 2005-2009, RoundCube Dev. - Switzerland                 |
9 | Licensed under the GNU GPL                                            |
10 |                                                                       |
11 | PURPOSE:                                                              |
12 |   Delivering a specific part of a mail message                        |
13 |                                                                       |
14 +-----------------------------------------------------------------------+
15 | Author: Thomas Bruederli <roundcube@gmail.com>                        |
16 +-----------------------------------------------------------------------+
17
18 $Id$
19
20*/
21
22
23// show loading page
24if (!empty($_GET['_preload'])) {
25  $url = str_replace('&_preload=1', '', $_SERVER['REQUEST_URI']);
26  $message = rcube_label('loadingdata');
27
28  header('Content-Type: text/html; charset=' . RCMAIL_CHARSET);
29  print "<html>\n<head>\n"
30        . '<meta http-equiv="refresh" content="0; url='.Q($url).'">' . "\n"
31        . '<meta http-equiv="content-type" content="text/html; charset='.RCMAIL_CHARSET.'">' . "\n"
32        . "</head>\n<body>\n$message\n</body>\n</html>";
33  exit;
34}
35
36ob_end_clean();
37
38// similar code as in program/steps/mail/show.inc
39if (!empty($_GET['_uid'])) {
40  $RCMAIL->config->set('prefer_html', true);
41  $MESSAGE = new rcube_message(get_input_value('_uid', RCUBE_INPUT_GET));
42}
43
44send_nocacheing_headers();
45
46// show part page
47if (!empty($_GET['_frame'])) {
48  $OUTPUT->send('messagepart');
49  exit;
50}
51
52else if ($pid = get_input_value('_part', RCUBE_INPUT_GET)) {
53
54  if ($part = $MESSAGE->mime_parts[$pid]) {
55    $ctype_primary = strtolower($part->ctype_primary);
56    $ctype_secondary = strtolower($part->ctype_secondary);
57    $mimetype = sprintf('%s/%s', $ctype_primary, $ctype_secondary);
58   
59    $browser = new rcube_browser;
60
61    // send download headers
62    if ($_GET['_download']) {
63      header("Content-Type: application/octet-stream");
64      if ($browser->ie)
65        header("Content-Type: application/force-download");
66    }
67    else if ($ctype_primary == 'text') {
68      header("Content-Type: text/$ctype_secondary; charset=" . ($part->charset ? $part->charset : RCMAIL_CHARSET));
69    }
70    else {
71      header("Content-Type: $mimetype");
72      header("Content-Transfer-Encoding: binary");
73    }
74
75    // deliver part content
76    if ($ctype_primary == 'text' && $ctype_secondary == 'html' && empty($_GET['_download'])) {
77      // get part body if not available
78      if (!$part->body)
79        $part->body = $MESSAGE->get_part_content($part->mime_id);
80
81      $OUTPUT = new rcube_html_page();
82      $OUTPUT->write(rcmail_print_body($part, array('safe' => $MESSAGE->is_safe, 'inline_html' => false)));
83    }
84    else {
85      // don't kill the connection if download takes more than 30 sec.
86      @set_time_limit(0);
87     
88      $filename = $part->filename ? $part->filename : ($MESSAGE->subject ? $MESSAGE->subject : 'roundcube') . '.'.$ctype_secondary;
89     
90      if ($browser->ie && $browser->ver < 7)
91        $filename = rawurlencode(abbreviate_string($filename, 55));
92      else if ($browser->ie)
93        $filename = rawurlencode($filename);
94      else
95        $filename = addcslashes($filename, '"');
96     
97      $disposition = !empty($_GET['_download']) ? 'attachment' : 'inline';
98     
99      header("Content-Disposition: $disposition; filename=\"$filename\"");
100     
101      // turn off output buffering and print part content
102      if ($part->body)
103        echo $part->body;
104      else if ($part->size)
105        $IMAP->get_message_part($MESSAGE->uid, $part->mime_id, $part, true);
106    }
107
108    exit;
109  }
110}
111
112// print message
113else {
114  // send correct headers for content type
115  header("Content-Type: text/html");
116
117  $cont = "<html>\n<head><title></title>\n</head>\n<body>";
118  $cont .= rcmail_message_body(array());
119  $cont .= "\n</body>\n</html>";
120
121  $OUTPUT = new rcube_html_page();
122  $OUTPUT->write($cont);
123
124  exit;
125}
126
127
128// if we arrive here, the requested part was not found
129header('HTTP/1.1 404 Not Found');
130exit;
131
132?>
Note: See TracBrowser for help on using the repository browser.