f95115ff |
1 | <?php |
a2b193bc |
2 | |
f95115ff |
3 | /** |
4 | * $Source$ |
5 | * Displays html message parts |
6 | * |
7 | * File is used to display html message parts. Usually inside iframe. |
f8a1ed5a |
8 | * It should be called with passed_id, ent_id and mailbox options in |
9 | * GET request. passed_ent_id and view_unsafe_images options are |
10 | * optional. User must be authenticated ($key in cookie. $username and |
f95115ff |
11 | * $onetimepad in session). |
f8a1ed5a |
12 | * |
4b5049de |
13 | * @copyright © 1999-2007 The SquirrelMail Project Team |
4b4abf93 |
14 | * @license http://opensource.org/licenses/gpl-license.php GNU Public License |
f95115ff |
15 | * @version $Id$ |
16 | * @package squirrelmail |
f95115ff |
17 | */ |
18 | |
19 | /** |
202bcbcc |
20 | * Include the SquirrelMail initialization file. |
f95115ff |
21 | */ |
202bcbcc |
22 | require('../include/init.php'); |
f95115ff |
23 | |
24 | /** SquirrelMail required files. */ |
202bcbcc |
25 | require_once(SM_PATH . 'functions/imap.php'); |
26 | require_once(SM_PATH . 'functions/mime.php'); |
27 | require_once(SM_PATH . 'functions/date.php'); |
f95115ff |
28 | |
29 | /** Get globals */ |
f95115ff |
30 | sqgetGlobalVar('messages', $messages, SQ_SESSION); |
31 | sqgetGlobalVar('mailbox', $mailbox, SQ_GET); |
32 | sqgetGlobalVar('ent_id', $ent_id, SQ_GET); |
33 | sqgetGlobalVar('passed_ent_id', $passed_ent_id, SQ_GET); |
34 | if (sqgetGlobalVar('passed_id', $temp, SQ_GET)) { |
35 | $passed_id = (int) $temp; |
36 | } |
37 | |
f95115ff |
38 | // TODO: add required var checks here. |
39 | |
906f7e9f |
40 | $imap_stream = sqimap_login($username, false, $imapServerAddress, $imapPort, 0); |
f95115ff |
41 | $mbx_response = sqimap_mailbox_select($imap_stream, $mailbox); |
42 | |
43 | $message = &$messages[$mbx_response['UIDVALIDITY']][$passed_id]; |
44 | if (!is_object($message)) { |
45 | $message = sqimap_get_message($imap_stream, $passed_id, $mailbox); |
46 | } |
4156e6f3 |
47 | $message_ent = $message->getEntity($ent_id); |
f95115ff |
48 | if ($passed_ent_id) { |
4156e6f3 |
49 | $message = $message->getEntity($passed_ent_id); |
f95115ff |
50 | } |
51 | $header = $message_ent->header; |
52 | $type0 = $header->type0; |
53 | $type1 = $header->type1; |
54 | $charset = $header->getParameter('charset'); |
55 | $encoding = strtolower($header->encoding); |
56 | |
57 | $body = mime_fetch_body($imap_stream, $passed_id, $ent_id); |
58 | $body = decodeBody($body, $encoding); |
6e515418 |
59 | do_hook('message_body', $body); |
f95115ff |
60 | |
61 | /** |
62 | * TODO: check if xtra_code is needed. |
63 | if (isset($languages[$squirrelmail_language]['XTRA_CODE']) && |
64 | function_exists($languages[$squirrelmail_language]['XTRA_CODE'].'_decode')) { |
65 | if (mb_detect_encoding($body) != 'ASCII') { |
66 | $body = call_user_func($languages[$squirrelmail_language]['XTRA_CODE'] . '_decode', $body); |
67 | } |
68 | } |
69 | */ |
70 | |
71 | /** TODO: provide reduced version of MagicHTML() */ |
72 | $body = MagicHTML( $body, $passed_id, $message, $mailbox); |
73 | |
74 | /** TODO: charset might be part of html code. */ |
75 | header('Content-Type: text/html; charset=' . $charset); |
76 | echo $body; |
906f7e9f |
77 | ?> |