16 define(
'PAGE_NAME',
'read_body');
22 define(
'SM_PATH',
'../');
25 require_once(
SM_PATH .
'include/validate.php');
26 require_once(
SM_PATH .
'functions/imap.php');
27 require_once(
SM_PATH .
'functions/mime.php');
28 require_once(
SM_PATH .
'functions/date.php');
29 require_once(
SM_PATH .
'functions/url_parser.php');
30 require_once(
SM_PATH .
'functions/html.php');
43 if (!is_array($server_sort_array)) {
44 $thread_sort_messages = 0;
49 $count = count($server_sort_array) - 1;
50 foreach($server_sort_array as $key=>$value) {
51 if ($passed_id == $value) {
55 $result = $server_sort_array[$key + 1];
60 if (is_array($msort)) {
61 for (reset($msort); ($key = key($msort)), (isset($key)); next($msort)) {
62 if ($passed_id ==
$msgs[$key][
'ID']) {
66 $result =
$msgs[$key][
'ID'];
79 $thread_sort_messages,
82 if (!is_array($server_sort_array)) {
83 $thread_sort_messages = 0;
87 foreach($server_sort_array as $key=>$value) {
88 if ($passed_id == $value) {
92 $result = $server_sort_array[$key - 1];
97 if (is_array($msort)) {
98 for (reset($msort); ($key = key($msort)), (isset($key)); next($msort)) {
99 if ($passed_id ==
$msgs[$key][
'ID']) {
103 $result =
$msgs[$key][
'ID'];
135 $params =
'?passed_ent_id=' . urlencode($passed_ent_id) .
137 '&passed_id=' . urlencode($passed_id).
140 $print_text =
_(
"View Printable Version");
145 $result =
'<script language="javascript" type="text/javascript">' .
"\n" .
147 " function printFormat() {\n" .
148 ' window.open("../src/printer_friendly_main.php' .
149 $params .
'","Print","width=800,height=600");' .
"\n".
153 "<a href=\"javascript:printFormat();\">$print_text</a>\n";
155 $result =
'<a target="_blank" href="../src/printer_friendly_bottom.php' .
156 "$params\">$print_text</a>\n";
163 $ret = preg_match(
'/(\x36MDNSent|\\\\\*)/i',
$read);
179 $content_type =
new ContentType(
'multipart/report');
180 $content_type->properties[
'report-type']=
'disposition-notification';
193 if (isset($identity) && $identity !=
'default') {
195 'email_address' . $identity);
197 'full_name' . $identity);
198 $from_addr =
'"'.$full_name.
'" <'.$from_mail.
'>';
200 'reply_to' . $identity);
204 $from_addr =
'"'.$full_name.
'" <'.$from_mail.
'>';
211 if (preg_match(
'|^([^@%/]+)[@%/](.+)$|',
$username, $usernamedata)) {
212 $popuser = $usernamedata[1];
214 unset($usernamedata);
220 $from_mail =
"$popuser@$domain";
221 $from_addr = $from_mail;
233 foreach ($to_array as $line) {
234 $to .=
' '.$line->getAddress();
238 $body =
_(
"Your message") .
"\r\n\r\n" .
241 "\t" .
_(
"Sent") .
': ' . $senton .
"\r\n" .
243 sprintf(
_(
"Was displayed on %s"), $now );
245 $special_encoding =
'';
250 if (mb_detect_encoding(
$body) ==
'ASCII') {
251 $special_encoding =
'8bit';
254 $special_encoding =
'7bit';
259 $special_encoding =
'8bit';
262 $part1->setBody(
$body);
264 $mime_header->type0 =
'text';
265 $mime_header->type1 =
'plain';
266 if ($special_encoding) {
267 $mime_header->encoding = $special_encoding;
269 $mime_header->encoding =
'7bit';
274 $part1->mime_header = $mime_header;
277 $original_recipient =
$to;
278 $original_message_id =
$header->message_id;
280 $report =
"Reporting-UA : $SERVER_NAME ; SquirrelMail (version $version) \r\n";
281 if ($original_recipient !=
'') {
282 $report .=
"Original-Recipient : $original_recipient\r\n";
284 $final_recipient = $sender;
285 $report .=
"Final-Recipient: rfc822; $final_recipient\r\n" .
286 "Original-Message-ID : $original_message_id\r\n" .
287 "Disposition: manual-action/MDN-sent-manually; displayed\r\n";
290 $part2->setBody($report);
292 $mime_header->type0 =
'message';
293 $mime_header->type1 =
'disposition-notification';
294 $mime_header->encoding =
'7bit';
295 $part2->mime_header = $mime_header;
297 $composeMessage =
new Message();
299 $composeMessage->addEntity($part1);
300 $composeMessage->addEntity($part2);
304 require_once(
SM_PATH .
'class/deliver/Deliver_SendMail.class.php');
317 require_once(
SM_PATH .
'class/deliver/Deliver_SMTP.class.php');
335 $deliver->mail($composeMessage,
$stream);
336 $success = $deliver->finalizeStream(
$stream);
339 $msg =
_(
"Message not sent.") .
' '.
_(
"Server replied:") .
340 "\n<blockquote>\n" . $deliver->dlv_msg .
'<br />' .
341 $deliver->dlv_ret_nr .
' ' .
342 $deliver->dlv_server_msg .
"</blockquote>\n\n";
343 require_once(
SM_PATH .
'functions/display_messages.php');
351 $svr_allow_sent =
true;
353 $svr_allow_sent =
false;
363 if ((isset($move_to_sent) && ($move_to_sent != 0)) || (!isset($move_to_sent))) {
364 $lcl_allow_sent =
true;
366 $lcl_allow_sent =
false;
369 if (($fld_sent && $svr_allow_sent && !$lcl_allow_sent) || ($fld_sent && $lcl_allow_sent)) {
370 require_once(
SM_PATH .
'class/deliver/Deliver_IMAP.class.php');
373 unset ($imap_deliver);
381 $cmd =
'STORE ' . $passed_id .
' ' . $sg .
'FLAGS ($MDNSent)';
387 global $show_more_cc, $show_more, $show_more_bcc,
391 if ((is_array($recipients)) && (isset($recipients[0]))) {
401 }
else if ($item ==
'cc') {
408 }
else if ($item ==
'bcc') {
409 if ($show_more_bcc) {
417 $cnt = count($recipients);
418 foreach($recipients as
$r) {
421 $string .=
'<br />' . $add;
425 $string .=
' (<a href="'.$url;
427 $string .=
'">'._(
"less").
'</a>)';
429 $string .=
'">'._(
"more").
'</a>)';
448 $from_name =
$header->getAddr_s(
'from');
450 $from_name =
$header->getAddr_s(
'sender');
452 $from_name =
_(
"Unknown sender");
470 $env[
_(
"Read receipt")] =
_(
"sent");
472 $env[
_(
"Read receipt")] =
_(
"requested");
478 $mdn_url =
set_url_var($mdn_url,
'passed_id', $passed_id);
479 $mdn_url =
set_url_var($mdn_url,
'passed_ent_id', $passed_ent_id);
480 $mdn_url =
set_url_var($mdn_url,
'sendreceipt', 1);
482 $script =
'<script language="JavaScript" type="text/javascript">' .
"\n";
483 $script .=
'<!--'.
"\n";
484 $script .=
'if(window.confirm("' .
485 _(
"The message sender has requested a response to indicate that you have read this message. Would you like to send a receipt?") .
489 $script .=
'// -->'.
"\n";
490 $script .=
'</script>'.
"\n";
493 $env[
_(
"Read receipt")] .=
' <a href="' . $mdn_url .
'">[' .
494 _(
"Send read receipt now") .
']</a>';
501 $s =
'<table width="100%" cellpadding="0" cellspacing="2" border="0"';
502 $s .=
' align="center" bgcolor="'.$color[0].
'">';
503 foreach ($env as $key => $val) {
506 $s .=
html_tag(
'td',
'<b>' . $key .
': </b>',
'right',
'',
'valign="top" width="20%"') .
"\n";
507 $s .=
html_tag(
'td', $val,
'left',
'',
'valign="top" width="80%"') .
"\n";
511 echo
'<table bgcolor="'.$color[9].
'" width="100%" cellpadding="1"'.
512 ' cellspacing="0" border="0" align="center">'.
"\n";
513 echo
'<tr><td height="5" colspan="2" bgcolor="'.
514 $color[4].
'"></td></tr><tr><td align="center">'.
"\n";
519 echo
'</td></tr><tr><td height="5" colspan="2" bgcolor="'.$color[4].
'"></td></tr>'.
"\n";
528 $topbar_delimiter =
' | ';
530 $s =
'<table width="100%" cellpadding="3" cellspacing="0" align="center"'.
531 ' border="0" bgcolor="'.$color[9].
'"><tr>' .
532 html_tag(
'td',
'',
'left',
'',
'width="33%"' ) .
'<small>';
535 if (isset($where) && isset($what)) {
537 '&what=' . urlencode($what) .
'&mailbox=' . $urlMailbox;
538 $msgs_str =
_(
"Search Results");
540 $msgs_url .=
'right_main.php?sort=' .
$sort .
'&startMessage=' .
541 $startMessage .
'&mailbox=' . $urlMailbox;
542 $msgs_str =
_(
"Message List");
544 $s .=
'<a href="' . $msgs_url .
'">' . $msgs_str .
'</a>';
546 $delete_url =
$base_uri .
'src/delete_message.php?mailbox=' . $urlMailbox .
549 if (!(isset($passed_ent_id) && $passed_ent_id)) {
550 if ($where && $what) {
551 $unread_url .=
'search.php?unread_passed_id=' . $passed_id .
'&smtoken=' .
sm_generate_security_token() .
'&where=' . urlencode($where) .
'&what=' . urlencode($what) .
'&mailbox=' . $urlMailbox;
553 $unread_url .=
'right_main.php?unread_passed_id=' . $passed_id .
'&sort=' .
$sort .
'&startMessage=' . $startMessage .
'&mailbox=' . $urlMailbox;
555 $s .= $topbar_delimiter;
556 $s .=
'<a href="' . $unread_url .
'">' .
_(
"Unread") .
'</a>';
558 if ($where && $what) {
559 $delete_url .=
'where=' . urlencode($where) .
'&what=' . urlencode($what);
561 $delete_url .=
'sort=' .
$sort .
'&startMessage=' . $startMessage;
563 $s .= $topbar_delimiter;
564 $s .=
'<a href="' . $delete_url .
'">' .
_(
"Delete") .
'</a>';
567 $comp_uri =
'src/compose.php' .
568 '?passed_id=' . $passed_id .
569 '&mailbox=' . $urlMailbox .
570 '&startMessage=' . $startMessage .
571 (isset($passed_ent_id)?
'&passed_ent_id='.urlencode($passed_ent_id):
'');
574 $comp_alt_uri = $comp_uri .
'&smaction=draft';
575 $comp_alt_string =
_(
"Resume Draft");
577 $comp_alt_uri = $comp_uri .
'&smaction=edit_as_new';
578 $comp_alt_string =
_(
"Edit Message as New");
580 if (isset($comp_alt_uri)) {
581 $s .= $topbar_delimiter;
585 $s .=
'</small></td><td align="center" width="33%"><small>';
587 if (!(isset($where) && isset($what)) && !$passed_ent_id) {
591 $uri =
$base_uri .
'src/read_body.php?passed_id='.$prev.
592 '&mailbox='.$urlMailbox.
'&sort='.
$sort.
593 '&startMessage='.$startMessage.
'&show_more=0';
594 $s .=
'<a href="'.$uri.
'">'.
_(
"Previous").
'</a>';
598 $s .= $topbar_delimiter;
600 $uri =
$base_uri .
'src/read_body.php?passed_id='.$next.
601 '&mailbox='.$urlMailbox.
'&sort='.
$sort.
602 '&startMessage='.$startMessage.
'&show_more=0';
603 $s .=
'<a href="'.$uri.
'">'.
_(
"Next").
'</a>';
607 }
else if (isset($passed_ent_id) && $passed_ent_id) {
610 $s .=
'<a href="'.$url.
'">'.
_(
"View Message").
'</a>';
612 $entity_count = array();
615 foreach(
$message->parent->entities as $ent) {
616 if ($ent->type0 ==
'message' && $ent->type1 ==
'rfc822') {
618 $entity_count[$c] = $ent->entity_id;
623 $prev_link =
_(
"Previous");
625 $prev_ent_id = $entity_count[
$entities[$passed_ent_id] - 1];
626 $prev_link =
'<a href="' 628 .
'">' . $prev_link .
'</a>';
631 $next_link =
_(
"Next");
633 $next_ent_id = $entity_count[
$entities[$passed_ent_id] + 1];
634 $next_link =
'<a href="' 636 .
'">' . $next_link .
'</a>';
638 $s .= $topbar_delimiter . $prev_link;
639 $par_ent_id =
$message->parent->entity_id;
641 $par_ent_id = substr($par_ent_id,0,-2);
642 $s .= $topbar_delimiter;
644 $s .=
'<a href="'.$url.
'">'.
_(
"Up").
'</a>';
646 $s .= $topbar_delimiter . $next_link;
649 $s .=
'</small></td>' .
"\n" .
650 html_tag(
'td',
'',
'right',
'',
'width="33%" nowrap' ) .
'<small>';
651 $comp_action_uri = $comp_uri .
'&smaction=forward';
655 $comp_action_uri = $comp_uri .
'&smaction=forward_as_attachment';
656 $s .= $topbar_delimiter;
660 $comp_action_uri = $comp_uri .
'&smaction=reply';
661 $s .= $topbar_delimiter;
664 $comp_action_uri = $comp_uri .
'&smaction=reply_all';
665 $s .= $topbar_delimiter;
667 $s .=
'</small></td></tr></table>';
673 do_hook(
'read_body_menu_bottom');
677 global
$base_uri, $where, $what, $download_and_unsafe_link;
680 $urlPassed_id = urlencode($passed_id);
681 $urlPassed_ent_id = urlencode($passed_ent_id);
683 $query_string =
'mailbox=' . $urlMailbox .
'&passed_id=' . $urlPassed_id .
'&passed_ent_id=' . $urlPassed_ent_id;
685 if (!empty($where)) {
686 $query_string .=
'&where=' . urlencode($where);
690 $query_string .=
'&what=' . urlencode($what);
696 html_tag(
'td',
'',
'right',
'',
'valign="middle" width="20%"' ) .
'<b>' .
_(
"Options") .
": </b></td>\n" .
697 html_tag(
'td',
'',
'left',
'',
'valign="middle" width="80%"' ) .
'<small>' .
698 '<a href="'.$url.
'">'.
_(
"View Full Header").
'</a>';
701 $s .=
' | ' .
706 if ($download_and_unsafe_link) {
707 echo $download_and_unsafe_link;
710 do_hook(
"read_body_header_right");
711 $s =
"</small></td>\n" .
742 $show_more = (int) $temp;
745 $show_more_cc = (int) $temp;
748 $show_more_bcc = (int) $temp;
751 $view_hdr = (int) $temp;
762 $passed_id = (int) $temp;
768 $startMessage = (int) $temp;
799 if (isset($passed_ent_id) && $passed_ent_id) {
828 if (isset($sendreceipt)) {
830 if (isset($identity) ) {
836 $final_recipient = trim($final_recipient);
837 if ($final_recipient ==
'' ) {
852 $msgs[$passed_id][
'FLAG_SEEN'] =
true;
857 $ent_ar =
$message->findDisplayEntity(array());
859 $ent_ar =
$message->findDisplayEntity(array(), array(
'text/plain'));
862 for ($i = 0; $i <
$cnt; $i++) {
872 echo
'<table width="100%" cellpadding="0" cellspacing="0" align="center" border="0">';
874 echo
' <table width="100%" cellpadding="1" cellspacing="0" align="center" border="0" bgcolor="'.$color[9].
'">';
876 echo
' <table width="100%" cellpadding="3" cellspacing="0" align="center" border="0">';
877 echo
' <tr bgcolor="'.$color[4].
'"><td>';
879 echo
html_tag(
'table' ,
'' ,
'left',
'',
'cellpadding="1" cellspacing="5" border="0"' );
884 echo
' </table></td></tr>';
888 echo
'<tr><td height="5" colspan="2" bgcolor="'.
889 $color[4].
'"></td></tr>'.
"\n";
894 echo
' <table width="100%" cellpadding="1" cellspacing="0" align="center"'.
' border="0" bgcolor="'.
$color[9].
'">';
896 echo
' <table width="100%" cellpadding="0" cellspacing="0" align="center" border="0" bgcolor="'.$color[4].
'">';
898 echo
' <b>' .
_(
"Attachments") .
':</b>';
901 echo
' <table width="100%" cellpadding="2" cellspacing="2" align="center"'.
' border="0" bgcolor="'.
$color[0].
'"><tr><td>';
903 echo
' </td></tr></table>';
904 echo
' </td></tr></table>';
905 echo
' </td></tr></table>';
907 echo
'<tr><td height="5" colspan="2" bgcolor="'.
916 $imgurl =
SM_PATH .
'src/download.php' .
918 'passed_id=' . urlencode($img[
'passed_id']) .
919 '&mailbox=' . urlencode(
$mailbox) .
920 '&ent_id=' . urlencode($img[
'ent_id']) .
921 '&absolute_dl=true';
925 html_tag(
'td',
'<img src="' . $imgurl .
'" />' .
"\n",
'left' 928 'center',
'',
'cellspacing="0" border="0" cellpadding="2"');