e152b438c8ddd8323f0956ee543e40adaac69fa7
[squirrelmail.git] / src / view_text.php
1 <?php
2
3 /**
4 * view_text.php -- Displays the main frameset
5 *
6 * Copyright (c) 1999-2002 The SquirrelMail development team
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. */
17 define('SM_PATH','../');
18
19 /* SquirrelMail required files. */
20 require_once(SM_PATH . 'src/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');
24
25 $mailbox = urldecode($mailbox);
26 if (!isset($passed_ent_id)) {
27 $passed_ent_id = '';
28 }
29
30 $imapConnection = sqimap_login($username, $key, $imapServerAddress, $imapPort, 0);
31 $mbx_response = sqimap_mailbox_select($imapConnection, $mailbox);
32
33 $message = &$messages[$mbx_response['UIDVALIDITY']]["$passed_id"];
34 $message_ent = &$message->getEntity($ent_id);
35 if ($passed_ent_id) {
36 $message = &$message->getEntity($passed_ent_id);
37 }
38
39 $header = $message_ent->header;
40 $charset = $header->getParameter('charset');
41 $type0 = $header->type0;
42 $type1 = $header->type1;
43 $encoding = strtolower($header->encoding);
44
45 $msg_url = 'read_body.php?' . $QUERY_STRING;
46 $msg_url = set_url_var($msg_url, 'ent_id', 0);
47
48 $body = mime_fetch_body($imapConnection, $passed_id, $ent_id);
49 $body = decodeBody($body, $encoding);
50
51 displayPageHeader($color, 'None');
52
53 echo "<BR><TABLE WIDTH=\"100%\" BORDER=0 CELLSPACING=0 CELLPADDING=2 ALIGN=CENTER><TR><TD BGCOLOR=\"$color[0]\">".
54 "<B><CENTER>".
55 _("Viewing a text attachment") . " - ";
56 echo '<a href="'.$msg_url.'">'. _("View message") . '</a>';
57
58 $dwnld_url = '../src/download.php?'. $QUERY_STRING.'&amp;absolute_dl=true';
59 echo '</b></td><tr><tr><td><CENTER><A HREF="'.$dwnld_url. '">'.
60 _("Download this as a file").
61 "</A></CENTER><BR>".
62 "</CENTER></B>".
63 "</TD></TR></TABLE>".
64 "<TABLE WIDTH=\"98%\" BORDER=0 CELLSPACING=0 CELLPADDING=2 ALIGN=CENTER><TR><TD BGCOLOR=\"$color[0]\">".
65 "<TR><TD BGCOLOR=\"$color[4]\"><TT>";
66 if ($type1 == 'html' || (isset($override_type1) && $override_type1 == 'html')) {
67 $body = MagicHTML( $body, $passed_id, $message, $mailbox);
68 } else {
69 translateText($body, $wrap_at, $charset);
70 }
71 echo $body . "</TT></TD></TR></TABLE>";
72
73 ?>