f95115ff |
1 | <?php |
2 | /** |
3 | * $Source$ |
4 | * Displays html message parts |
5 | * |
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). |
11 | * |
12 | * Copyright (c) 1999-2005 The SquirrelMail Project Team |
13 | * This file is part of SquirrelMail webmail interface. |
14 | * |
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. |
19 | * |
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. |
24 | * |
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 |
28 | * |
29 | * @version $Id$ |
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% |
37 | * working. |
38 | */ |
39 | |
40 | /** |
41 | * Path for SquirrelMail required files. |
42 | * @ignore |
43 | */ |
44 | define('SM_PATH','../'); |
45 | |
46 | /** SquirrelMail required files. */ |
47 | require_once(SM_PATH . 'include/validate.php'); |
48 | include_once(SM_PATH . 'functions/imap.php'); |
49 | |
50 | /** Get globals */ |
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; |
60 | } |
61 | |
62 | global $view_unsafe_images; |
63 | if (sqgetGlobalVar('view_unsafe_images', $temp, SQ_GET)) { |
64 | $view_unsafe_images = (bool) $temp; |
65 | } else { |
66 | $view_unsafe_images = false; |
67 | } |
68 | |
69 | // TODO: add required var checks here. |
70 | |
71 | $imap_stream = sqimap_login($username, $key, $imapServerAddress, $imapPort, 0); |
72 | $mbx_response = sqimap_mailbox_select($imap_stream, $mailbox); |
73 | |
74 | $message = &$messages[$mbx_response['UIDVALIDITY']][$passed_id]; |
75 | if (!is_object($message)) { |
76 | $message = sqimap_get_message($imap_stream, $passed_id, $mailbox); |
77 | } |
78 | $message_ent = &$message->getEntity($ent_id); |
79 | if ($passed_ent_id) { |
80 | $message = &$message->getEntity($passed_ent_id); |
81 | } |
82 | $header = $message_ent->header; |
83 | $type0 = $header->type0; |
84 | $type1 = $header->type1; |
85 | $charset = $header->getParameter('charset'); |
86 | $encoding = strtolower($header->encoding); |
87 | |
88 | $body = mime_fetch_body($imap_stream, $passed_id, $ent_id); |
89 | $body = decodeBody($body, $encoding); |
90 | |
91 | /** |
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); |
97 | } |
98 | } |
99 | */ |
100 | |
101 | /** TODO: provide reduced version of MagicHTML() */ |
102 | $body = MagicHTML( $body, $passed_id, $message, $mailbox); |
103 | |
104 | /** TODO: charset might be part of html code. */ |
105 | header('Content-Type: text/html; charset=' . $charset); |
106 | echo $body; |
107 | ?> |