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