facf44e7 |
1 | <?php |
2 | |
86725763 |
3 | /** |
906f7e9f |
4 | * view_text.php -- View a text attachment |
86725763 |
5 | * |
906f7e9f |
6 | * Used by attachment_common code. |
86725763 |
7 | * |
c0d96801 |
8 | * @copyright 1999-2012 The SquirrelMail Project Team |
4b4abf93 |
9 | * @license http://opensource.org/licenses/gpl-license.php GNU Public License |
30967a1e |
10 | * @version $Id$ |
8f6f9ba5 |
11 | * @package squirrelmail |
86725763 |
12 | */ |
13 | |
ebd2391c |
14 | /** This is the view_text page */ |
15 | define('PAGE_NAME', 'view_text'); |
16 | |
867fed37 |
17 | /** SquirrelMail required files. */ |
202bcbcc |
18 | include('../include/init.php'); |
19 | include(SM_PATH . 'functions/imap_general.php'); |
20 | include(SM_PATH . 'functions/imap_messages.php'); |
21 | include(SM_PATH . 'functions/mime.php'); |
22 | include(SM_PATH . 'functions/date.php'); |
23 | include(SM_PATH . 'functions/url_parser.php'); |
1e12d1ff |
24 | |
2e30aa64 |
25 | sqgetGlobalVar('messages', $messages, SQ_SESSION); |
26 | sqgetGlobalVar('mailbox', $mailbox, SQ_GET); |
27 | sqgetGlobalVar('ent_id', $ent_id, SQ_GET); |
28 | sqgetGlobalVar('passed_ent_id', $passed_ent_id, SQ_GET); |
1e12d1ff |
29 | sqgetGlobalVar('QUERY_STRING', $QUERY_STRING, SQ_SERVER); |
51bbe8fa |
30 | sqgetGlobalVar('passed_id', $passed_id, SQ_GET, NULL, SQ_TYPE_BIGINT); |
86725763 |
31 | |
906f7e9f |
32 | $imapConnection = sqimap_login($username, false, $imapServerAddress, $imapPort, 0); |
24419a72 |
33 | $mbx_response = sqimap_mailbox_select($imapConnection, $mailbox); |
86725763 |
34 | |
2e30aa64 |
35 | $message = &$messages[$mbx_response['UIDVALIDITY']][$passed_id]; |
36 | if (!is_object($message)) { |
37 | $message = sqimap_get_message($imapConnection, $passed_id, $mailbox); |
38 | } |
d08f6513 |
39 | $message_ent = $message->getEntity($ent_id); |
86725763 |
40 | if ($passed_ent_id) { |
41 | $message = &$message->getEntity($passed_ent_id); |
42 | } |
2e30aa64 |
43 | $header = $message_ent->header; |
44 | $type0 = $header->type0; |
45 | $type1 = $header->type1; |
46 | $charset = $header->getParameter('charset'); |
86725763 |
47 | $encoding = strtolower($header->encoding); |
48 | |
2e30aa64 |
49 | $msg_url = 'read_body.php?' . $QUERY_STRING; |
50 | $msg_url = set_url_var($msg_url, 'ent_id', 0); |
e6e9ed4a |
51 | $dwnld_url = '../src/download.php?' . $QUERY_STRING . '&absolute_dl=true'; |
be9f42bf |
52 | $unsafe_url = 'view_text.php?' . $QUERY_STRING; |
53 | $unsafe_url = set_url_var($unsafe_url, 'view_unsafe_images', 1); |
54 | |
86725763 |
55 | |
56 | $body = mime_fetch_body($imapConnection, $passed_id, $ent_id); |
57 | $body = decodeBody($body, $encoding); |
6e515418 |
58 | do_hook('message_body', $body); |
86725763 |
59 | |
2e30aa64 |
60 | if (isset($languages[$squirrelmail_language]['XTRA_CODE']) && |
f4bb5d22 |
61 | function_exists($languages[$squirrelmail_language]['XTRA_CODE'].'_decode')) { |
2e30aa64 |
62 | if (mb_detect_encoding($body) != 'ASCII') { |
f4bb5d22 |
63 | $body = call_user_func($languages[$squirrelmail_language]['XTRA_CODE'] . '_decode', $body); |
e842b215 |
64 | } |
2e30aa64 |
65 | } |
e842b215 |
66 | |
86725763 |
67 | if ($type1 == 'html' || (isset($override_type1) && $override_type1 == 'html')) { |
be9f42bf |
68 | $ishtml = TRUE; |
ea51e94a |
69 | // html attachment with character set information |
be9f42bf |
70 | if (! empty($charset)) { |
ea51e94a |
71 | $body = charset_decode($charset,$body,false,true); |
be9f42bf |
72 | } |
567dc524 |
73 | $body = MagicHTML( $body, $passed_id, $message, $mailbox); |
86725763 |
74 | } else { |
ac589f55 |
75 | $ishtml = FALSE; |
86725763 |
76 | translateText($body, $wrap_at, $charset); |
77 | } |
86725763 |
78 | |
876fdb60 |
79 | displayPageHeader($color); |
37683fa0 |
80 | |
81 | $oTemplate->assign('view_message_href', $msg_url); |
82 | $oTemplate->assign('download_href', $dwnld_url); |
83 | $oTemplate->assign('view_unsafe_image_href', $ishtml ? $unsafe_url : ''); |
84 | $oTemplate->assign('body', $body); |
85 | |
86 | $oTemplate->display('view_text.tpl'); |
87 | |
5c4ff7bf |
88 | $oTemplate->display('footer.tpl'); |