+ return $string;
+}
+
+function formatEnvheader($mailbox, $passed_id, $passed_ent_id, $message,
+ $color, $FirstTimeSee) {
+ global $msn_user_support, $default_use_mdn, $draft_folder, $sent_folder,
+ $default_use_priority, $show_xmailer_default,
+ $mdn_user_support, $PHP_SELF, $javascript_on;
+
+ $header = $message->rfc822_header;
+ $env = array();
+ $env[_("Subject")] = htmlspecialchars($header->subject);
+ $from_name = $header->getAddr_s('from');
+ if (!$from_name) {
+ $from_name = $header->getAddr_s('sender');
+ if (!$from_name) {
+ $from_name = _("Unknown sender");
+ }
+ }
+ $env[_("From")] = htmlspecialchars($from_name);
+ $env[_("Date")] = getLongDateString($header->date);
+ $env[_("To")] = formatRecipientString($header->to, "to");
+ $env[_("Cc")] = formatRecipientString($header->cc, "cc");
+ $env[_("Bcc")] = formatRecipientString($header->bcc, "bcc");
+ if ($default_use_priority) {
+ $env[_("Priority")] = getPriorityStr($header->priority);
+ }
+ if ($show_xmailer_default) {
+ $env[_("Mailer")] = $header->xmailer;
+ }
+ if ($default_use_mdn) {
+ if ($mdn_user_support) {
+ if ($header->dnt) {
+ if ($message->is_mdnsent) {
+ $env[_("Read receipt")] = _("send");
+ } else {
+ if ( !($mailbox == $draft_folder ||
+ $mailbox == $sent_folder || $message->is_deleted)) {
+ $mdn_url = $PHP_SELF . '&sendreceipt=1';
+ if ($FirstTimeSee && $javascript_on) {
+ $script = '<script language="JavaScript" type="text/javascript">' ."\n";
+ $script .= '<!--'. "\n";
+ $script .= 'if(window.confirm("' .
+ _("The message sender has requested a response to indicate that you have read this message. Would you like to send a receipt?") .
+ '")) { '."\n" .
+ ' sendMDN()'.
+ '}' . "\n";
+ $script .= '// -->'. "\n";
+ $script .= '</script>'. "\n";
+ echo $script;
+ }
+ $env[_("Read receipt")] = _("requested") .
+ ' <a href="'.$mdn_url.'">['. _("Send read receipt now") .']</a>';
+ } else {
+ $env[_("Read receipt")] = _("requested");
+ }
+ }
+ }
+ }
+ }
+
+ $s = '<table width="100%" cellpadding="0" cellspacing="0" border="0" ' .
+ 'align="center">';
+ foreach ($env as $key => $val) {
+ if ($val) {
+ $s .= '<tr>';
+ $s .= html_tag( 'td', '<b>'.$key.': </b>', 'right', $color[0], 'valign="top" width="20%"') . "\n";
+ $s .= html_tag( 'td', $val, 'left', $color[0], 'valign="top" width="80%"');
+ $s .= "\n</tr>";
+ }
+ }
+ $s .= '</table>';
+ echo $s;
+}
+
+function formatMenubar($mailbox, $passed_id, $passed_ent_id, $message, $mbx_response) {
+ global $base_uri, $sent_folder, $draft_folder, $where, $what, $color, $sort,
+ $startMessage, $compose_new_win, $PHP_SELF, $save_as_draft;
+
+ $topbar_delimiter = ' | ';
+ $urlMailbox = urlencode($mailbox);
+ $s = '<table width="100%" cellpadding="3" cellspacing="0" align="center"'.
+ ' border="0" bgcolor="'.$color[9].'"><tr><td align="left" width="33%"><small>';
+
+ $msgs_url = $base_uri . 'src/';
+ if (isset($where) && isset($what)) {
+ $msgs_url .= 'search.php?where='.urlencode($where).
+ '&what='.urlencode($what).'&mailbox='.$urlMailbox;
+ $msgs_str = _("Search results");
+ } else {
+ $msgs_url .= 'right_main.php?sort='.$sort.'&startMessage='.
+ $startMessage.'&mailbox='.$urlMailbox;
+ $msgs_str = _("Message List");
+ }
+ $s .= '<a href="'. $msgs_url.'">'.$msgs_str.'</a>';
+ $s .= $topbar_delimiter;
+
+ $delete_url = $base_uri . 'src/delete_message.php?mailbox='.$urlMailbox.
+ '&message='.$passed_id.'&';
+ if (!(isset($passed_ent_id) && $passed_ent_id)) {
+ if ($where && $what) {
+ $delete_url .= 'where=' . urlencode($where) . '&what=' . urlencode($what);
+ } else {
+ $delete_url .= 'sort='. $sort . '&startMessage='. $startMessage;
+ }
+ $s .= '<a href="'. $delete_url.'">'._("Delete").'</a>';
+ }
+
+ $comp_uri = $base_uri . 'src/compose.php'.
+ '?passed_id='.$passed_id.
+ '&mailbox='.$urlMailbox.
+ (isset($passed_ent_id)?'&passed_ent_id='.$passed_ent_id:'');
+
+ if (($mailbox == $draft_folder) && ($save_as_draft)) {
+ $comp_alt_uri = $comp_uri . '&action=draft';
+ $comp_alt_string = _("Resume Draft");
+ } else if ($mailbox == $sent_folder) {
+ $comp_alt_uri = $comp_uri . '&action=edit_as_new';
+ $comp_alt_string = _("Edit Message as New");
+ }
+ if (isset($comp_alt_uri)) {
+ $s .= $topbar_delimiter;
+ if ($compose_new_win == '1') {
+ $s .= '<a href="javascript:void(0)" '.
+ 'onclick="comp_in_new(\''.$comp_alt_uri.'\')">'.$comp_alt_string.'</a>';
+ } else {
+ $s .= '<a href="'.$comp_alt_uri.'">'.$comp_alt_string.'</a>';
+ }
+ }
+
+ $s .= '</small></td><td align="center" width="33%"><small>';
+
+ if (!(isset($where) && isset($what)) && !$passed_ent_id) {
+ $prev = findPreviousMessage($mbx_response['EXISTS'], $passed_id);
+ $next = findNextMessage($passed_id);
+ if ($prev != -1) {
+ $uri = $base_uri . 'src/read_body.php?passed_id='.$prev.
+ '&mailbox='.$urlMailbox.'&sort='.$sort.
+ '&startMessage='.$startMessage.'&show_more=0';
+ $s .= '<a href="'.$uri.'">'._("Previous").'</a>';
+ } else {
+ $s .= _("Previous");
+ }
+ $s .= $topbar_delimiter;
+ if ($next != -1) {
+ $uri = $base_uri . 'src/read_body.php?passed_id='.$next.
+ '&mailbox='.$urlMailbox.'&sort='.$sort.
+ '&startMessage='.$startMessage.'&show_more=0';
+ $s .= '<a href="'.$uri.'">'._("Next").'</a>';
+ } else {
+ $s .= _("Next");
+ }
+ } else if (isset($passed_ent_id) && $passed_ent_id) {
+ /* code for navigating through attached message/rfc822 messages */
+ $url = set_url_var($PHP_SELF, 'passed_ent_id',0);
+ $s .= '<a href="'.$url.'">'._("View Message").'</a>';
+ $par_ent_id = $message->parent->entity_id;
+ if ($par_ent_id) {
+ $par_ent_id = substr($par_ent_id,0,-2);
+ $s .= $topbar_delimiter;
+ $url = set_url_var($PHP_SELF, 'passed_ent_id',$par_ent_id);
+ $s .= '<a href="'.$url.'">'._("Up").'</a>';
+ }
+ }
+
+ $s .= '</small></td><td align="right" width="33%"><small>';
+
+ $comp_action_uri = $comp_uri . '&action=forward';
+ if ($compose_new_win == '1') {
+ $s .= '<a href="javascript:void(0)" '.
+ 'onclick="comp_in_new(\''.$comp_action_uri.'\')">'._("Forward").'</a>';
+ } else {
+ $s .= '<a href="'.$comp_action_uri.'">'._("Forward").'</a>';
+ }
+ $s .= $topbar_delimiter;
+
+ $comp_action_uri = decodeHeader($comp_uri . '&action=reply');
+ if ($compose_new_win == '1') {
+ $s .= '<a href="javascript:void(0)" '.
+ 'onclick="comp_in_new(\''.$comp_action_uri.'\')">'._("Reply").'</a>';
+ } else {
+ $s .= '<a href="'.$comp_action_uri.'">'._("Reply").'</a>';
+ }
+ $s .= $topbar_delimiter;
+
+ $comp_action_uri = $comp_uri . '&action=reply_all';
+ if ($compose_new_win == '1') {
+ $s .= '<a href="javascript:void(0)" '.
+ 'onclick="comp_in_new(\''.$comp_action_uri.'\')">'._("Reply All").'</a>';
+ } else {
+ $s .= '<a href="'.$comp_action_uri.'">'._("Reply All").'</a>';
+ }
+ $s .= '</small></td></tr></table>';
+ echo $s;
+}
+
+function formatToolbar($mailbox, $passed_id, $passed_ent_id, $message, $color) {
+ global $QUERY_STRING, $base_uri;
+
+ $urlMailbox = urlencode($mailbox);
+ $s = '<table width="100%" cellpadding="3" cellspacing="0" align="center"'.
+ ' border="0" bgcolor="'.$color[9].'">'. "\n".
+ '<tr align="right"><td valign="top" align="right"><small>';
+ $url = $base_uri.'src/view_header.php?'.$QUERY_STRING;
+ $s .= '<a href="'.$url.'">'.("View Full Header").'</a>';
+ /* Output the printer friendly link if we are in subtle mode. */
+ $s .= ' | '.
+ printer_friendly_link($mailbox, $passed_id, $passed_ent_id, $color);
+ echo $s;
+ do_hook("read_body_header_right");
+ echo '</small></td></tr>';
+ echo '</table>'."\n";
+}
+
+
+/*
+ * Main of read_boby.php --------------------------------------------------
+ */
+
+/*
+ Urled vars
+ ----------
+ $passed_id
+*/
+
+global $uid_support, $sqimap_capabilities;
+
+if (isset($mailbox)) {
+ $mailbox = urldecode( $mailbox );
+}
+
+$imapConnection = sqimap_login($username, $key, $imapServerAddress,
+ $imapPort, 0);
+
+$mbx_response = sqimap_mailbox_select($imapConnection, $mailbox, false, false, true);
+
+if (!isset($messages)) {
+ $messages = array();
+ session_register('messages');
+}