- Improve recovery when EHLO not supported on legacy SMTP servers
[squirrelmail.git] / src / view_text.php
... / ...
CommitLineData
1<?php
2
3/**
4 * view_text.php -- Displays the main frameset
5 *
6 * Who knows what this file does. However PUT IT HERE DID NOT PUT
7 * A SINGLE FREAKING COMMENT IN! Whoever is responsible for this,
8 * be very ashamed.
9 *
10 * @copyright &copy; 1999-2006 The SquirrelMail Project Team
11 * @license http://opensource.org/licenses/gpl-license.php GNU Public License
12 * @version $Id$
13 * @package squirrelmail
14 */
15
16
17/* SquirrelMail required files. */
18include('../include/init.php');
19include(SM_PATH . 'functions/imap_general.php');
20include(SM_PATH . 'functions/imap_messages.php');
21include(SM_PATH . 'functions/mime.php');
22include(SM_PATH . 'functions/date.php');
23include(SM_PATH . 'functions/url_parser.php');
24
25sqgetGlobalVar('key', $key, SQ_COOKIE);
26sqgetGlobalVar('username', $username, SQ_SESSION);
27sqgetGlobalVar('onetimepad', $onetimepad, SQ_SESSION);
28sqgetGlobalVar('messages', $messages, SQ_SESSION);
29sqgetGlobalVar('mailbox', $mailbox, SQ_GET);
30sqgetGlobalVar('ent_id', $ent_id, SQ_GET);
31sqgetGlobalVar('passed_ent_id', $passed_ent_id, SQ_GET);
32sqgetGlobalVar('QUERY_STRING', $QUERY_STRING, SQ_SERVER);
33if (sqgetGlobalVar('passed_id', $temp, SQ_GET)) {
34 $passed_id = (int) $temp;
35}
36
37$imapConnection = sqimap_login($username, $key, $imapServerAddress, $imapPort, 0);
38$mbx_response = sqimap_mailbox_select($imapConnection, $mailbox);
39
40$message = &$messages[$mbx_response['UIDVALIDITY']][$passed_id];
41if (!is_object($message)) {
42 $message = sqimap_get_message($imapConnection, $passed_id, $mailbox);
43}
44$message_ent = $message->getEntity($ent_id);
45if ($passed_ent_id) {
46 $message = &$message->getEntity($passed_ent_id);
47}
48$header = $message_ent->header;
49$type0 = $header->type0;
50$type1 = $header->type1;
51$charset = $header->getParameter('charset');
52$encoding = strtolower($header->encoding);
53
54$msg_url = 'read_body.php?' . $QUERY_STRING;
55$msg_url = set_url_var($msg_url, 'ent_id', 0);
56$dwnld_url = '../src/download.php?' . $QUERY_STRING . '&amp;absolute_dl=true';
57
58$body = mime_fetch_body($imapConnection, $passed_id, $ent_id);
59$body = decodeBody($body, $encoding);
60$hookResults = do_hook('message_body', $body);
61$body = $hookResults[1];
62
63if (isset($languages[$squirrelmail_language]['XTRA_CODE']) &&
64 function_exists($languages[$squirrelmail_language]['XTRA_CODE'].'_decode')) {
65 if (mb_detect_encoding($body) != 'ASCII') {
66 $body = call_user_func($languages[$squirrelmail_language]['XTRA_CODE'] . '_decode', $body);
67 }
68}
69
70if ($type1 == 'html' || (isset($override_type1) && $override_type1 == 'html')) {
71 $body = MagicHTML( $body, $passed_id, $message, $mailbox);
72 // html attachment with character set information
73 if (! empty($charset))
74 $body = charset_decode($charset,$body,false,true);
75} else {
76 translateText($body, $wrap_at, $charset);
77}
78
79displayPageHeader($color, 'None');
80?>
81<br /><table width="100%" border="0" cellspacing="0" cellpadding="2" align="center"><tr><td bgcolor="<?php echo $color[0]; ?>">
82<b><div style="text-align: center;">
83<?php
84echo _("Viewing a text attachment") . ' - ' .
85 '<a href="'.$msg_url.'">' . _("View message") . '</a>';
86?>
87</b></td><tr><tr><td><div style="text-align: center;">
88<?php
89echo '<a href="' . $dwnld_url . '">' . _("Download this as a file") . '</a>';
90?>
91</div><br />
92</div></b>
93</td></tr></table>
94<table width="98%" border="0" cellspacing="0" cellpadding="2" align="center"><tr><td bgcolor="<?php echo $color[0]; ?>">
95<tr><td bgcolor="<?php echo $color[4]; ?>"><tt>
96<?php echo $body; ?>
97</tt></td></tr></table>
98<?php
99$oTemplate->display('footer.tpl');
100?>