moving main color tags to css
[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 *
4b4abf93 13 * @copyright &copy; 1999-2005 The SquirrelMail Project Team
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. */
26require_once(SM_PATH . 'include/validate.php');
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
41global $view_unsafe_images;
42if (sqgetGlobalVar('view_unsafe_images', $temp, SQ_GET)) {
43 $view_unsafe_images = (bool) $temp;
44} else {
45 $view_unsafe_images = false;
46}
47
48// TODO: add required var checks here.
49
50$imap_stream = sqimap_login($username, $key, $imapServerAddress, $imapPort, 0);
51$mbx_response = sqimap_mailbox_select($imap_stream, $mailbox);
52
53$message = &$messages[$mbx_response['UIDVALIDITY']][$passed_id];
54if (!is_object($message)) {
55 $message = sqimap_get_message($imap_stream, $passed_id, $mailbox);
56}
4156e6f3 57$message_ent = $message->getEntity($ent_id);
f95115ff 58if ($passed_ent_id) {
4156e6f3 59 $message = $message->getEntity($passed_ent_id);
f95115ff 60}
61$header = $message_ent->header;
62$type0 = $header->type0;
63$type1 = $header->type1;
64$charset = $header->getParameter('charset');
65$encoding = strtolower($header->encoding);
66
67$body = mime_fetch_body($imap_stream, $passed_id, $ent_id);
68$body = decodeBody($body, $encoding);
69
70/**
71 * TODO: check if xtra_code is needed.
72if (isset($languages[$squirrelmail_language]['XTRA_CODE']) &&
73 function_exists($languages[$squirrelmail_language]['XTRA_CODE'].'_decode')) {
74 if (mb_detect_encoding($body) != 'ASCII') {
75 $body = call_user_func($languages[$squirrelmail_language]['XTRA_CODE'] . '_decode', $body);
76 }
77}
78*/
79
80/** TODO: provide reduced version of MagicHTML() */
81$body = MagicHTML( $body, $passed_id, $message, $mailbox);
82
83/** TODO: charset might be part of html code. */
84header('Content-Type: text/html; charset=' . $charset);
85echo $body;
a2b193bc 86
4156e6f3 87?>