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