phpdoc updates
[squirrelmail.git] / src / view_text.php
1 <?php
2
3 /**
4 * view_text.php -- Displays the main frameset
5 *
6 * Copyright (c) 1999-2004 The SquirrelMail development team
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 * @package squirrelmail
15 */
16
17 /** Path for SquirrelMail required files. */
18 define('SM_PATH','../');
19
20 /* SquirrelMail required files. */
21 require_once(SM_PATH . 'include/validate.php');
22 require_once(SM_PATH . 'functions/global.php');
23 require_once(SM_PATH . 'functions/imap.php');
24 require_once(SM_PATH . 'functions/mime.php');
25 require_once(SM_PATH . 'functions/html.php');
26
27 sqgetGlobalVar('key', $key, SQ_COOKIE);
28 sqgetGlobalVar('username', $username, SQ_SESSION);
29 sqgetGlobalVar('onetimepad', $onetimepad, SQ_SESSION);
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);
34 sqgetGlobalVar('QUERY_STRING', $QUERY_STRING, SQ_SERVER);
35 if (sqgetGlobalVar('passed_id', $temp, SQ_GET)) {
36 $passed_id = (int) $temp;
37 }
38
39 $imapConnection = sqimap_login($username, $key, $imapServerAddress, $imapPort, 0);
40 $mbx_response = sqimap_mailbox_select($imapConnection, $mailbox);
41
42 $message = &$messages[$mbx_response['UIDVALIDITY']][$passed_id];
43 if (!is_object($message)) {
44 $message = sqimap_get_message($imapConnection, $passed_id, $mailbox);
45 }
46 $message_ent = &$message->getEntity($ent_id);
47 if ($passed_ent_id) {
48 $message = &$message->getEntity($passed_ent_id);
49 }
50 $header = $message_ent->header;
51 $type0 = $header->type0;
52 $type1 = $header->type1;
53 $charset = $header->getParameter('charset');
54 $encoding = strtolower($header->encoding);
55
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 . '&amp;absolute_dl=true';
59
60 $body = mime_fetch_body($imapConnection, $passed_id, $ent_id);
61 $body = decodeBody($body, $encoding);
62
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);
67 }
68 }
69
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 }
75
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>' .
89 $body . '</TT></TD></TR></TABLE>' .
90 '</body></html>';
91 ?>