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 | * |
f95115ff |
13 | * Copyright (c) 1999-2005 The SquirrelMail Project Team |
14 | * This file is part of SquirrelMail webmail interface. |
f8a1ed5a |
15 | * |
f95115ff |
16 | * SquirrelMail is free software; you can redistribute it and/or modify |
17 | * it under the terms of the GNU General Public License as published by |
18 | * the Free Software Foundation; either version 2 of the License, or |
19 | * (at your option) any later version. |
20 | * |
21 | * SquirrelMail is distributed in the hope that it will be useful, |
22 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
23 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
24 | * GNU General Public License for more details. |
25 | * |
26 | * You should have received a copy of the GNU General Public License |
27 | * along with SquirrelMail; if not, write to the Free Software |
28 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
29 | * |
30 | * @version $Id$ |
31 | * @package squirrelmail |
f95115ff |
32 | */ |
33 | |
34 | /** |
35 | * Path for SquirrelMail required files. |
36 | * @ignore |
37 | */ |
38 | define('SM_PATH','../'); |
39 | |
40 | /** SquirrelMail required files. */ |
41 | require_once(SM_PATH . 'include/validate.php'); |
42 | include_once(SM_PATH . 'functions/imap.php'); |
43 | |
44 | /** Get globals */ |
45 | sqgetGlobalVar('key', $key, SQ_COOKIE); |
46 | sqgetGlobalVar('username', $username, SQ_SESSION); |
47 | sqgetGlobalVar('onetimepad', $onetimepad, SQ_SESSION); |
48 | sqgetGlobalVar('messages', $messages, SQ_SESSION); |
49 | sqgetGlobalVar('mailbox', $mailbox, SQ_GET); |
50 | sqgetGlobalVar('ent_id', $ent_id, SQ_GET); |
51 | sqgetGlobalVar('passed_ent_id', $passed_ent_id, SQ_GET); |
52 | if (sqgetGlobalVar('passed_id', $temp, SQ_GET)) { |
53 | $passed_id = (int) $temp; |
54 | } |
55 | |
56 | global $view_unsafe_images; |
57 | if (sqgetGlobalVar('view_unsafe_images', $temp, SQ_GET)) { |
58 | $view_unsafe_images = (bool) $temp; |
59 | } else { |
60 | $view_unsafe_images = false; |
61 | } |
62 | |
63 | // TODO: add required var checks here. |
64 | |
65 | $imap_stream = sqimap_login($username, $key, $imapServerAddress, $imapPort, 0); |
66 | $mbx_response = sqimap_mailbox_select($imap_stream, $mailbox); |
67 | |
68 | $message = &$messages[$mbx_response['UIDVALIDITY']][$passed_id]; |
69 | if (!is_object($message)) { |
70 | $message = sqimap_get_message($imap_stream, $passed_id, $mailbox); |
71 | } |
72 | $message_ent = &$message->getEntity($ent_id); |
73 | if ($passed_ent_id) { |
74 | $message = &$message->getEntity($passed_ent_id); |
75 | } |
76 | $header = $message_ent->header; |
77 | $type0 = $header->type0; |
78 | $type1 = $header->type1; |
79 | $charset = $header->getParameter('charset'); |
80 | $encoding = strtolower($header->encoding); |
81 | |
82 | $body = mime_fetch_body($imap_stream, $passed_id, $ent_id); |
83 | $body = decodeBody($body, $encoding); |
84 | |
85 | /** |
86 | * TODO: check if xtra_code is needed. |
87 | if (isset($languages[$squirrelmail_language]['XTRA_CODE']) && |
88 | function_exists($languages[$squirrelmail_language]['XTRA_CODE'].'_decode')) { |
89 | if (mb_detect_encoding($body) != 'ASCII') { |
90 | $body = call_user_func($languages[$squirrelmail_language]['XTRA_CODE'] . '_decode', $body); |
91 | } |
92 | } |
93 | */ |
94 | |
95 | /** TODO: provide reduced version of MagicHTML() */ |
96 | $body = MagicHTML( $body, $passed_id, $message, $mailbox); |
97 | |
98 | /** TODO: charset might be part of html code. */ |
99 | header('Content-Type: text/html; charset=' . $charset); |
100 | echo $body; |
a2b193bc |
101 | |
f95115ff |
102 | ?> |