| 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$ |
|---|
| 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 : $IMAP->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 = new rcube_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 | 'message' => 'Message UID '.$uid.' not found'), |
|---|
| 54 | true, |
|---|
| 55 | true); |
|---|
| 56 | } |
|---|
| 57 | |
|---|
| 58 | exit; |
|---|
| 59 | ?> |
|---|