don't add delimiter to folder name, when folder with subfolders is
[squirrelmail.git] / src / view_text.php
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 /** SquirrelMail required files. */
17 include('../include/init.php');
18 include(SM_PATH . 'functions/imap_general.php');
19 include(SM_PATH . 'functions/imap_messages.php');
20 include(SM_PATH . 'functions/mime.php');
21 include(SM_PATH . 'functions/date.php');
22 include(SM_PATH . 'functions/url_parser.php');
23
24 sqgetGlobalVar('key', $key, SQ_COOKIE);
25 sqgetGlobalVar('username', $username, SQ_SESSION);
26 sqgetGlobalVar('onetimepad', $onetimepad, SQ_SESSION);
27 sqgetGlobalVar('messages', $messages, SQ_SESSION);
28 sqgetGlobalVar('mailbox', $mailbox, SQ_GET);
29 sqgetGlobalVar('ent_id', $ent_id, SQ_GET);
30 sqgetGlobalVar('passed_ent_id', $passed_ent_id, SQ_GET);
31 sqgetGlobalVar('QUERY_STRING', $QUERY_STRING, SQ_SERVER);
32 if (sqgetGlobalVar('passed_id', $temp, SQ_GET)) {
33 $passed_id = (int) $temp;
34 }
35
36 $imapConnection = sqimap_login($username, $key, $imapServerAddress, $imapPort, 0);
37 $mbx_response = sqimap_mailbox_select($imapConnection, $mailbox);
38
39 $message = &$messages[$mbx_response['UIDVALIDITY']][$passed_id];
40 if (!is_object($message)) {
41 $message = sqimap_get_message($imapConnection, $passed_id, $mailbox);
42 }
43 $message_ent = $message->getEntity($ent_id);
44 if ($passed_ent_id) {
45 $message = &$message->getEntity($passed_ent_id);
46 }
47 $header = $message_ent->header;
48 $type0 = $header->type0;
49 $type1 = $header->type1;
50 $charset = $header->getParameter('charset');
51 $encoding = strtolower($header->encoding);
52
53 $msg_url = 'read_body.php?' . $QUERY_STRING;
54 $msg_url = set_url_var($msg_url, 'ent_id', 0);
55 $dwnld_url = '../src/download.php?' . $QUERY_STRING . '&amp;absolute_dl=true';
56
57 $body = mime_fetch_body($imapConnection, $passed_id, $ent_id);
58 $body = decodeBody($body, $encoding);
59 $hookResults = do_hook('message_body', $body);
60 $body = $hookResults[1];
61
62 if (isset($languages[$squirrelmail_language]['XTRA_CODE']) &&
63 function_exists($languages[$squirrelmail_language]['XTRA_CODE'].'_decode')) {
64 if (mb_detect_encoding($body) != 'ASCII') {
65 $body = call_user_func($languages[$squirrelmail_language]['XTRA_CODE'] . '_decode', $body);
66 }
67 }
68
69 if ($type1 == 'html' || (isset($override_type1) && $override_type1 == 'html')) {
70 $body = MagicHTML( $body, $passed_id, $message, $mailbox);
71 // html attachment with character set information
72 if (! empty($charset))
73 $body = charset_decode($charset,$body,false,true);
74 } else {
75 translateText($body, $wrap_at, $charset);
76 }
77
78 displayPageHeader($color, 'None');
79 ?>
80 <br /><table width="100%" border="0" cellspacing="0" cellpadding="2" align="center"><tr><td bgcolor="<?php echo $color[0]; ?>">
81 <b><div style="text-align: center;">
82 <?php
83 echo _("Viewing a text attachment") . ' - ' .
84 '<a href="'.$msg_url.'">' . _("View message") . '</a>';
85 ?>
86 </b></td><tr><tr><td><div style="text-align: center;">
87 <?php
88 echo '<a href="' . $dwnld_url . '">' . _("Download this as a file") . '</a>';
89 ?>
90 </div><br />
91 </div></b>
92 </td></tr></table>
93 <table width="98%" border="0" cellspacing="0" cellpadding="2" align="center"><tr><td bgcolor="<?php echo $color[0]; ?>">
94 <tr><td bgcolor="<?php echo $color[4]; ?>"><tt>
95 <?php echo $body; ?>
96 </tt></td></tr></table>
97 <?php
98 $oTemplate->display('footer.tpl');
99 ?>