e0b50bbd3e4bcc60129a0ec16693c9734722dc15
6 * Copyright (c) 1999-2002 The SquirrelMail Project Team
7 * Licensed under the GNU GPL. For full terms see the file COPYING.
9 * This code sends a mail.
11 * There are 4 modes of operation:
20 require_once('../src/validate.php');
21 require_once('../functions/imap.php');
22 require_once('../functions/date.php');
23 require_once('../functions/mime.php');
24 require_once('../functions/smtp.php');
25 require_once('../functions/display_messages.php');
26 require_once('../functions/plugin.php');
28 if (!isset($attachments)) {
29 $attachments = array();
30 session_register('attachments');
33 if (!isset($mailbox) ||
$mailbox == '' ||
($mailbox == 'None')) {
38 include_once ('../src/draft_actions.php');
39 if (! isset($reply_id)) {
45 if (!saveMessageAsDraft($send_to, $send_to_cc, $send_to_bcc, $subject, $body, $reply_id, $MDN)) {
49 $draft_message = _("Draft Email Saved");
50 /* If this is a resumed draft, then delete the original */
51 if(isset($delete_draft)) {
52 Header("Location: delete_message.php?mailbox=$draft_folder".
53 "&message=$delete_draft&sort=$sort&startMessage=1&saved_draft=yes");
57 if ($compose_new_win == '1') {
58 Header("Location: compose.php?saved_draft=yes");
62 Header("Location: right_main.php?mailbox=$draft_folder&sort=$sort".
63 "&startMessage=1¬e=$draft_message");
71 if (isset($HTTP_POST_FILES['attachfile']) &&
72 $HTTP_POST_FILES['attachfile']['tmp_name'] &&
73 $HTTP_POST_FILES['attachfile']['tmp_name'] != 'none') {
74 $AttachFailure = saveAttachedFiles();
76 if (checkInput(false) && !isset($AttachFailure)) {
77 $urlMailbox = urlencode (trim($mailbox));
78 if (! isset($reply_id)) {
82 * Set $default_charset to correspond with the user's selection
83 * of language interface.
88 * This is to change all newlines to \n
89 * We'll change them to \r\n later (in the sendMessage function)
91 $body = str_replace("\r\n", "\n", $body);
92 $body = str_replace("\r", "\n", $body);
95 * Rewrap $body so that no line is bigger than $editor_size
96 * This should only really kick in the sqWordWrap function
97 * if the browser doesn't support "HARD" as the wrap type
98 * Or, in Opera's case, something goes wrong.
100 $body = explode("\n", $body);
102 foreach ($body as $line) {
103 if( $line <> '-- ' ) {
104 $line = rtrim($line);
106 if (strlen($line) <= $editor_size +
1) {
107 $newBody .= $line . "\n";
109 sqWordWrap($line, $editor_size) . "\n";
115 do_hook("compose_send");
117 $MDN = False; // we are not sending a mdn response
118 if (! isset($mailprio)) {
119 $Result = sendMessage($send_to, $send_to_cc, $send_to_bcc,
120 $subject, $body, $reply_id, $MDN);
122 $Result = sendMessage($send_to, $send_to_cc, $send_to_bcc,
123 $subject, $body, $reply_id, $MDN, $mailprio);
129 if ( isset($delete_draft)) {
130 Header("Location: delete_message.php?mailbox=$draft_folder".
131 "&message=$delete_draft&sort=$sort&startMessage=1&mail_sent=yes");
134 if ($compose_new_win == '1') {
135 Header("Location: compose.php?mail_sent=yes");
138 Header("Location: right_main.php?mailbox=$urlMailbox&sort=$sort".
143 *$imapConnection = sqimap_login($username, $key, $imapServerAddress,
146 if ($compose_new_win == '1') {
147 compose_Header($color, $mailbox);
150 displayPageHeader($color, $mailbox);
152 if (isset($AttachFailure)) {
153 plain_error_message(_("Could not move/copy file. File not attached"),
159 /* sqimap_logout($imapConnection); */
162 elseif (isset($html_addr_search_done)) {
163 if ($compose_new_win == '1') {
164 compose_Header($color, $mailbox);
167 displayPageHeader($color, $mailbox);
170 if (isset($send_to_search) && is_array($send_to_search)) {
171 foreach ($send_to_search as $k => $v) {
172 if (substr($k, 0, 1) == 'T') {
178 elseif (substr($k, 0, 1) == 'C') {
184 elseif (substr($k, 0, 1) == 'B') {
186 $send_to_bcc .= ', ';
194 elseif (isset($html_addr_search)) {
195 if (isset($HTTP_POST_FILES['attachfile']) &&
196 $HTTP_POST_FILES['attachfile']['tmp_name'] &&
197 $HTTP_POST_FILES['attachfile']['tmp_name'] != 'none') {
198 if (saveAttachedFiles()) {
199 plain_error_message(_("Could not move/copy file. File not attached"), $color);
203 * I am using an include so as to elminiate an extra unnecessary
204 * click. If you can think of a better way, please implement it.
206 include_once('./addrbook_search_html.php');
208 elseif (isset($attach)) {
209 if (saveAttachedFiles()) {
210 plain_error_message(_("Could not move/copy file. File not attached"), $color);
212 if ($compose_new_win == '1') {
213 compose_Header($color, $mailbox);
216 displayPageHeader($color, $mailbox);
220 elseif (isset($do_delete)) {
221 if ($compose_new_win == '1') {
222 compose_Header($color, $mailbox);
225 displayPageHeader($color, $mailbox);
228 $hashed_attachment_dir = getHashedDir($username, $attachment_dir);
229 if (isset($delete) && is_array($delete)) {
230 foreach($delete as $index) {
231 $attached_file = $hashed_attachment_dir . '/'
232 . $attachments[$index]['localfilename'];
233 unlink ($attached_file);
234 unset ($attachments[$index]);
241 * This handles the default case as well as the error case
242 * (they had the same code) --> if (isset($smtpErrors))
244 $imapConnection = sqimap_login($username, $key, $imapServerAddress,
246 if ($compose_new_win == '1') {
247 compose_Header($color, $mailbox);
250 displayPageHeader($color, $mailbox);
257 if (isset($forward_id) && $forward_id && isset($ent_num) && $ent_num) {
261 if (isset($draft_id) && $draft_id && isset($ent_num) && $ent_num) {
267 sqimap_logout($imapConnection);
273 /**************** Only function definitions go below *************/
276 /* This function is used when not sending or adding attachments */
277 function newMail () {
278 global $forward_id, $imapConnection, $msg, $ent_num, $body_ary, $body,
279 $reply_id, $send_to, $send_to_cc, $mailbox, $send_to_bcc, $editor_size,
280 $draft_id, $use_signature;
282 $send_to = decodeHeader($send_to, false);
283 $send_to_cc = decodeHeader($send_to_cc, false);
284 $send_to_bcc = decodeHeader($send_to_bcc, false);
288 } elseif ($reply_id) {
294 $use_signature = FALSE;
298 sqimap_mailbox_select($imapConnection, $mailbox);
299 $message = sqimap_get_message($imapConnection, $id, $mailbox);
300 $orig_header = $message->header
;
302 $message = getEntity($message, $ent_num);
304 if ($message->header
->type0
== 'text' ||
305 $message->header
->type1
== 'message') {
308 mime_fetch_body($imapConnection, $id, $ent_num),
309 $message->header
->encoding
);
312 mime_fetch_body($imapConnection, $id, 1),
313 $message->header
->encoding
);
319 if ($message->header
->type1
== 'html') {
320 $body = strip_tags($body);
324 $body_ary = explode("\n", $body);
325 $i = count($body_ary) - 1;
326 while ($i >= 0 && ereg("^[>\\s]*$", $body_ary[$i])) {
327 unset($body_ary[$i]);
331 for ($i=0; isset($body_ary[$i]); $i++
) {
333 if (ereg('^[ >]+', $body_ary[$i])) {
334 $body_ary[$i] = '>' . $body_ary[$i];
336 $body_ary[$i] = '> ' . $body_ary[$i];
340 sqWordWrap($body_ary[$i], $editor_size - 1);
342 $body .= $body_ary[$i] . "\n";
343 unset($body_ary[$i]);
346 $bodyTop = '-------- ' . _("Original Message") . " --------\n" .
347 _("Subject") . ': ' . $orig_header->subject
. "\n" .
348 _("From") . ': ' . $orig_header->from
. "\n" .
350 getLongDateString( $orig_header->date
). "\n" .
351 _("To") . ': ' . $orig_header->to
[0] . "\n";
352 if (count($orig_header->to
) > 1) {
353 for ($x=1; $x < count($orig_header->to
); $x++
) {
354 $bodyTop .= ' ' . $orig_header->to
[$x] . "\n";
358 $body = $bodyTop . $body;
361 $orig_from = decodeHeader($orig_header->from
, false);
362 $body = getReplyCitation($orig_from) . $body;
369 $send_to = sqimap_find_email($send_to);
372 /* This formats a CC string if they hit "reply all" */
373 if ($send_to_cc != '') {
374 $send_to_cc = ereg_replace('"[^"]*"', '', $send_to_cc);
375 $send_to_cc = str_replace(';', ',', $send_to_cc);
376 $sendcc = explode(',', $send_to_cc);
379 for ($i = 0; $i < count($sendcc); $i++
) {
380 $sendcc[$i] = trim($sendcc[$i]);
381 if ($sendcc[$i] == '') {
385 $sendcc[$i] = sqimap_find_email($sendcc[$i]);
386 $whofrom = sqimap_find_displayable_name($msg['HEADER']['FROM']);
387 $whoreplyto = sqimap_find_email($msg['HEADER']['REPLYTO']);
389 if ((strtolower(trim($sendcc[$i])) != strtolower(trim($whofrom))) &&
390 (strtolower(trim($sendcc[$i])) != strtolower(trim($whoreplyto))) &&
391 (trim($sendcc[$i]) != '')) {
392 $send_to_cc .= trim($sendcc[$i]) . ', ';
395 $send_to_cc = trim($send_to_cc);
396 if (substr($send_to_cc, -1) == ',') {
397 $send_to_cc = substr($send_to_cc, 0, strlen($send_to_cc) - 1);
400 } /* function newMail() */
403 function getAttachments($message) {
404 global $mailbox, $attachments, $attachment_dir, $imapConnection,
405 $ent_num, $forward_id, $draft_id, $username;
407 if (isset($draft_id)) {
414 sqimap_mailbox_select($imapConnection, $mailbox);
415 $message = sqimap_get_message($imapConnection, $id, $mailbox);
418 $hashed_attachment_dir = getHashedDir($username, $attachment_dir);
419 if (count($message->entities
) == 0) {
420 if ($message->header
->entity_id
!= $ent_num) {
421 $filename = decodeHeader($message->header
->filename
);
423 if ($filename == "") {
424 $filename = "untitled-".$message->header
->entity_id
;
427 $localfilename = GenerateRandomString(32, '', 7);
428 $full_localfilename = "$hashed_attachment_dir/$localfilename";
429 while (file_exists($full_localfilename)) {
430 $localfilename = GenerateRandomString(32, '', 7);
431 $full_localfilename = "$hashed_attachment_dir/$localfilename";
434 $newAttachment = array();
435 $newAttachment['localfilename'] = $localfilename;
436 $newAttachment['remotefilename'] = $filename;
437 $newAttachment['type'] = strtolower($message->header
->type0
.
438 '/' . $message->header
->type1
);
440 /* Write Attachment to file */
441 $fp = fopen ("$hashed_attachment_dir/$localfilename", 'w');
442 fputs($fp, decodeBody(mime_fetch_body($imapConnection,
443 $id, $message->header
->entity_id
),
444 $message->header
->encoding
));
447 $attachments[] = $newAttachment;
450 for ($i = 0; $i < count($message->entities
); $i++
) {
451 getAttachments($message->entities
[$i]);
457 function showInputForm () {
458 global $send_to, $send_to_cc, $reply_subj, $forward_subj, $body,
459 $passed_body, $color, $use_signature, $signature, $prefix_sig,
460 $editor_size, $attachments, $subject, $newmail,
461 $use_javascript_addr_book, $send_to_bcc, $reply_id, $mailbox,
462 $from_htmladdr_search, $location_of_buttons, $attachment_dir,
463 $username, $data_dir, $identity, $draft_id, $delete_draft,
464 $mailprio, $default_use_mdn, $mdn_user_support, $compose_new_win,
465 $saved_draft, $mail_sent;
467 $subject = decodeHeader($subject, false);
468 $reply_subj = decodeHeader($reply_subj, false);
469 $forward_subj = decodeHeader($forward_subj, false);
471 if ($use_javascript_addr_book) {
472 echo "\n". '<SCRIPT LANGUAGE=JavaScript><!--' . "\n" .
473 'function open_abook() { ' . "\n" .
474 ' var nwin = window.open("addrbook_popup.php","abookpopup",' .
475 '"width=670,height=300,resizable=yes,scrollbars=yes");' . "\n" .
476 ' if((!nwin.opener) && (document.windows != null))' . "\n" .
477 ' nwin.opener = document.windows;' . "\n" .
479 '// --></SCRIPT>' . "\n\n";
482 echo "\n" . '<FORM name=compose action="compose.php" METHOD=POST ' .
483 'ENCTYPE="multipart/form-data"';
484 do_hook("compose_form");
489 if (isset($draft_id)) {
490 echo '<input type="hidden" name="delete_draft" value="' . $draft_id . "\">\n";
492 if (isset($delete_draft)) {
493 echo '<input type="hidden" name="delete_draft" value="' . $delete_draft. "\">\n";
495 if ($saved_draft == 'yes') {
496 echo '<BR><CENTER><B>'. _("Draft Saved").'</CENTER></B>';
498 if ($mail_sent == 'yes') {
499 echo '<BR><CENTER><B>'. _("Your Message has been sent").'</CENTER></B>';
501 echo '<TABLE WIDTH="100%" ALIGN=center CELLSPACING=0 BORDER=0>' . "\n";
502 if ($compose_new_win == '1') {
503 echo ' <TR><TD></TD><TD ALIGN="RIGHT"><INPUT TYPE="BUTTON" NAME="Close" onClick="return self.close()" VALUE='._("Close").'></TD></TR>'."\n";
505 if ($location_of_buttons == 'top') {
506 showComposeButtonRow();
509 $idents = getPref($data_dir, $username, 'identities', 0);
511 echo ' <TR>' . "\n" .
512 ' <TD BGCOLOR="' . $color[4] . '" WIDTH="10%" ALIGN=RIGHT>' .
515 ' </TD><TD BGCOLOR="' . $color[4] . '" WIDTH="90%">' . "\n" .
516 '<select name=identity>' . "\n" .
517 '<option value=default>' .
518 htmlspecialchars(getPref($data_dir, $username, 'full_name'));
519 $em = getPref($data_dir, $username, 'email_address');
521 echo htmlspecialchars(' <' . $em . '>') . "\n";
523 for ($i = 1; $i < $idents; $i ++
) {
524 echo '<option value="' . $i . '"';
525 if (isset($identity) && $identity == $i) {
528 echo '>' . htmlspecialchars(getPref($data_dir, $username,
530 $em = getPref($data_dir, $username, 'email_address' . $i);
532 echo htmlspecialchars(' <' . $em . '>') . "\n";
536 echo '</select>' . "\n" .
540 echo ' <TR>' . "\n" .
541 ' <TD BGCOLOR="' . $color[4] . '" WIDTH="10%" ALIGN=RIGHT>' . "\n" .
543 ' </TD><TD BGCOLOR="' . $color[4] . '" WIDTH="90%">' . "\n" .
544 ' <INPUT TYPE=text NAME="send_to" VALUE="' .
545 htmlspecialchars($send_to) . '" SIZE=60><BR>' . "\n" .
549 ' <TD BGCOLOR="' . $color[4] . '" ALIGN=RIGHT>' . "\n" .
551 ' </TD><TD BGCOLOR="' . $color[4] . '" ALIGN=LEFT>' . "\n" .
552 ' <INPUT TYPE=text NAME="send_to_cc" SIZE=60 VALUE="' .
553 htmlspecialchars($send_to_cc) . '"><BR>' . "\n" .
557 ' <TD BGCOLOR="' . $color[4] . '" ALIGN=RIGHT>' . "\n" .
559 ' </TD><TD BGCOLOR="' . $color[4] . '" ALIGN=LEFT>' . "\n" .
560 ' <INPUT TYPE=text NAME="send_to_bcc" VALUE="' .
561 htmlspecialchars($send_to_bcc) . '" SIZE=60><BR>' . "\n" .
562 '</TD></TR>' . "\n" .
564 ' <TD BGCOLOR="' . $color[4] . '" ALIGN=RIGHT>' . "\n" .
566 ' </TD><TD BGCOLOR="' . $color[4] . '" ALIGN=LEFT>' . "\n";
568 $reply_subj = str_replace('"', "'", $reply_subj);
569 $reply_subj = trim($reply_subj);
570 if (substr(strtolower($reply_subj), 0, 3) != 're:') {
571 $reply_subj = 'Re: ' . $reply_subj;
573 echo ' <INPUT TYPE=text NAME=subject SIZE=60 VALUE="' .
574 htmlspecialchars($reply_subj) . '">';
576 elseif ($forward_subj) {
577 $forward_subj = trim($forward_subj);
578 if ((substr(strtolower($forward_subj), 0, 4) != 'fwd:') &&
579 (substr(strtolower($forward_subj), 0, 5) != '[fwd:') &&
580 (substr(strtolower($forward_subj), 0, 6) != '[ fwd:')) {
581 $forward_subj = '[Fwd: ' . $forward_subj . ']';
583 echo ' <INPUT TYPE=text NAME=subject SIZE=60 VALUE="' .
584 htmlspecialchars($forward_subj) . '">';
586 echo ' <INPUT TYPE=text NAME=subject SIZE=60 VALUE="' .
587 htmlspecialchars($subject) . '">';
589 echo '</td></tr>' . "\n\n";
591 if ($location_of_buttons == 'between') {
592 showComposeButtonRow();
595 echo ' <TR>' . "\n" .
596 ' <TD BGCOLOR="' . $color[4] . '" COLSPAN=2>' . "\n" .
597 ' <TEXTAREA NAME=body ROWS=20 COLS="' .
598 $editor_size . '" WRAP=HARD>' . htmlspecialchars($body);
599 if ($use_signature == true && $newmail == true && !isset($from_htmladdr_search)) {
600 echo "\n\n".($prefix_sig==true?
"-- \n":'').htmlspecialchars($signature);
602 echo '</TEXTAREA><BR>' . "\n" .
606 if ($location_of_buttons == 'bottom') {
607 showComposeButtonRow();
609 echo ' <TR><TD COLSPAN=2 ALIGN=LEFT>';
610 echo ' <INPUT TYPE=SUBMIT NAME=send VALUE="' . _("Send") . '"></TD></TR>' . "\n";
613 /* This code is for attachments */
614 echo ' <TR>' . "\n" .
615 ' <TD VALIGN=MIDDLE ALIGN=RIGHT>' . "\n" .
618 ' <TD VALIGN=MIDDLE ALIGN=LEFT>' . "\n" .
619 ' <INPUT NAME="attachfile" SIZE=48 TYPE="file">' . "\n" .
620 ' <input type="submit" name="attach"' .
621 ' value="' . _("Add") .'">' . "\n" .
625 if (count($attachments)) {
626 $hashed_attachment_dir = getHashedDir($username, $attachment_dir);
627 echo '<tr><td bgcolor="' . $color[0] . '" align=right>' . "\n" .
629 '</td><td align=left bgcolor="' . $color[0] . '">';
630 foreach ($attachments as $key => $info) {
631 $attached_file = "$hashed_attachment_dir/$info[localfilename]";
632 echo '<input type="checkbox" name="delete[]" value="' . $key . "\">\n" .
633 $info['remotefilename'] . ' - ' . $info['type'] . ' (' .
634 show_readable_size(filesize($attached_file)) . ")<br>\n";
637 echo '<input type="submit" name="do_delete" value="' .
638 _("Delete selected attachments") . "\">\n" .
641 /* End of attachment code */
643 echo '</TABLE>' . "\n";
645 echo '<input type=hidden name=reply_id value=' . $reply_id . ">\n";
647 echo '<INPUT TYPE=hidden NAME=mailbox VALUE="' . htmlspecialchars($mailbox) .
650 do_hook('compose_bottom');
651 echo '</BODY></HTML>' . "\n";
655 function showComposeButtonRow() {
656 global $use_javascript_addr_book, $save_as_draft,
657 $default_use_priority, $mailprio, $default_use_mdn,
658 $data_dir, $username;
660 echo " <TR><TD>\n</TD><TD>\n";
661 if ($default_use_priority) {
662 if(!isset($mailprio)) {
665 echo _("Priority") .': <select name="mailprio">'.
666 '<option value="1"'.($mailprio=='1'?
' selected':'').'>'. _("High") .'</option>'.
667 '<option value="3"'.($mailprio=='3'?
' selected':'').'>'. _("Normal") .'</option>'.
668 '<option value="5"'.($mailprio=='5'?
' selected':'').'>'. _("Low").'</option>'.
671 $mdn_user_support=getPref($data_dir, $username, 'mdn_user_support',$default_use_mdn);
672 if ($default_use_mdn) {
673 if ($mdn_user_support) {
674 echo "\n\t". _("Receipt") .': '.
675 '<input type="checkbox" name="request_mdn" value=1>'. _("On read").
676 ' <input type="checkbox" name="request_dr" value=1>'. _("On Delivery");
680 echo " <TR><td>\n </td><td>\n";
681 if ($use_javascript_addr_book) {
682 echo " <SCRIPT LANGUAGE=JavaScript><!--\n document.write(\"".
683 " <input type=button value=\\\""._("Addresses").
684 "\\\" onclick='javascript:open_abook();'>\");".
685 " // --></SCRIPT><NOSCRIPT>\n".
686 " <input type=submit name=\"html_addr_search\" value=\"".
687 _("Addresses")."\">".
690 echo " <input type=submit name=\"html_addr_search\" value=\"".
691 _("Addresses")."\">";
693 echo "\n <INPUT TYPE=SUBMIT NAME=send VALUE=\"". _("Send") . "\">\n";
695 if ($save_as_draft) {
696 echo '<input type="submit" name ="draft" value="' . _("Save Draft") . "\">\n";
699 do_hook('compose_button_row');
701 echo " </TD></TR>\n\n";
704 function checkInput ($show) {
706 * I implemented the $show variable because the error messages
707 * were getting sent before the page header. So, I check once
708 * using $show=false, and then when i'm ready to display the error
711 global $body, $send_to, $subject, $color;
713 if ($send_to == "") {
715 plain_error_message(_("You have not filled in the \"To:\" field."), $color);
720 } /* function checkInput() */
723 /* True if FAILURE */
724 function saveAttachedFiles() {
725 global $HTTP_POST_FILES, $attachment_dir, $attachments, $username;
727 $hashed_attachment_dir = getHashedDir($username, $attachment_dir);
728 $localfilename = GenerateRandomString(32, '', 7);
729 $full_localfilename = "$hashed_attachment_dir/$localfilename";
730 while (file_exists($full_localfilename)) {
731 $localfilename = GenerateRandomString(32, '', 7);
732 $full_localfilename = "$hashed_attachment_dir/$localfilename";
735 if (!@rename
($HTTP_POST_FILES['attachfile']['tmp_name'], $full_localfilename)) {
736 if (!@copy
($HTTP_POST_FILES['attachfile']['tmp_name'], $full_localfilename)) {
741 $newAttachment['localfilename'] = $localfilename;
742 $newAttachment['remotefilename'] = $HTTP_POST_FILES['attachfile']['name'];
743 $newAttachment['type'] = strtolower($HTTP_POST_FILES['attachfile']['type']);
745 if ($newAttachment['type'] == "") {
746 $newAttachment['type'] = 'application/octet-stream';
749 $attachments[] = $newAttachment;
755 function ClearAttachments()
757 global $username, $attachments, $attachment_dir;
758 $hashed_attachment_dir = getHashedDir($username, $attachment_dir);
760 foreach ($attachments as $info) {
761 $attached_file = "$hashed_attachment_dir/$info[localfilename]";
762 if (file_exists($attached_file)) {
763 unlink($attached_file);
767 $attachments = array();
770 function getReplyCitation($orig_from)
772 global $reply_citation_style, $reply_citation_start, $reply_citation_end;
774 /* First, return an empty string when no citation style selected. */
775 if (($reply_citation_style == '') ||
($reply_citation_style == 'none')) {
779 /* Decode the users name. */
780 $parpos = strpos($orig_from, '(');
781 if ($parpos === false) {
782 $orig_from = trim(substr($orig_from, 0, strpos($orig_from, '<')));
783 $orig_from = str_replace('"', '', $orig_from);
784 $orig_from = str_replace("'", '', $orig_from);
786 $end_parpos = strrpos($orig_from, ')');
787 $end_parpos -= ($end_parpos === false ?
$end_parpos : $parpos +
1);
788 $orig_from = trim(substr($orig_from, $parpos +
1, $end_parpos));
791 /* Make sure our final value isn't an empty string. */
792 if ($orig_from == '') {
796 /* Otherwise, try to select the desired citation style. */
797 switch ($reply_citation_style) {
800 $end = ' ' . _("said") . ':';
803 $start = '<' . _("quote") . ' ' . _("who") . '="';
807 $start = $reply_citation_start;
808 $end = $reply_citation_end;
814 /* Build and return the citation string. */
815 return ($start . $orig_from . $end . "\n");