adding address book sorting options. changed some parts of patch written
[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 *
30967a1e 13 * @version $Id$
8f6f9ba5 14 * @package squirrelmail
86725763 15 */
16
30967a1e 17/**
18 * Path for SquirrelMail required files.
19 * @ignore
20 */
86725763 21define('SM_PATH','../');
22
23/* SquirrelMail required files. */
08185f2a 24require_once(SM_PATH . 'include/validate.php');
1e12d1ff 25require_once(SM_PATH . 'functions/global.php');
86725763 26require_once(SM_PATH . 'functions/imap.php');
27require_once(SM_PATH . 'functions/mime.php');
28require_once(SM_PATH . 'functions/html.php');
1e12d1ff 29
30sqgetGlobalVar('key', $key, SQ_COOKIE);
31sqgetGlobalVar('username', $username, SQ_SESSION);
32sqgetGlobalVar('onetimepad', $onetimepad, SQ_SESSION);
2e30aa64 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);
1e12d1ff 37sqgetGlobalVar('QUERY_STRING', $QUERY_STRING, SQ_SERVER);
2e30aa64 38if (sqgetGlobalVar('passed_id', $temp, SQ_GET)) {
39 $passed_id = (int) $temp;
a8393c89 40}
86725763 41
42$imapConnection = sqimap_login($username, $key, $imapServerAddress, $imapPort, 0);
2e30aa64 43$mbx_response = sqimap_mailbox_select($imapConnection, $mailbox);
86725763 44
2e30aa64 45$message = &$messages[$mbx_response['UIDVALIDITY']][$passed_id];
46if (!is_object($message)) {
47 $message = sqimap_get_message($imapConnection, $passed_id, $mailbox);
48}
86725763 49$message_ent = &$message->getEntity($ent_id);
50if ($passed_ent_id) {
51 $message = &$message->getEntity($passed_ent_id);
52}
2e30aa64 53$header = $message_ent->header;
54$type0 = $header->type0;
55$type1 = $header->type1;
56$charset = $header->getParameter('charset');
86725763 57$encoding = strtolower($header->encoding);
58
2e30aa64 59$msg_url = 'read_body.php?' . $QUERY_STRING;
60$msg_url = set_url_var($msg_url, 'ent_id', 0);
61$dwnld_url = '../src/download.php?'. $QUERY_STRING . '&amp;absolute_dl=true';
86725763 62
63$body = mime_fetch_body($imapConnection, $passed_id, $ent_id);
64$body = decodeBody($body, $encoding);
65
2e30aa64 66if (isset($languages[$squirrelmail_language]['XTRA_CODE']) &&
67 function_exists($languages[$squirrelmail_language]['XTRA_CODE'])) {
68 if (mb_detect_encoding($body) != 'ASCII') {
69 $body = $languages[$squirrelmail_language]['XTRA_CODE']('decode', $body);
e842b215 70 }
2e30aa64 71}
e842b215 72
86725763 73if ($type1 == 'html' || (isset($override_type1) && $override_type1 == 'html')) {
74 $body = MagicHTML( $body, $passed_id, $message, $mailbox);
75} else {
76 translateText($body, $wrap_at, $charset);
77}
86725763 78
2e30aa64 79displayPageHeader($color, 'None');
80
81echo '<BR><TABLE WIDTH="100%" BORDER=0 CELLSPACING=0 CELLPADDING=2 ALIGN=CENTER><TR><TD BGCOLOR="' . $color[0] . '">' .
82 '<B><CENTER>' .
83 _("Viewing a text attachment") . ' - ' .
84 '<a href="'.$msg_url.'">'. _("View message") . '</a>' .
85 '</b></td><tr><tr><td><CENTER><A HREF="' . $dwnld_url . '">' .
86 _("Download this as a file") .
87 '</A></CENTER><BR>' .
88 '</CENTER></B>' .
89 '</TD></TR></TABLE>' .
90 '<TABLE WIDTH="98%" BORDER=0 CELLSPACING=0 CELLPADDING=2 ALIGN=CENTER><TR><TD BGCOLOR="' . $color[0] . '">' .
91 '<TR><TD BGCOLOR="' . $color[4] . '"><TT>' .
dcc1cc82 92 $body . '</TT></TD></TR></TABLE>' .
93 '</body></html>';
94?>