fix for viewing html entities with images involved.
[squirrelmail.git] / src / view_text.php
CommitLineData
facf44e7 1<?php
2
facf44e7 3 require_once('../src/validate.php');
4 require_once('../functions/imap.php');
5 require_once('../functions/mime.php');
f5563549 6 require_once('../functions/html.php');
7
facf44e7 8 $mailbox = urldecode($mailbox);
9 if (!isset($passed_ent_id)) {
10 $passed_ent_id = '';
11 }
12
13 $imapConnection = sqimap_login($username, $key, $imapServerAddress, $imapPort, 0);
14 $mbx_response = sqimap_mailbox_select($imapConnection, $mailbox);
15
16 $message = &$messages[$mbx_response['UIDVALIDITY']]["$passed_id"];
5984aeb0 17 $message_ent = &$message->getEntity($ent_id);
18 if ($passed_ent_id) {
19 $message = &$message->getEntity($passed_ent_id);
20 }
4124e322 21
5984aeb0 22 $header = $message_ent->header;
f5563549 23 $charset = $header->getParameter('charset');
facf44e7 24 $type0 = $header->type0;
25 $type1 = $header->type1;
26 $encoding = strtolower($header->encoding);
27
28 $msg_url = 'read_body.php?' . $QUERY_STRING;
f5563549 29 $msg_url = set_url_var($msg_url, 'ent_id', 0);
facf44e7 30
4124e322 31 $body = mime_fetch_body($imapConnection, $passed_id, $ent_id);
facf44e7 32 $body = decodeBody($body, $encoding);
33
34 displayPageHeader($color, 'None');
35
36 echo "<BR><TABLE WIDTH=\"100%\" BORDER=0 CELLSPACING=0 CELLPADDING=2 ALIGN=CENTER><TR><TD BGCOLOR=\"$color[0]\">".
37 "<B><CENTER>".
38 _("Viewing a text attachment") . " - ";
39 echo '<a href="'.$msg_url.'">'. _("View message") . '</a>';
40
f498a104 41 $dwnld_url = '../src/download.php?'. $QUERY_STRING.'&amp;absolute_dl=true';
facf44e7 42 echo '</b></td><tr><tr><td><CENTER><A HREF="'.$dwnld_url. '">'.
43 _("Download this as a file").
44 "</A></CENTER><BR>".
45 "</CENTER></B>".
46 "</TD></TR></TABLE>".
47 "<TABLE WIDTH=\"98%\" BORDER=0 CELLSPACING=0 CELLPADDING=2 ALIGN=CENTER><TR><TD BGCOLOR=\"$color[0]\">".
48 "<TR><TD BGCOLOR=\"$color[4]\"><TT>";
f498a104 49 if ($type1 == 'html' || $override_type1 == 'html') {
5984aeb0 50 $body = MagicHTML( $body, $passed_id, $message, $mailbox);
facf44e7 51 } else {
52 translateText($body, $wrap_at, $charset);
53 }
54 echo $body .
55 "</TT></TD></TR></TABLE>";
56?>