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=" . urlencode($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&note=$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=" . urlencode( $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".
139 "&startMessage=1");
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); */
161 } elseif (isset($html_addr_search_done)) {
162 if ($compose_new_win == '1') {
163 compose_Header($color, $mailbox);
166 displayPageHeader($color, $mailbox);
169 if (isset($send_to_search) && is_array($send_to_search)) {
170 foreach ($send_to_search as $k => $v) {
171 if (substr($k, 0, 1) == 'T') {
177 elseif (substr($k, 0, 1) == 'C') {
183 elseif (substr($k, 0, 1) == 'B') {
185 $send_to_bcc .= ', ';
192 } elseif (isset($html_addr_search)) {
193 if (isset($HTTP_POST_FILES['attachfile']) &&
194 $HTTP_POST_FILES['attachfile']['tmp_name'] &&
195 $HTTP_POST_FILES['attachfile']['tmp_name'] != 'none') {
196 if (saveAttachedFiles()) {
197 plain_error_message(_("Could not move/copy file. File not attached"), $color);
201 * I am using an include so as to elminiate an extra unnecessary
202 * click. If you can think of a better way, please implement it.
204 include_once('./addrbook_search_html.php');
205 } elseif (isset($attach)) {
206 if (saveAttachedFiles()) {
207 plain_error_message(_("Could not move/copy file. File not attached"), $color);
209 if ($compose_new_win == '1') {
210 compose_Header($color, $mailbox);
213 displayPageHeader($color, $mailbox);
217 elseif (isset($sigappend)) {
218 $idents = getPref($data_dir, $username, 'identities', 0);
220 if ($identity == 'default') {
225 $signature = getSig($data_dir, $username, $no);
227 $body .= "\n\n".($prefix_sig==true?
"-- \n":'').$signature;
228 if ($compose_new_win == '1') {
229 compose_Header($color, $mailbox);
231 displayPageHeader($color, $mailbox);
234 } elseif (isset($do_delete)) {
235 if ($compose_new_win == '1') {
236 compose_Header($color, $mailbox);
239 displayPageHeader($color, $mailbox);
242 $hashed_attachment_dir = getHashedDir($username, $attachment_dir);
243 if (isset($delete) && is_array($delete)) {
244 foreach($delete as $index) {
245 $attached_file = $hashed_attachment_dir . '/'
246 . $attachments[$index]['localfilename'];
247 unlink ($attached_file);
248 unset ($attachments[$index]);
255 * This handles the default case as well as the error case
256 * (they had the same code) --> if (isset($smtpErrors))
258 $imapConnection = sqimap_login($username, $key, $imapServerAddress,
260 if ($compose_new_win == '1') {
261 compose_Header($color, $mailbox);
264 displayPageHeader($color, $mailbox);
271 if (isset($forward_id) && $forward_id && isset($ent_num) && $ent_num) {
275 if (isset($draft_id) && $draft_id && isset($ent_num) && $ent_num) {
281 sqimap_logout($imapConnection);
287 /**************** Only function definitions go below *************/
290 /* This function is used when not sending or adding attachments */
291 function newMail () {
292 global $forward_id, $imapConnection, $msg, $ent_num, $body_ary, $body,
293 $reply_id, $send_to, $send_to_cc, $mailbox, $send_to_bcc, $editor_size,
294 $draft_id, $use_signature;
296 $send_to = decodeHeader($send_to, false);
297 $send_to_cc = decodeHeader($send_to_cc, false);
298 $send_to_bcc = decodeHeader($send_to_bcc, false);
302 } elseif ($reply_id) {
308 $use_signature = FALSE;
312 sqimap_mailbox_select($imapConnection, $mailbox);
313 $message = sqimap_get_message($imapConnection, $id, $mailbox);
314 $orig_header = $message->header
;
316 $message = getEntity($message, $ent_num);
318 if ($message->header
->type0
== 'text' ||
319 $message->header
->type1
== 'message') {
322 mime_fetch_body($imapConnection, $id, $ent_num),
323 $message->header
->encoding
);
326 mime_fetch_body($imapConnection, $id, 1),
327 $message->header
->encoding
);
333 if ($message->header
->type1
== 'html') {
334 $body = strip_tags($body);
338 $body_ary = explode("\n", $body);
339 $i = count($body_ary) - 1;
340 while ($i >= 0 && ereg("^[>\\s]*$", $body_ary[$i])) {
341 unset($body_ary[$i]);
345 for ($i=0; isset($body_ary[$i]); $i++
) {
347 if (ereg('^[ >]+', $body_ary[$i])) {
348 $body_ary[$i] = '>' . $body_ary[$i];
350 $body_ary[$i] = '> ' . $body_ary[$i];
354 sqWordWrap($body_ary[$i], $editor_size - 1);
356 $body .= $body_ary[$i] . "\n";
357 unset($body_ary[$i]);
360 $bodyTop = '-------- ' . _("Original Message") . " --------\n" .
361 _("Subject") . ': ' . $orig_header->subject
. "\n" .
362 _("From") . ': ' . $orig_header->from
. "\n" .
364 getLongDateString( $orig_header->date
). "\n" .
365 _("To") . ': ' . $orig_header->to
[0] . "\n";
366 if (count($orig_header->to
) > 1) {
367 for ($x=1; $x < count($orig_header->to
); $x++
) {
368 $bodyTop .= ' ' . $orig_header->to
[$x] . "\n";
372 $body = $bodyTop . $body;
375 $orig_from = decodeHeader($orig_header->from
, false);
376 $body = getReplyCitation($orig_from) . $body;
383 $send_to = sqimap_find_email($send_to);
386 /* This formats a CC string if they hit "reply all" */
387 if ($send_to_cc != '') {
388 $send_to_cc = ereg_replace('"[^"]*"', '', $send_to_cc);
389 $send_to_cc = str_replace(';', ',', $send_to_cc);
390 $sendcc = explode(',', $send_to_cc);
393 for ($i = 0; $i < count($sendcc); $i++
) {
394 $sendcc[$i] = trim($sendcc[$i]);
395 if ($sendcc[$i] == '') {
399 $sendcc[$i] = sqimap_find_email($sendcc[$i]);
400 $whofrom = sqimap_find_displayable_name($msg['HEADER']['FROM']);
401 $whoreplyto = sqimap_find_email($msg['HEADER']['REPLYTO']);
403 if ((strtolower(trim($sendcc[$i])) != strtolower(trim($whofrom))) &&
404 (strtolower(trim($sendcc[$i])) != strtolower(trim($whoreplyto))) &&
405 (trim($sendcc[$i]) != '')) {
406 $send_to_cc .= trim($sendcc[$i]) . ', ';
409 $send_to_cc = trim($send_to_cc);
410 if (substr($send_to_cc, -1) == ',') {
411 $send_to_cc = substr($send_to_cc, 0, strlen($send_to_cc) - 1);
414 } /* function newMail() */
417 function getAttachments($message) {
418 global $mailbox, $attachments, $attachment_dir, $imapConnection,
419 $ent_num, $forward_id, $draft_id, $username;
421 if (isset($draft_id)) {
428 sqimap_mailbox_select($imapConnection, $mailbox);
429 $message = sqimap_get_message($imapConnection, $id, $mailbox);
432 $hashed_attachment_dir = getHashedDir($username, $attachment_dir);
433 if (count($message->entities
) == 0) {
434 if ($message->header
->entity_id
!= $ent_num) {
435 $filename = decodeHeader($message->header
->filename
);
437 if ($filename == "") {
438 $filename = "untitled-".$message->header
->entity_id
;
441 $localfilename = GenerateRandomString(32, '', 7);
442 $full_localfilename = "$hashed_attachment_dir/$localfilename";
443 while (file_exists($full_localfilename)) {
444 $localfilename = GenerateRandomString(32, '', 7);
445 $full_localfilename = "$hashed_attachment_dir/$localfilename";
448 $newAttachment = array();
449 $newAttachment['localfilename'] = $localfilename;
450 $newAttachment['remotefilename'] = $filename;
451 $newAttachment['type'] = strtolower($message->header
->type0
.
452 '/' . $message->header
->type1
);
454 /* Write Attachment to file */
455 $fp = fopen ("$hashed_attachment_dir/$localfilename", 'w');
456 fputs($fp, decodeBody(mime_fetch_body($imapConnection,
457 $id, $message->header
->entity_id
),
458 $message->header
->encoding
));
461 $attachments[] = $newAttachment;
464 for ($i = 0; $i < count($message->entities
); $i++
) {
465 getAttachments($message->entities
[$i]);
471 function showInputForm () {
472 global $send_to, $send_to_cc, $reply_subj, $forward_subj, $body,
473 $passed_body, $color, $use_signature, $signature, $prefix_sig,
474 $editor_size, $attachments, $subject, $newmail,
475 $use_javascript_addr_book, $send_to_bcc, $reply_id, $mailbox,
476 $from_htmladdr_search, $location_of_buttons, $attachment_dir,
477 $username, $data_dir, $identity, $draft_id, $delete_draft,
478 $mailprio, $default_use_mdn, $mdn_user_support, $compose_new_win,
479 $saved_draft, $mail_sent;
481 $subject = decodeHeader($subject, false);
482 $reply_subj = decodeHeader($reply_subj, false);
483 $forward_subj = decodeHeader($forward_subj, false);
485 if ($use_javascript_addr_book) {
486 echo "\n". '<SCRIPT LANGUAGE=JavaScript><!--' . "\n" .
487 'function open_abook() { ' . "\n" .
488 ' var nwin = window.open("addrbook_popup.php","abookpopup",' .
489 '"width=670,height=300,resizable=yes,scrollbars=yes");' . "\n" .
490 ' if((!nwin.opener) && (document.windows != null))' . "\n" .
491 ' nwin.opener = document.windows;' . "\n" .
493 '// --></SCRIPT>' . "\n\n";
496 echo "\n" . '<FORM name=compose action="compose.php" METHOD=POST ' .
497 'ENCTYPE="multipart/form-data"';
498 do_hook("compose_form");
503 if (isset($draft_id)) {
504 echo '<input type="hidden" name="delete_draft" value="' . $draft_id . "\">\n";
506 if (isset($delete_draft)) {
507 echo '<input type="hidden" name="delete_draft" value="' . $delete_draft. "\">\n";
509 if ($saved_draft == 'yes') {
510 echo '<BR><CENTER><B>'. _("Draft Saved").'</CENTER></B>';
512 if ($mail_sent == 'yes') {
513 echo '<BR><CENTER><B>'. _("Your Message has been sent").'</CENTER></B>';
515 echo '<TABLE WIDTH="100%" ALIGN=center CELLSPACING=0 BORDER=0>' . "\n";
516 if ($compose_new_win == '1') {
517 echo ' <TR><TD></TD><TD ALIGN="RIGHT"><INPUT TYPE="BUTTON" NAME="Close" onClick="return self.close()" VALUE='._("Close").'></TD></TR>'."\n";
519 if ($location_of_buttons == 'top') {
520 showComposeButtonRow();
523 $idents = getPref($data_dir, $username, 'identities', 0);
525 echo ' <TR>' . "\n" .
526 ' <TD BGCOLOR="' . $color[4] . '" WIDTH="10%" ALIGN=RIGHT>' .
529 ' </TD><TD BGCOLOR="' . $color[4] . '" WIDTH="90%">' . "\n" .
530 '<select name=identity>' . "\n" .
531 '<option value=default>' .
532 htmlspecialchars(getPref($data_dir, $username, 'full_name'));
533 $em = getPref($data_dir, $username, 'email_address');
535 echo htmlspecialchars(' <' . $em . '>') . "\n";
537 for ($i = 1; $i < $idents; $i ++
) {
538 echo '<option value="' . $i . '"';
539 if (isset($identity) && $identity == $i) {
542 echo '>' . htmlspecialchars(getPref($data_dir, $username,
544 $em = getPref($data_dir, $username, 'email_address' . $i);
546 echo htmlspecialchars(' <' . $em . '>') . "\n";
550 echo '</select>' . "\n" .
554 echo ' <TR>' . "\n" .
555 ' <TD BGCOLOR="' . $color[4] . '" WIDTH="10%" ALIGN=RIGHT>' . "\n" .
557 ' </TD><TD BGCOLOR="' . $color[4] . '" WIDTH="90%">' . "\n" .
558 ' <INPUT TYPE=text NAME="send_to" VALUE="' .
559 htmlspecialchars($send_to) . '" SIZE=60><BR>' . "\n" .
563 ' <TD BGCOLOR="' . $color[4] . '" ALIGN=RIGHT>' . "\n" .
565 ' </TD><TD BGCOLOR="' . $color[4] . '" ALIGN=LEFT>' . "\n" .
566 ' <INPUT TYPE=text NAME="send_to_cc" SIZE=60 VALUE="' .
567 htmlspecialchars($send_to_cc) . '"><BR>' . "\n" .
571 ' <TD BGCOLOR="' . $color[4] . '" ALIGN=RIGHT>' . "\n" .
573 ' </TD><TD BGCOLOR="' . $color[4] . '" ALIGN=LEFT>' . "\n" .
574 ' <INPUT TYPE=text NAME="send_to_bcc" VALUE="' .
575 htmlspecialchars($send_to_bcc) . '" SIZE=60><BR>' . "\n" .
576 '</TD></TR>' . "\n" .
578 ' <TD BGCOLOR="' . $color[4] . '" ALIGN=RIGHT>' . "\n" .
580 ' </TD><TD BGCOLOR="' . $color[4] . '" ALIGN=LEFT>' . "\n";
582 $reply_subj = str_replace('"', "'", $reply_subj);
583 $reply_subj = trim($reply_subj);
584 if (substr(strtolower($reply_subj), 0, 3) != 're:') {
585 $reply_subj = 'Re: ' . $reply_subj;
587 echo ' <INPUT TYPE=text NAME=subject SIZE=60 VALUE="' .
588 htmlspecialchars($reply_subj) . '">';
590 elseif ($forward_subj) {
591 $forward_subj = trim($forward_subj);
592 if ((substr(strtolower($forward_subj), 0, 4) != 'fwd:') &&
593 (substr(strtolower($forward_subj), 0, 5) != '[fwd:') &&
594 (substr(strtolower($forward_subj), 0, 6) != '[ fwd:')) {
595 $forward_subj = '[Fwd: ' . $forward_subj . ']';
597 echo ' <INPUT TYPE=text NAME=subject SIZE=60 VALUE="' .
598 htmlspecialchars($forward_subj) . '">';
600 echo ' <INPUT TYPE=text NAME=subject SIZE=60 VALUE="' .
601 htmlspecialchars($subject) . '">';
603 echo '</td></tr>' . "\n\n";
605 if ($location_of_buttons == 'between') {
606 showComposeButtonRow();
609 echo ' <TR>' . "\n" .
610 ' <TD BGCOLOR="' . $color[4] . '" COLSPAN=2>' . "\n" .
611 ' <TEXTAREA NAME=body ROWS=20 COLS="' .
612 $editor_size . '" WRAP=HARD>' . htmlspecialchars($body);
613 if ($use_signature == true && $newmail == true && !isset($from_htmladdr_search)) {
614 echo "\n\n".($prefix_sig==true?
"-- \n":'').htmlspecialchars($signature);
616 echo '</TEXTAREA><BR>' . "\n" .
620 if ($location_of_buttons == 'bottom') {
621 showComposeButtonRow();
623 echo ' <TR><TD COLSPAN=2 ALIGN=LEFT>';
624 echo ' <INPUT TYPE=SUBMIT NAME=send VALUE="' . _("Send") . '"></TD></TR>' . "\n";
627 /* This code is for attachments */
628 echo ' <TR>' . "\n" .
629 ' <TD VALIGN=MIDDLE ALIGN=RIGHT>' . "\n" .
632 ' <TD VALIGN=MIDDLE ALIGN=LEFT>' . "\n" .
633 ' <INPUT NAME="attachfile" SIZE=48 TYPE="file">' . "\n" .
634 ' <input type="submit" name="attach"' .
635 ' value="' . _("Add") .'">' . "\n" .
639 if (count($attachments)) {
640 $hashed_attachment_dir = getHashedDir($username, $attachment_dir);
641 echo '<tr><td bgcolor="' . $color[0] . '" align=right>' . "\n" .
643 '</td><td align=left bgcolor="' . $color[0] . '">';
644 foreach ($attachments as $key => $info) {
645 $attached_file = "$hashed_attachment_dir/$info[localfilename]";
646 echo '<input type="checkbox" name="delete[]" value="' . $key . "\">\n" .
647 $info['remotefilename'] . ' - ' . $info['type'] . ' (' .
648 show_readable_size(filesize($attached_file)) . ")<br>\n";
651 echo '<input type="submit" name="do_delete" value="' .
652 _("Delete selected attachments") . "\">\n" .
655 /* End of attachment code */
657 echo '</TABLE>' . "\n";
659 echo '<input type=hidden name=reply_id value=' . $reply_id . ">\n";
661 echo '<INPUT TYPE=hidden NAME=mailbox VALUE="' . htmlspecialchars($mailbox) .
664 do_hook('compose_bottom');
665 echo '</BODY></HTML>' . "\n";
669 function showComposeButtonRow() {
670 global $use_javascript_addr_book, $save_as_draft,
671 $default_use_priority, $mailprio, $default_use_mdn,
672 $data_dir, $username;
674 echo " <TR><TD>\n</TD><TD>\n";
675 if ($default_use_priority) {
676 if(!isset($mailprio)) {
679 echo _("Priority") .': <select name="mailprio">'.
680 '<option value="1"'.($mailprio=='1'?
' selected':'').'>'. _("High") .'</option>'.
681 '<option value="3"'.($mailprio=='3'?
' selected':'').'>'. _("Normal") .'</option>'.
682 '<option value="5"'.($mailprio=='5'?
' selected':'').'>'. _("Low").'</option>'.
685 $mdn_user_support=getPref($data_dir, $username, 'mdn_user_support',$default_use_mdn);
686 if ($default_use_mdn) {
687 if ($mdn_user_support) {
688 echo "\n\t". _("Receipt") .': '.
689 '<input type="checkbox" name="request_mdn" value=1>'. _("On read").
690 ' <input type="checkbox" name="request_dr" value=1>'. _("On Delivery");
694 echo " <TR><td>\n </td><td>\n";
695 echo "\n <INPUT TYPE=SUBMIT NAME=\"sigappend\" VALUE=\"". _("Signature") . "\">\n";
696 if ($use_javascript_addr_book) {
697 echo " <SCRIPT LANGUAGE=JavaScript><!--\n document.write(\"".
698 " <input type=button value=\\\""._("Addresses").
699 "\\\" onclick='javascript:open_abook();'>\");".
700 " // --></SCRIPT><NOSCRIPT>\n".
701 " <input type=submit name=\"html_addr_search\" value=\"".
702 _("Addresses")."\">".
705 echo " <input type=submit name=\"html_addr_search\" value=\"".
706 _("Addresses")."\">";
708 echo "\n <INPUT TYPE=SUBMIT NAME=send VALUE=\"". _("Send") . "\">\n";
710 if ($save_as_draft) {
711 echo '<input type="submit" name ="draft" value="' . _("Save Draft") . "\">\n";
714 do_hook('compose_button_row');
716 echo " </TD></TR>\n\n";
719 function checkInput ($show) {
721 * I implemented the $show variable because the error messages
722 * were getting sent before the page header. So, I check once
723 * using $show=false, and then when i'm ready to display the error
726 global $body, $send_to, $subject, $color;
728 if ($send_to == "") {
730 plain_error_message(_("You have not filled in the \"To:\" field."), $color);
735 } /* function checkInput() */
738 /* True if FAILURE */
739 function saveAttachedFiles() {
740 global $HTTP_POST_FILES, $attachment_dir, $attachments, $username;
742 $hashed_attachment_dir = getHashedDir($username, $attachment_dir);
743 $localfilename = GenerateRandomString(32, '', 7);
744 $full_localfilename = "$hashed_attachment_dir/$localfilename";
745 while (file_exists($full_localfilename)) {
746 $localfilename = GenerateRandomString(32, '', 7);
747 $full_localfilename = "$hashed_attachment_dir/$localfilename";
750 if (!@rename
($HTTP_POST_FILES['attachfile']['tmp_name'], $full_localfilename)) {
751 if (!@copy
($HTTP_POST_FILES['attachfile']['tmp_name'], $full_localfilename)) {
756 $newAttachment['localfilename'] = $localfilename;
757 $newAttachment['remotefilename'] = $HTTP_POST_FILES['attachfile']['name'];
758 $newAttachment['type'] = strtolower($HTTP_POST_FILES['attachfile']['type']);
760 if ($newAttachment['type'] == "") {
761 $newAttachment['type'] = 'application/octet-stream';
764 $attachments[] = $newAttachment;
770 function ClearAttachments()
772 global $username, $attachments, $attachment_dir;
773 $hashed_attachment_dir = getHashedDir($username, $attachment_dir);
775 foreach ($attachments as $info) {
776 $attached_file = "$hashed_attachment_dir/$info[localfilename]";
777 if (file_exists($attached_file)) {
778 unlink($attached_file);
782 $attachments = array();
785 function getReplyCitation($orig_from)
787 global $reply_citation_style, $reply_citation_start, $reply_citation_end;
789 /* First, return an empty string when no citation style selected. */
790 if (($reply_citation_style == '') ||
($reply_citation_style == 'none')) {
794 /* Decode the users name. */
795 $parpos = strpos($orig_from, '(');
796 if ($parpos === false) {
797 $orig_from = trim(substr($orig_from, 0, strpos($orig_from, '<')));
798 $orig_from = str_replace('"', '', $orig_from);
799 $orig_from = str_replace("'", '', $orig_from);
801 $end_parpos = strrpos($orig_from, ')');
802 $end_parpos -= ($end_parpos === false ?
$end_parpos : $parpos +
1);
803 $orig_from = trim(substr($orig_from, $parpos +
1, $end_parpos));
806 /* Make sure our final value isn't an empty string. */
807 if ($orig_from == '') {
811 /* Otherwise, try to select the desired citation style. */
812 switch ($reply_citation_style) {
815 $end = ' ' . _("said") . ':';
818 $start = '<' . _("quote") . ' ' . _("who") . '="';
822 $start = $reply_citation_start;
823 $end = $reply_citation_end;
829 /* Build and return the citation string. */
830 return ($start . $orig_from . $end . "\n");