Fix for infinite loop when trying to decode multi-part mime attachments
[squirrelmail.git] / src / view_text.php
CommitLineData
facf44e7 1<?php
2
86725763 3/**
4 * view_text.php -- Displays the main frameset
5 *
76911253 6 * Copyright (c) 1999-2003 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$
14 */
15
16/* Path for SquirrelMail required files. */
17define('SM_PATH','../');
18
19/* SquirrelMail required files. */
08185f2a 20require_once(SM_PATH . 'include/validate.php');
1e12d1ff 21require_once(SM_PATH . 'functions/global.php');
86725763 22require_once(SM_PATH . 'functions/imap.php');
23require_once(SM_PATH . 'functions/mime.php');
24require_once(SM_PATH . 'functions/html.php');
1e12d1ff 25
26sqgetGlobalVar('key', $key, SQ_COOKIE);
27sqgetGlobalVar('username', $username, SQ_SESSION);
28sqgetGlobalVar('onetimepad', $onetimepad, SQ_SESSION);
29sqgetGlobalVar('delimiter', $delimiter, SQ_SESSION);
30sqgetGlobalVar('QUERY_STRING', $QUERY_STRING, SQ_SERVER);
31sqgetGlobalVar('messages', $messages);
32sqgetGlobalVar('passed_id', $passed_id, SQ_GET);
33
34if ( sqgetGlobalVar('mailbox', $temp, SQ_GET) ) {
fdc9d9b5 35 $mailbox = $temp;
86725763 36}
1e12d1ff 37if ( !sqgetGlobalVar('ent_id', $ent_id, SQ_GET) ) {
38 $ent_id = '';
a8393c89 39}
1e12d1ff 40if ( !sqgetGlobalVar('passed_ent_id', $passed_ent_id, SQ_GET) ) {
41 $passed_ent_id = '';
42}
43
a8393c89 44
86725763 45
46$imapConnection = sqimap_login($username, $key, $imapServerAddress, $imapPort, 0);
47$mbx_response = sqimap_mailbox_select($imapConnection, $mailbox);
48
49$message = &$messages[$mbx_response['UIDVALIDITY']]["$passed_id"];
50$message_ent = &$message->getEntity($ent_id);
51if ($passed_ent_id) {
52 $message = &$message->getEntity($passed_ent_id);
53}
4124e322 54
86725763 55$header = $message_ent->header;
56$charset = $header->getParameter('charset');
57$type0 = $header->type0;
58$type1 = $header->type1;
59$encoding = strtolower($header->encoding);
60
61$msg_url = 'read_body.php?' . $QUERY_STRING;
62$msg_url = set_url_var($msg_url, 'ent_id', 0);
63
64$body = mime_fetch_body($imapConnection, $passed_id, $ent_id);
65$body = decodeBody($body, $encoding);
66
67displayPageHeader($color, 'None');
68
69echo "<BR><TABLE WIDTH=\"100%\" BORDER=0 CELLSPACING=0 CELLPADDING=2 ALIGN=CENTER><TR><TD BGCOLOR=\"$color[0]\">".
70 "<B><CENTER>".
71 _("Viewing a text attachment") . " - ";
72echo '<a href="'.$msg_url.'">'. _("View message") . '</a>';
73
74$dwnld_url = '../src/download.php?'. $QUERY_STRING.'&amp;absolute_dl=true';
75echo '</b></td><tr><tr><td><CENTER><A HREF="'.$dwnld_url. '">'.
76 _("Download this as a file").
77 "</A></CENTER><BR>".
78 "</CENTER></B>".
79 "</TD></TR></TABLE>".
80 "<TABLE WIDTH=\"98%\" BORDER=0 CELLSPACING=0 CELLPADDING=2 ALIGN=CENTER><TR><TD BGCOLOR=\"$color[0]\">".
81 "<TR><TD BGCOLOR=\"$color[4]\"><TT>";
82if ($type1 == 'html' || (isset($override_type1) && $override_type1 == 'html')) {
83 $body = MagicHTML( $body, $passed_id, $message, $mailbox);
84} else {
85 translateText($body, $wrap_at, $charset);
86}
87echo $body . "</TT></TD></TR></TABLE>";
88
facf44e7 89?>