4 * view_text.php -- Displays the main frameset
6 * Copyright (c) 1999-2002 The SquirrelMail development team
7 * Licensed under the GNU GPL. For full terms see the file COPYING.
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,
16 /* Path for SquirrelMail required files. */
17 define('SM_PATH','../');
19 /* SquirrelMail required files. */
20 require_once(SM_PATH
. 'include/validate.php');
21 require_once(SM_PATH
. 'functions/imap.php');
22 require_once(SM_PATH
. 'functions/mime.php');
23 require_once(SM_PATH
. 'functions/html.php');
25 $mailbox = urldecode($_GET['mailbox']);
26 if (!isset($_GET['passed_ent_id'])) {
29 $passed_ent_id = $_GET['passed_ent_id'];
31 $passed_id = $_GET['passed_id'];
32 $username = $_SESSION['username'];
33 $key = $_COOKIE['key'];
34 $delimiter = $_SESSION['delimiter'];
35 $onetimepad = $_SESSION['onetimepad'];
38 $imapConnection = sqimap_login($username, $key, $imapServerAddress, $imapPort, 0);
39 $mbx_response = sqimap_mailbox_select($imapConnection, $mailbox);
41 $message = &$messages[$mbx_response['UIDVALIDITY']]["$passed_id"];
42 $message_ent = &$message->getEntity($ent_id);
44 $message = &$message->getEntity($passed_ent_id);
47 $header = $message_ent->header
;
48 $charset = $header->getParameter('charset');
49 $type0 = $header->type0
;
50 $type1 = $header->type1
;
51 $encoding = strtolower($header->encoding
);
53 $msg_url = 'read_body.php?' . $QUERY_STRING;
54 $msg_url = set_url_var($msg_url, 'ent_id', 0);
56 $body = mime_fetch_body($imapConnection, $passed_id, $ent_id);
57 $body = decodeBody($body, $encoding);
59 displayPageHeader($color, 'None');
61 echo "<BR><TABLE WIDTH=\"100%\" BORDER=0 CELLSPACING=0 CELLPADDING=2 ALIGN=CENTER><TR><TD BGCOLOR=\"$color[0]\">".
63 _("Viewing a text attachment") . " - ";
64 echo '<a href="'.$msg_url.'">'. _("View message") . '</a>';
66 $dwnld_url = '../src/download.php?'. $QUERY_STRING.'&absolute_dl=true';
67 echo '</b></td><tr><tr><td><CENTER><A HREF="'.$dwnld_url. '">'.
68 _("Download this as a file").
72 "<TABLE WIDTH=\"98%\" BORDER=0 CELLSPACING=0 CELLPADDING=2 ALIGN=CENTER><TR><TD BGCOLOR=\"$color[0]\">".
73 "<TR><TD BGCOLOR=\"$color[4]\"><TT>";
74 if ($type1 == 'html' ||
(isset($override_type1) && $override_type1 == 'html')) {
75 $body = MagicHTML( $body, $passed_id, $message, $mailbox);
77 translateText($body, $wrap_at, $charset);
79 echo $body . "</TT></TD></TR></TABLE>";