squirrelmail-webmail  1.4.22
About: SquirrelMail is a standards-based webmail package with strong MIME support, address books, and folder manipulation (written in PHP4).
  Fossies Dox: squirrelmail-webmail-1.4.22.tar.gz  ("inofficial" and yet experimental doxygen-generated source code documentation)  

view_text.php
Go to the documentation of this file.
1 <?php
2 
20 define('SM_PATH','../');
21 
22 /* SquirrelMail required files. */
23 require_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('delimiter', $delimiter, SQ_SESSION);
33 sqgetGlobalVar('QUERY_STRING', $QUERY_STRING, SQ_SERVER);
34 sqgetGlobalVar('messages', $messages, SQ_SESSION);
35 sqgetGlobalVar('passed_id', $passed_id, SQ_GET);
36 
37 if ( sqgetGlobalVar('mailbox', $temp, SQ_GET) ) {
38  $mailbox = $temp;
39 }
40 if ( !sqgetGlobalVar('ent_id', $ent_id, SQ_GET) ) {
41  $ent_id = '';
42 }
43 if ( !sqgetGlobalVar('passed_ent_id', $passed_ent_id, SQ_GET) ) {
44  $passed_ent_id = '';
45 }
46 
47 
48 
51 
52 // were we using a reference here just to save memory?
53 // problem is that below if $passed_ent_id is given,
54 // the message cache now points to that entity and not
55 // the original message (corrupts the cache)
56 //
57 //$message = &$messages[$mbx_response['UIDVALIDITY']][$passed_id];
58 //
59 $message = $messages[$mbx_response['UIDVALIDITY']][$passed_id];
60 $message_ent = $message->getEntity($ent_id);
61 if ($passed_ent_id) {
62  $message = &$message->getEntity($passed_ent_id);
63 }
65 $type0 = $header->type0;
66 $type1 = $header->type1;
67 $charset = $header->getParameter('charset');
68 $encoding = strtolower($header->encoding);
69 
70 $msg_url = 'read_body.php?' . $QUERY_STRING;
71 $msg_url = set_url_var($msg_url, 'ent_id', 0);
72 $dwnld_url = '../src/download.php?' . $QUERY_STRING . '&amp;absolute_dl=true';
73 $unsafe_url = 'view_text.php?' . $QUERY_STRING;
74 $unsafe_url = set_url_var($unsafe_url, 'view_unsafe_images', 1);
75 
76 $body = mime_fetch_body($imapConnection, $passed_id, $ent_id);
78 
79 if (isset($languages[$squirrelmail_language]['XTRA_CODE']) &&
80  function_exists($languages[$squirrelmail_language]['XTRA_CODE'])) {
81  if (mb_detect_encoding($body) != 'ASCII') {
82  $body = $languages[$squirrelmail_language]['XTRA_CODE']('decode', $body);
83  }
84 }
85 
86 if ($type1 == 'html' || (isset($override_type1) && $override_type1 == 'html')) {
87  $ishtml = TRUE;
88  // html attachment with character set information
89  if (! empty($charset))
90  $body = charset_decode($charset,$body,false,true);
91  $body = magicHTML( $body, $passed_id, $message, $mailbox);
92 } else {
93  $ishtml = FALSE;
95 }
96 
97 displayPageHeader($color, 'None');
98 ?>
99 <br /><table width="100%" border="0" cellspacing="0" cellpadding="2" align="center"><tr><td bgcolor="<?php echo $color[0]; ?>">
100 <b><center>
101 <?php
102 echo _("Viewing a text attachment") . ' - ' .
103  '<a href="'.$msg_url.'">' . _("View message") . '</a>';
104 ?>
105 </b></td><tr><tr><td><center>
106 <?php
107 if ( $ishtml ) {
108  echo '<a href="' . $unsafe_url . '">' . _("View Unsafe Images") . '</a> | ';
109 }
110 echo '<a href="' . $dwnld_url . '">' . _("Download this as a file") . '</a>';
111 ?>
112 </center><br />
113 </center></b>
114 </td></tr></table>
115 <table width="98%" border="0" cellspacing="0" cellpadding="2" align="center"><tr><td bgcolor="<?php echo $color[0]; ?>">
116 <tr><td bgcolor="<?php echo $color[4]; ?>"><tt>
117 <?php echo $body; ?>
118 </tt></td></tr></table>
119 </body></html>
sqgetGlobalVar
sqgetGlobalVar($name, &$value, $search=SQ_INORDER)
Definition: global.php:344
$mbx_response
$mbx_response
Definition: view_text.php:50
$imapServerAddress
$imapServerAddress
Definition: config_default.php:202
sqimap_login
sqimap_login($username, $password, $imap_server_address, $imap_port, $hide)
Definition: imap_general.php:481
$charset
$charset
Definition: view_text.php:67
SQ_SESSION
const SQ_SESSION
Definition: global.php:18
$body
$body
Definition: view_text.php:76
displayPageHeader
displayPageHeader($color, $mailbox, $xtra='', $session=false)
Definition: page_header.php:105
$mailbox
$mailbox
Definition: options.php:28
set_url_var
set_url_var($url, $var, $val=null, $link=true)
Definition: html.php:109
html
Definition: html.class.php:18
$dwnld_url
$dwnld_url
Definition: view_text.php:72
$username
global $username
Definition: validate.php:55
magicHTML
magicHTML($body, $id, $message, $mailbox='INBOX', $take_mailto_links=true)
Definition: mime.php:2291
mime_fetch_body
mime_fetch_body($imap_stream, $id, $ent_id=1, $fetch_size=0)
Definition: mime.php:100
sqimap_mailbox_select
sqimap_mailbox_select($imap_stream, $mailbox)
Definition: imap_mailbox.php:238
$message
$message
Definition: view_text.php:59
$encoding
$encoding
Definition: view_text.php:68
decodeBody
decodeBody($body, $encoding)
Definition: mime.php:598
$languages
global $languages
Definition: i18n.php:774
$header
if($passed_ent_id) $header
Definition: view_text.php:64
SM_PATH
const SM_PATH
Definition: view_text.php:20
SQ_GET
const SQ_GET
Definition: global.php:16
$message_ent
$message_ent
Definition: view_text.php:60
SQ_SERVER
const SQ_SERVER
Definition: global.php:20
$msg_url
$msg_url
Definition: view_text.php:70
$wrap_at
$wrap_at
Definition: load_prefs.php:132
_
_($str)
Definition: gettext.php:160
translateText
translateText(&$body, $wrap_at, $charset)
Definition: mime.php:251
$type0
$type0
Definition: view_text.php:65
charset_decode
charset_decode($charset, $string, $force_decode=false, $save_html=false)
Definition: i18n.php:178
$imapPort
$imapPort
Definition: config_default.php:210
$color
$color
Definition: load_prefs.php:28
SQ_COOKIE
const SQ_COOKIE
Definition: global.php:19
$imapConnection
if(sqgetGlobalVar('mailbox', $temp, SQ_GET)) if(!sqgetGlobalVar('ent_id', $ent_id, SQ_GET)) if(!sqgetGlobalVar('passed_ent_id', $passed_ent_id, SQ_GET)) $imapConnection
Definition: view_text.php:49
$squirrelmail_language
global $squirrelmail_language
Definition: i18n.php:774
$unsafe_url
$unsafe_url
Definition: view_text.php:73
$type1
$type1
Definition: view_text.php:66