Fixed untranslated string
[squirrelmail.git] / src / view_html.php
CommitLineData
f95115ff 1<?php
a2b193bc 2
f95115ff 3/**
ebd2391c 4 * view_html
f95115ff 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 *
ae5dddc0 13 * @copyright 1999-2011 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
ebd2391c 19/** This is the view_html page */
20define('PAGE_NAME', 'view_html');
21
f95115ff 22/**
202bcbcc 23 * Include the SquirrelMail initialization file.
f95115ff 24 */
202bcbcc 25require('../include/init.php');
f95115ff 26
27/** SquirrelMail required files. */
202bcbcc 28require_once(SM_PATH . 'functions/imap.php');
29require_once(SM_PATH . 'functions/mime.php');
30require_once(SM_PATH . 'functions/date.php');
f95115ff 31
32/** Get globals */
f95115ff 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);
51bbe8fa 37sqgetGlobalVar('passed_id', $passed_id, SQ_GET, NULL, SQ_TYPE_BIGINT);
f95115ff 38
f95115ff 39// TODO: add required var checks here.
40
906f7e9f 41$imap_stream = sqimap_login($username, false, $imapServerAddress, $imapPort, 0);
f95115ff 42$mbx_response = sqimap_mailbox_select($imap_stream, $mailbox);
43
44$message = &$messages[$mbx_response['UIDVALIDITY']][$passed_id];
45if (!is_object($message)) {
46 $message = sqimap_get_message($imap_stream, $passed_id, $mailbox);
47}
4156e6f3 48$message_ent = $message->getEntity($ent_id);
f95115ff 49if ($passed_ent_id) {
4156e6f3 50 $message = $message->getEntity($passed_ent_id);
f95115ff 51}
52$header = $message_ent->header;
53$type0 = $header->type0;
54$type1 = $header->type1;
55$charset = $header->getParameter('charset');
56$encoding = strtolower($header->encoding);
57
58$body = mime_fetch_body($imap_stream, $passed_id, $ent_id);
59$body = decodeBody($body, $encoding);
6e515418 60do_hook('message_body', $body);
f95115ff 61
62/**
63 * TODO: check if xtra_code is needed.
64if (isset($languages[$squirrelmail_language]['XTRA_CODE']) &&
65 function_exists($languages[$squirrelmail_language]['XTRA_CODE'].'_decode')) {
66 if (mb_detect_encoding($body) != 'ASCII') {
67 $body = call_user_func($languages[$squirrelmail_language]['XTRA_CODE'] . '_decode', $body);
68 }
69}
70*/
71
72/** TODO: provide reduced version of MagicHTML() */
73$body = MagicHTML( $body, $passed_id, $message, $mailbox);
74
75/** TODO: charset might be part of html code. */
76header('Content-Type: text/html; charset=' . $charset);
77echo $body;