Added Flag/Unflag buttons. I have been up for 2 days straight. Please check for...
[squirrelmail.git] / src / view_text.php
CommitLineData
facf44e7 1<?php
2
86725763 3/**
4 * view_text.php -- Displays the main frameset
5 *
82d304a0 6 * Copyright (c) 1999-2004 The SquirrelMail development team
86725763 7 * Licensed under the GNU GPL. For full terms see the file COPYING.
8 *
9 * Who knows what this file does. However PUT IT HERE DID NOT PUT
10 * A SINGLE FREAKING COMMENT IN! Whoever is responsible for this,
11 * be very ashamed.
12 *
13 * $Id$
8f6f9ba5 14 * @package squirrelmail
86725763 15 */
16
8f6f9ba5 17/** Path for SquirrelMail required files. */
86725763 18define('SM_PATH','../');
19
20/* SquirrelMail required files. */
08185f2a 21require_once(SM_PATH . 'include/validate.php');
1e12d1ff 22require_once(SM_PATH . 'functions/global.php');
86725763 23require_once(SM_PATH . 'functions/imap.php');
24require_once(SM_PATH . 'functions/mime.php');
25require_once(SM_PATH . 'functions/html.php');
1e12d1ff 26
27sqgetGlobalVar('key', $key, SQ_COOKIE);
28sqgetGlobalVar('username', $username, SQ_SESSION);
29sqgetGlobalVar('onetimepad', $onetimepad, SQ_SESSION);
2e30aa64 30sqgetGlobalVar('messages', $messages, SQ_SESSION);
31sqgetGlobalVar('mailbox', $mailbox, SQ_GET);
32sqgetGlobalVar('ent_id', $ent_id, SQ_GET);
33sqgetGlobalVar('passed_ent_id', $passed_ent_id, SQ_GET);
1e12d1ff 34sqgetGlobalVar('QUERY_STRING', $QUERY_STRING, SQ_SERVER);
2e30aa64 35if (sqgetGlobalVar('passed_id', $temp, SQ_GET)) {
36 $passed_id = (int) $temp;
a8393c89 37}
86725763 38
39$imapConnection = sqimap_login($username, $key, $imapServerAddress, $imapPort, 0);
2e30aa64 40$mbx_response = sqimap_mailbox_select($imapConnection, $mailbox);
86725763 41
2e30aa64 42$message = &$messages[$mbx_response['UIDVALIDITY']][$passed_id];
43if (!is_object($message)) {
44 $message = sqimap_get_message($imapConnection, $passed_id, $mailbox);
45}
86725763 46$message_ent = &$message->getEntity($ent_id);
47if ($passed_ent_id) {
48 $message = &$message->getEntity($passed_ent_id);
49}
2e30aa64 50$header = $message_ent->header;
51$type0 = $header->type0;
52$type1 = $header->type1;
53$charset = $header->getParameter('charset');
86725763 54$encoding = strtolower($header->encoding);
55
2e30aa64 56$msg_url = 'read_body.php?' . $QUERY_STRING;
57$msg_url = set_url_var($msg_url, 'ent_id', 0);
58$dwnld_url = '../src/download.php?'. $QUERY_STRING . '&amp;absolute_dl=true';
86725763 59
60$body = mime_fetch_body($imapConnection, $passed_id, $ent_id);
61$body = decodeBody($body, $encoding);
62
2e30aa64 63if (isset($languages[$squirrelmail_language]['XTRA_CODE']) &&
64 function_exists($languages[$squirrelmail_language]['XTRA_CODE'])) {
65 if (mb_detect_encoding($body) != 'ASCII') {
66 $body = $languages[$squirrelmail_language]['XTRA_CODE']('decode', $body);
e842b215 67 }
2e30aa64 68}
e842b215 69
86725763 70if ($type1 == 'html' || (isset($override_type1) && $override_type1 == 'html')) {
71 $body = MagicHTML( $body, $passed_id, $message, $mailbox);
72} else {
73 translateText($body, $wrap_at, $charset);
74}
86725763 75
2e30aa64 76displayPageHeader($color, 'None');
77
78echo '<BR><TABLE WIDTH="100%" BORDER=0 CELLSPACING=0 CELLPADDING=2 ALIGN=CENTER><TR><TD BGCOLOR="' . $color[0] . '">' .
79 '<B><CENTER>' .
80 _("Viewing a text attachment") . ' - ' .
81 '<a href="'.$msg_url.'">'. _("View message") . '</a>' .
82 '</b></td><tr><tr><td><CENTER><A HREF="' . $dwnld_url . '">' .
83 _("Download this as a file") .
84 '</A></CENTER><BR>' .
85 '</CENTER></B>' .
86 '</TD></TR></TABLE>' .
87 '<TABLE WIDTH="98%" BORDER=0 CELLSPACING=0 CELLPADDING=2 ALIGN=CENTER><TR><TD BGCOLOR="' . $color[0] . '">' .
88 '<TR><TD BGCOLOR="' . $color[4] . '"><TT>' .
dcc1cc82 89 $body . '</TT></TD></TR></TABLE>' .
90 '</body></html>';
91?>