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
34 * Path for SquirrelMail required files.
37 define('SM_PATH','../');
39 /** SquirrelMail required files. */
40 require_once(SM_PATH
. 'include/validate.php');
41 include_once(SM_PATH
. 'functions/imap.php');
44 sqgetGlobalVar('key', $key, SQ_COOKIE
);
45 sqgetGlobalVar('username', $username, SQ_SESSION
);
46 sqgetGlobalVar('onetimepad', $onetimepad, SQ_SESSION
);
47 sqgetGlobalVar('messages', $messages, SQ_SESSION
);
48 sqgetGlobalVar('mailbox', $mailbox, SQ_GET
);
49 sqgetGlobalVar('ent_id', $ent_id, SQ_GET
);
50 sqgetGlobalVar('passed_ent_id', $passed_ent_id, SQ_GET
);
51 if (sqgetGlobalVar('passed_id', $temp, SQ_GET
)) {
52 $passed_id = (int) $temp;
55 global $view_unsafe_images;
56 if (sqgetGlobalVar('view_unsafe_images', $temp, SQ_GET
)) {
57 $view_unsafe_images = (bool) $temp;
59 $view_unsafe_images = false;
62 // TODO: add required var checks here.
64 $imap_stream = sqimap_login($username, $key, $imapServerAddress, $imapPort, 0);
65 $mbx_response = sqimap_mailbox_select($imap_stream, $mailbox);
67 $message = &$messages[$mbx_response['UIDVALIDITY']][$passed_id];
68 if (!is_object($message)) {
69 $message = sqimap_get_message($imap_stream, $passed_id, $mailbox);
71 $message_ent = &$message->getEntity($ent_id);
73 $message = &$message->getEntity($passed_ent_id);
75 $header = $message_ent->header
;
76 $type0 = $header->type0
;
77 $type1 = $header->type1
;
78 $charset = $header->getParameter('charset');
79 $encoding = strtolower($header->encoding
);
81 $body = mime_fetch_body($imap_stream, $passed_id, $ent_id);
82 $body = decodeBody($body, $encoding);
85 * TODO: check if xtra_code is needed.
86 if (isset($languages[$squirrelmail_language]['XTRA_CODE']) &&
87 function_exists($languages[$squirrelmail_language]['XTRA_CODE'].'_decode')) {
88 if (mb_detect_encoding($body) != 'ASCII') {
89 $body = call_user_func($languages[$squirrelmail_language]['XTRA_CODE'] . '_decode', $body);
94 /** TODO: provide reduced version of MagicHTML() */
95 $body = MagicHTML( $body, $passed_id, $message, $mailbox);
97 /** TODO: charset might be part of html code. */
98 header('Content-Type: text/html; charset=' . $charset);