facf44e7 |
1 | <?php |
2 | |
3 | /** |
4 | * view_text.php |
5 | * |
6 | * Copyright (c) 1999-2002 The SquirrelMail Project Team |
7 | * Licensed under the GNU GPL. For full terms see the file COPYING. |
8 | * |
9 | * This is the code to view the text attachments. |
10 | * |
11 | * $Id$ |
12 | */ |
13 | |
14 | |
15 | require_once('../src/validate.php'); |
16 | require_once('../functions/imap.php'); |
17 | require_once('../functions/mime.php'); |
18 | |
19 | $mailbox = urldecode($mailbox); |
20 | if (!isset($passed_ent_id)) { |
21 | $passed_ent_id = ''; |
22 | } |
23 | |
24 | $imapConnection = sqimap_login($username, $key, $imapServerAddress, $imapPort, 0); |
25 | $mbx_response = sqimap_mailbox_select($imapConnection, $mailbox); |
26 | |
27 | $message = &$messages[$mbx_response['UIDVALIDITY']]["$passed_id"]; |
28 | $message = &$message->getEntity($passed_ent_id); |
29 | |
30 | $header = $message->header; |
31 | $charset = $header->charset; |
32 | $type0 = $header->type0; |
33 | $type1 = $header->type1; |
34 | $encoding = strtolower($header->encoding); |
35 | |
36 | $msg_url = 'read_body.php?' . $QUERY_STRING; |
37 | |
38 | $body = mime_fetch_body($imapConnection, $passed_id, $passed_ent_id); |
39 | $body = decodeBody($body, $encoding); |
40 | |
41 | displayPageHeader($color, 'None'); |
42 | |
43 | echo "<BR><TABLE WIDTH=\"100%\" BORDER=0 CELLSPACING=0 CELLPADDING=2 ALIGN=CENTER><TR><TD BGCOLOR=\"$color[0]\">". |
44 | "<B><CENTER>". |
45 | _("Viewing a text attachment") . " - "; |
46 | echo '<a href="'.$msg_url.'">'. _("View message") . '</a>'; |
47 | |
48 | $dwnld_url = '../src/download.php?'. $QUERY_STRING.'&absolute_dl=1'; |
49 | echo '</b></td><tr><tr><td><CENTER><A HREF="'.$dwnld_url. '">'. |
50 | _("Download this as a file"). |
51 | "</A></CENTER><BR>". |
52 | "</CENTER></B>". |
53 | "</TD></TR></TABLE>". |
54 | "<TABLE WIDTH=\"98%\" BORDER=0 CELLSPACING=0 CELLPADDING=2 ALIGN=CENTER><TR><TD BGCOLOR=\"$color[0]\">". |
55 | "<TR><TD BGCOLOR=\"$color[4]\"><TT>"; |
56 | |
57 | if ($type1 == 'html') { |
58 | $msg = sqimap_get_message($imapConnection, $passed_id, $mailbox); |
59 | $msg = $msg->getEntity($passed_ent_id); |
60 | $body = MagicHTML( $body, $passed_id, $msg ); |
61 | } else { |
62 | translateText($body, $wrap_at, $charset); |
63 | } |
64 | echo $body . |
65 | "</TT></TD></TR></TABLE>"; |
460aef76 |
66 | |
67 | sqimap_logout($imapConnection); |
facf44e7 |
68 | ?> |