Adding template for error box.
[squirrelmail.git] / src / view_html.php
CommitLineData
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 *
47ccfad4 13 * @copyright &copy; 1999-2006 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/**
20 * Path for SquirrelMail required files.
21 * @ignore
22 */
23define('SM_PATH','../');
24
25/** SquirrelMail required files. */
5c4ff7bf 26include_once(SM_PATH . 'include/validate.php');
f95115ff 27include_once(SM_PATH . 'functions/imap.php');
28
29/** Get globals */
30sqgetGlobalVar('key', $key, SQ_COOKIE);
31sqgetGlobalVar('username', $username, SQ_SESSION);
32sqgetGlobalVar('onetimepad', $onetimepad, SQ_SESSION);
33sqgetGlobalVar('messages', $messages, SQ_SESSION);
34sqgetGlobalVar('mailbox', $mailbox, SQ_GET);
35sqgetGlobalVar('ent_id', $ent_id, SQ_GET);
36sqgetGlobalVar('passed_ent_id', $passed_ent_id, SQ_GET);
37if (sqgetGlobalVar('passed_id', $temp, SQ_GET)) {
38 $passed_id = (int) $temp;
39}
40
f95115ff 41// TODO: add required var checks here.
42
43$imap_stream = sqimap_login($username, $key, $imapServerAddress, $imapPort, 0);
44$mbx_response = sqimap_mailbox_select($imap_stream, $mailbox);
45
46$message = &$messages[$mbx_response['UIDVALIDITY']][$passed_id];
47if (!is_object($message)) {
48 $message = sqimap_get_message($imap_stream, $passed_id, $mailbox);
49}
4156e6f3 50$message_ent = $message->getEntity($ent_id);
f95115ff 51if ($passed_ent_id) {
4156e6f3 52 $message = $message->getEntity($passed_ent_id);
f95115ff 53}
54$header = $message_ent->header;
55$type0 = $header->type0;
56$type1 = $header->type1;
57$charset = $header->getParameter('charset');
58$encoding = strtolower($header->encoding);
59
60$body = mime_fetch_body($imap_stream, $passed_id, $ent_id);
61$body = decodeBody($body, $encoding);
f63fd5f0 62$hookResults = do_hook('message_body', $body);
63$body = $hookResults[1];
f95115ff 64
65/**
66 * TODO: check if xtra_code is needed.
67if (isset($languages[$squirrelmail_language]['XTRA_CODE']) &&
68 function_exists($languages[$squirrelmail_language]['XTRA_CODE'].'_decode')) {
69 if (mb_detect_encoding($body) != 'ASCII') {
70 $body = call_user_func($languages[$squirrelmail_language]['XTRA_CODE'] . '_decode', $body);
71 }
72}
73*/
74
75/** TODO: provide reduced version of MagicHTML() */
76$body = MagicHTML( $body, $passed_id, $message, $mailbox);
77
78/** TODO: charset might be part of html code. */
79header('Content-Type: text/html; charset=' . $charset);
80echo $body;
a2b193bc 81
f63fd5f0 82?>