]> git.donarmstrong.com Git - roundcube.git/blob - program/steps/mail/viewsource.inc
003438aae2cef1db46e698ac79238b2efab491c5
[roundcube.git] / program / steps / mail / viewsource.inc
1 <?php
2
3 /*
4  +-----------------------------------------------------------------------+
5  | program/steps/mail/viewsource.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  |   Display a mail message similar as a usual mail application does     |
13  |                                                                       |
14  +-----------------------------------------------------------------------+
15  | Author: Thomas Bruederli <roundcube@gmail.com>                        |
16  +-----------------------------------------------------------------------+
17
18  $Id: viewsource.inc 3989 2010-09-25 13:03:53Z alec $
19
20 */
21
22 ob_end_clean();
23
24 // similar code as in program/steps/mail/get.inc
25 if ($uid = get_input_value('_uid', RCUBE_INPUT_GET))
26 {
27   $headers = $IMAP->get_headers($uid);
28   $charset = $headers->charset ? $headers->charset : $CONFIG['default_charset'];
29   header("Content-Type: text/plain; charset={$charset}");
30
31   if (!empty($_GET['_save'])) {
32     $filename = ($headers->subject ? $IMAP->decode_header($headers->subject) : 'roundcube') . '.eml';
33     $browser = $RCMAIL->output->browser;
34
35     if ($browser->ie && $browser->ver < 7)
36       $filename = rawurlencode(abbreviate_string($filename, 55));
37     else if ($browser->ie)
38       $filename = rawurlencode($filename);
39     else
40       $filename = addcslashes($filename, '"');
41
42     header("Content-Length: {$headers->size}");
43     header("Content-Disposition: attachment; filename=\"$filename\"");
44   }
45
46   $IMAP->print_raw_body($uid);
47 }
48 else
49 {
50   raise_error(array(
51       'code' => 500,
52       'type' => 'php',
53       'file' => __FILE__, 'line' => __LINE__,
54       'message' => 'Message UID '.$uid.' not found'),
55     true, true);
56 }
57
58 exit;
59