305e6a1fdf60a7db01e4419afae6624e33003f61
4 * Displays html message parts
6 * File is used to display html message parts. Usually inside iframe.
7 * It should be called with passed_id, ent_id and mailbox options in
8 * GET request. passed_ent_id and view_unsafe_images options are
9 * optional. User must be authenticated ($key in cookie. $username and
10 * $onetimepad in session).
12 * Copyright (c) 1999-2005 The SquirrelMail Project Team
13 * This file is part of SquirrelMail webmail interface.
15 * SquirrelMail is free software; you can redistribute it and/or modify
16 * it under the terms of the GNU General Public License as published by
17 * the Free Software Foundation; either version 2 of the License, or
18 * (at your option) any later version.
20 * SquirrelMail is distributed in the hope that it will be useful,
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 * GNU General Public License for more details.
25 * You should have received a copy of the GNU General Public License
26 * along with SquirrelMail; if not, write to the Free Software
27 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
30 * @package squirrelmail
31 * @todo Integrate it in formatBody() function after template stuff is
32 * in. original html display code has to be wrapped with iframe code.
33 * View Unsafe Images (target=iframe frame) and Download this as a file
34 * should be part of read_body page. Iframe code should be activated
35 * only for show_html_default=true
36 * @todo fix formating of read_body.php in order to get iframe width=100%
41 * Path for SquirrelMail required files.
44 define('SM_PATH','../');
46 /** SquirrelMail required files. */
47 require_once(SM_PATH
. 'include/validate.php');
48 include_once(SM_PATH
. 'functions/imap.php');
51 sqgetGlobalVar('key', $key, SQ_COOKIE
);
52 sqgetGlobalVar('username', $username, SQ_SESSION
);
53 sqgetGlobalVar('onetimepad', $onetimepad, SQ_SESSION
);
54 sqgetGlobalVar('messages', $messages, SQ_SESSION
);
55 sqgetGlobalVar('mailbox', $mailbox, SQ_GET
);
56 sqgetGlobalVar('ent_id', $ent_id, SQ_GET
);
57 sqgetGlobalVar('passed_ent_id', $passed_ent_id, SQ_GET
);
58 if (sqgetGlobalVar('passed_id', $temp, SQ_GET
)) {
59 $passed_id = (int) $temp;
62 global $view_unsafe_images;
63 if (sqgetGlobalVar('view_unsafe_images', $temp, SQ_GET
)) {
64 $view_unsafe_images = (bool) $temp;
66 $view_unsafe_images = false;
69 // TODO: add required var checks here.
71 $imap_stream = sqimap_login($username, $key, $imapServerAddress, $imapPort, 0);
72 $mbx_response = sqimap_mailbox_select($imap_stream, $mailbox);
74 $message = &$messages[$mbx_response['UIDVALIDITY']][$passed_id];
75 if (!is_object($message)) {
76 $message = sqimap_get_message($imap_stream, $passed_id, $mailbox);
78 $message_ent = &$message->getEntity($ent_id);
80 $message = &$message->getEntity($passed_ent_id);
82 $header = $message_ent->header
;
83 $type0 = $header->type0
;
84 $type1 = $header->type1
;
85 $charset = $header->getParameter('charset');
86 $encoding = strtolower($header->encoding
);
88 $body = mime_fetch_body($imap_stream, $passed_id, $ent_id);
89 $body = decodeBody($body, $encoding);
92 * TODO: check if xtra_code is needed.
93 if (isset($languages[$squirrelmail_language]['XTRA_CODE']) &&
94 function_exists($languages[$squirrelmail_language]['XTRA_CODE'].'_decode')) {
95 if (mb_detect_encoding($body) != 'ASCII') {
96 $body = call_user_func($languages[$squirrelmail_language]['XTRA_CODE'] . '_decode', $body);
101 /** TODO: provide reduced version of MagicHTML() */
102 $body = MagicHTML( $body, $passed_id, $message, $mailbox);
104 /** TODO: charset might be part of html code. */
105 header('Content-Type: text/html; charset=' . $charset);