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