4 * view_text.php -- Displays the main frameset
6 * Copyright (c) 1999-2003 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/global.php');
22 require_once(SM_PATH
. 'functions/imap.php');
23 require_once(SM_PATH
. 'functions/mime.php');
24 require_once(SM_PATH
. 'functions/html.php');
26 sqgetGlobalVar('key', $key, SQ_COOKIE
);
27 sqgetGlobalVar('username', $username, SQ_SESSION
);
28 sqgetGlobalVar('onetimepad', $onetimepad, SQ_SESSION
);
29 sqgetGlobalVar('delimiter', $delimiter, SQ_SESSION
);
30 sqgetGlobalVar('QUERY_STRING', $QUERY_STRING, SQ_SERVER
);
31 sqgetGlobalVar('messages', $messages);
32 sqgetGlobalVar('passed_id', $passed_id, SQ_GET
);
34 if ( sqgetGlobalVar('mailbox', $temp, SQ_GET
) ) {
37 if ( !sqgetGlobalVar('ent_id', $ent_id, SQ_GET
) ) {
40 if ( !sqgetGlobalVar('passed_ent_id', $passed_ent_id, SQ_GET
) ) {
46 $imapConnection = sqimap_login($username, $key, $imapServerAddress, $imapPort, 0);
47 $mbx_response = sqimap_mailbox_select($imapConnection, $mailbox);
49 $message = &$messages[$mbx_response['UIDVALIDITY']]["$passed_id"];
50 $message_ent = &$message->getEntity($ent_id);
52 $message = &$message->getEntity($passed_ent_id);
55 $header = $message_ent->header
;
56 $charset = $header->getParameter('charset');
57 $type0 = $header->type0
;
58 $type1 = $header->type1
;
59 $encoding = strtolower($header->encoding
);
61 $msg_url = 'read_body.php?' . $QUERY_STRING;
62 $msg_url = set_url_var($msg_url, 'ent_id', 0);
64 $body = mime_fetch_body($imapConnection, $passed_id, $ent_id);
65 $body = decodeBody($body, $encoding);
67 displayPageHeader($color, 'None');
69 echo "<BR><TABLE WIDTH=\"100%\" BORDER=0 CELLSPACING=0 CELLPADDING=2 ALIGN=CENTER><TR><TD BGCOLOR=\"$color[0]\">".
71 _("Viewing a text attachment") . " - ";
72 echo '<a href="'.$msg_url.'">'. _("View message") . '</a>';
74 $dwnld_url = '../src/download.php?'. $QUERY_STRING.'&absolute_dl=true';
75 echo '</b></td><tr><tr><td><CENTER><A HREF="'.$dwnld_url. '">'.
76 _("Download this as a file").
80 "<TABLE WIDTH=\"98%\" BORDER=0 CELLSPACING=0 CELLPADDING=2 ALIGN=CENTER><TR><TD BGCOLOR=\"$color[0]\">".
81 "<TR><TD BGCOLOR=\"$color[4]\"><TT>";
83 if (isset($languages[$squirrelmail_language]['XTRA_CODE']) &&
84 function_exists($languages[$squirrelmail_language]['XTRA_CODE'])) {
85 if (mb_detect_encoding($body) != 'ASCII') {
86 $body = $languages[$squirrelmail_language]['XTRA_CODE']('decode', $body);
90 if ($type1 == 'html' ||
(isset($override_type1) && $override_type1 == 'html')) {
91 $body = MagicHTML( $body, $passed_id, $message, $mailbox);
93 translateText($body, $wrap_at, $charset);
95 echo $body . "</TT></TD></TR></TABLE>";