94
95
/* Location (For HTTP 1.1 Header("Location: ...") redirects) */
95
96
$location = get_location();
96
/* Identities (fetch only once) */
97
$idents = get_identities();
99
98
/* --------------------- Specific Functions ------------------------------ */
101
100
function replyAllString($header) {
102
global $include_self_reply_all, $idents;
105
* 1) Remove the addresses we'll be sending the message 'to'
107
$url_replytoall_avoid_addrs = '';
108
if (isset($header->replyto)) {
109
$excl_ar = $header->getAddr_a('replyto');
112
* 2) Remove our identities from the CC list (they still can be in the
113
* TO list) only if $include_self_reply_all is turned off
115
if (!$include_self_reply_all) {
116
foreach($idents as $id) {
117
$excl_ar[strtolower(trim($id['email_address']))] = '';
122
* 3) get the addresses.
124
$url_replytoall_ar = $header->getAddr_a(array('to','cc'), $excl_ar);
127
* 4) generate the string.
129
$url_replytoallcc = '';
130
foreach( $url_replytoall_ar as $email => $personal) {
132
// if personal name contains address separator then surround
133
// the personal name with double quotes.
134
if (strpos($personal,',') !== false) {
135
$personal = '"'.$personal.'"';
137
$url_replytoallcc .= ", $personal <$email>";
139
$url_replytoallcc .= ', '. $email;
142
$url_replytoallcc = substr($url_replytoallcc,2);
144
return $url_replytoallcc;
101
global $include_self_reply_all, $username, $data_dir;
104
* 1) Remove the addresses we'll be sending the message 'to'
106
$url_replytoall_avoid_addrs = '';
107
if (isset($header->replyto)) {
108
$excl_ar = $header->getAddr_a('replyto');
111
* 2) Remove our identities from the CC list (they still can be in the
112
* TO list) only if $include_self_reply_all is turned off
114
if (!$include_self_reply_all) {
115
$email_address = strtolower(trim(getPref($data_dir, $username, 'email_address')));
116
$excl_ar[$email_address] = '';
117
$idents = getPref($data_dir, $username, 'identities');
118
if ($idents != '' && $idents > 1) {
120
for ($i = 1; $i < $idents; $i ++) {
121
$cur_email_address = getPref($data_dir, $username,
122
'email_address' . $i);
123
$cur_email_address = strtolower(trim($cur_email_address));
124
$excl_ar[$cur_email_address] = '';
130
* 3) get the addresses.
132
$url_replytoall_ar = $header->getAddr_a(array('to','cc'), $excl_ar);
135
* 4) generate the string.
137
$url_replytoallcc = '';
138
foreach( $url_replytoall_ar as $email => $personal) {
140
// if personal name contains address separator then surround
141
// the personal name with double quotes.
142
if (strpos($personal,',') !== false) {
143
$personal = '"'.$personal.'"';
145
$url_replytoallcc .= ", $personal <$email>";
147
$url_replytoallcc .= ', '. $email;
150
$url_replytoallcc = substr($url_replytoallcc,2);
152
return $url_replytoallcc;
147
function getReplyCitation($orig_from) {
155
function getReplyCitation($orig_from, $orig_date) {
148
156
global $reply_citation_style, $reply_citation_start, $reply_citation_end;
149
157
$orig_from = decodeHeader($orig_from->getAddress(false),false,false,true);
150
// $from = decodeHeader($orig_header->getAddr_s('from',"\n$indent"),false,false);
151
159
/* First, return an empty string when no citation style selected. */
152
160
if (($reply_citation_style == '') || ($reply_citation_style == 'none')) {
184
196
function getforwardHeader($orig_header) {
185
197
global $editor_size;
187
$display = array( _("Subject") => strlen(_("Subject")),
188
_("From") => strlen(_("From")),
189
_("Date") => strlen(_("Date")),
190
_("To") => strlen(_("To")),
191
_("Cc") => strlen(_("Cc")) );
192
$maxsize = max($display);
193
$indent = str_pad('',$maxsize+2);
194
foreach($display as $key => $val) {
195
$display[$key] = $key .': '. str_pad('', $maxsize - $val);
197
$from = decodeHeader($orig_header->getAddr_s('from',"\n$indent"),false,false,true);
198
$from = str_replace(' ',' ',$from);
199
$to = decodeHeader($orig_header->getAddr_s('to',"\n$indent"),false,false,true);
200
$to = str_replace(' ',' ',$to);
201
$subject = decodeHeader($orig_header->subject,false,false,true);
202
$subject = str_replace(' ',' ',$subject);
203
$bodyTop = str_pad(' '._("Original Message").' ',$editor_size -2,'-',STR_PAD_BOTH) .
204
"\n". $display[_("Subject")] . $subject . "\n" .
205
$display[_("From")] . $from . "\n" .
206
$display[_("Date")] . getLongDateString( $orig_header->date ). "\n" .
207
$display[_("To")] . $to . "\n";
208
if ($orig_header->cc != array() && $orig_header->cc !='') {
209
$cc = decodeHeader($orig_header->getAddr_s('cc',"\n$indent"),false,false,true);
210
$cc = str_replace(' ',' ',$cc);
211
$bodyTop .= $display[_("Cc")] .$cc . "\n";
213
$bodyTop .= str_pad('', $editor_size -2 , '-') .
199
$display = array( _("Subject") => strlen(_("Subject")),
200
_("From") => strlen(_("From")),
201
_("Date") => strlen(_("Date")),
202
_("To") => strlen(_("To")),
203
_("Cc") => strlen(_("Cc")) );
204
$maxsize = max($display);
205
$indent = str_pad('',$maxsize+2);
206
foreach($display as $key => $val) {
207
$display[$key] = $key .': '. str_pad('', $maxsize - $val);
209
$from = decodeHeader($orig_header->getAddr_s('from',"\n$indent"),false,false,true);
210
$from = str_replace(' ',' ',$from);
211
$to = decodeHeader($orig_header->getAddr_s('to',"\n$indent"),false,false,true);
212
$to = str_replace(' ',' ',$to);
213
$subject = decodeHeader($orig_header->subject,false,false,true);
214
$subject = str_replace(' ',' ',$subject);
215
$bodyTop = str_pad(' '._("Original Message").' ',$editor_size -2,'-',STR_PAD_BOTH) .
216
"\n". $display[_("Subject")] . $subject . "\n" .
217
$display[_("From")] . $from . "\n" .
218
$display[_("Date")] . getLongDateString( $orig_header->date ). "\n" .
219
$display[_("To")] . $to . "\n";
220
if ($orig_header->cc != array() && $orig_header->cc !='') {
221
$cc = decodeHeader($orig_header->getAddr_s('cc',"\n$indent"),false,false,true);
222
$cc = str_replace(' ',' ',$cc);
223
$bodyTop .= $display[_("Cc")] .$cc . "\n";
225
$bodyTop .= str_pad('', $editor_size -2 , '-') .
217
229
/* ----------------------------------------------------------------------- */
669
695
if ($identity_match) {
670
696
$identity = $identity_match;
672
// we need identiy here fore draft case #845290
673
// echo $identity."leer";
676
700
switch ($action) {
678
$use_signature = FALSE;
679
$composeMessage->rfc822_header = $orig_header;
680
$send_to = decodeHeader($orig_header->getAddr_s('to'),false,true,true);
681
$send_to_cc = decodeHeader($orig_header->getAddr_s('cc'),false,true,true);
682
$send_to_bcc = decodeHeader($orig_header->getAddr_s('bcc'),false,true,true);
683
$send_from = $orig_header->getAddr_s('from');
684
$send_from_parts = new AddressStructure();
685
$send_from_parts = $orig_header->parseAddress($send_from);
686
$send_from_add = $send_from_parts->mailbox . '@' . $send_from_parts->host;
687
$identities = get_identities();
688
if (count($identities) > 0) {
689
foreach($identities as $iddata) {
690
if ($send_from_add == $iddata['email_address']) {
691
$identity = $iddata['index'];
702
$use_signature = FALSE;
703
$composeMessage->rfc822_header = $orig_header;
704
$send_to = decodeHeader($orig_header->getAddr_s('to'),false,false,true);
705
$send_to_cc = decodeHeader($orig_header->getAddr_s('cc'),false,false,true);
706
$send_to_bcc = decodeHeader($orig_header->getAddr_s('bcc'),false,false,true);
707
$subject = decodeHeader($orig_header->subject,false,false,true);
708
/* remember the references and in-reply-to headers in case of an reply */
709
$composeMessage->rfc822_header->more_headers['References'] = $orig_header->references;
710
$composeMessage->rfc822_header->more_headers['In-Reply-To'] = $orig_header->in_reply_to;
711
$body_ary = explode("\n", $body);
712
$cnt = count($body_ary) ;
714
for ($i=0; $i < $cnt; $i++) {
715
if (!ereg("^[>\\s]*$", $body_ary[$i]) || !$body_ary[$i]) {
716
sqWordWrap($body_ary[$i], $editor_size );
717
$body .= $body_ary[$i] . "\n";
696
$subject = decodeHeader($orig_header->subject,false,true,true);
697
// /* remember the references and in-reply-to headers in case of an reply */
698
$composeMessage->rfc822_header->more_headers['References'] = $orig_header->references;
699
$composeMessage->rfc822_header->more_headers['In-Reply-To'] = $orig_header->in_reply_to;
700
$body_ary = explode("\n", $body);
701
$cnt = count($body_ary) ;
703
for ($i=0; $i < $cnt; $i++) {
704
if (!ereg("^[>\\s]*$", $body_ary[$i]) || !$body_ary[$i]) {
705
sqWordWrap($body_ary[$i], $editor_size );
706
$body .= $body_ary[$i] . "\n";
708
unset($body_ary[$i]);
711
$composeMessage = getAttachments($message, $composeMessage, $passed_id, $entities, $imapConnection);
713
case ('edit_as_new'):
714
$send_to = decodeHeader($orig_header->getAddr_s('to'),false,true,true);
715
$send_to_cc = decodeHeader($orig_header->getAddr_s('cc'),false,true,true);
716
$send_to_bcc = decodeHeader($orig_header->getAddr_s('bcc'),false,true,true);
717
$subject = decodeHeader($orig_header->subject,false,true,true);
718
$mailprio = $orig_header->priority;
720
$composeMessage = getAttachments($message, $composeMessage, $passed_id, $entities, $imapConnection);
725
$subject = getforwardSubject(decodeHeader($orig_header->subject,false,true,true));
726
$body = getforwardHeader($orig_header) . $body;
728
$composeMessage = getAttachments($message, $composeMessage, $passed_id, $entities, $imapConnection);
729
$body = "\n" . $body;
731
case ('forward_as_attachment'):
732
$subject = getforwardSubject(decodeHeader($orig_header->subject,false,true,true));
733
$composeMessage = getMessage_RFC822_Attachment($message, $composeMessage, $passed_id, $passed_ent_id, $imapConnection);
737
if(isset($orig_header->mail_followup_to) && $orig_header->mail_followup_to) {
738
$send_to = $orig_header->getAddr_s('mail_followup_to');
719
unset($body_ary[$i]);
722
$composeMessage = getAttachments($message, $composeMessage, $passed_id, $entities, $imapConnection);
724
case ('edit_as_new'):
725
$send_to = decodeHeader($orig_header->getAddr_s('to'),false,false,true);
726
$send_to_cc = decodeHeader($orig_header->getAddr_s('cc'),false,false,true);
727
$send_to_bcc = decodeHeader($orig_header->getAddr_s('bcc'),false,false,true);
728
$subject = decodeHeader($orig_header->subject,false,false,true);
729
$mailprio = $orig_header->priority;
731
$composeMessage = getAttachments($message, $composeMessage, $passed_id, $entities, $imapConnection);
736
$subject = decodeHeader($orig_header->subject,false,false,true);
737
if ((substr(strtolower($subject), 0, 4) != 'fwd:') &&
738
(substr(strtolower($subject), 0, 5) != '[fwd:') &&
739
(substr(strtolower($subject), 0, 6) != '[ fwd:')) {
740
$subject = '[Fwd: ' . $subject . ']';
742
$body = getforwardHeader($orig_header) . $body;
744
$composeMessage = getAttachments($message, $composeMessage, $passed_id, $entities, $imapConnection);
745
$body = "\n" . $body;
747
case ('forward_as_attachment'):
748
$composeMessage = getMessage_RFC822_Attachment($message, $composeMessage, $passed_id, $passed_ent_id, $imapConnection);
740
752
$send_to_cc = replyAllString($orig_header);
741
$send_to_cc = decodeHeader($send_to_cc,false,true,true);
744
// skip this if send_to was already set right above here
753
$send_to_cc = decodeHeader($send_to_cc,false,false,true);
746
755
$send_to = $orig_header->reply_to;
747
756
if (is_array($send_to) && count($send_to)) {
748
757
$send_to = $orig_header->getAddr_s('reply_to');
749
} else if (is_object($send_to)) { /* unneccesarry, just for failsafe purpose */
758
} else if (is_object($send_to)) { /* unnessecarry, just for falesafe purpose */
750
759
$send_to = $orig_header->getAddr_s('reply_to');
752
761
$send_to = $orig_header->getAddr_s('from');
755
$send_to = decodeHeader($send_to,false,true,true);
756
$subject = decodeHeader($orig_header->subject,false,true,true);
757
$subject = str_replace('"', "'", $subject);
758
$subject = trim($subject);
759
if (substr(strtolower($subject), 0, 3) != 're:') {
760
$subject = 'Re: ' . $subject;
762
/* this corrects some wrapping/quoting problems on replies */
763
$rewrap_body = explode("\n", $body);
764
$from = (is_array($orig_header->from)) ? $orig_header->from[0] : $orig_header->from;
765
sqUnWordWrap($body); // unwrap and then reset it?!
767
$strip_sigs = getPref($data_dir, $username, 'strip_sigs');
768
foreach ($rewrap_body as $line) {
769
if ($strip_sigs && substr($line,0,3) == '-- ') {
772
sqWordWrap($line, ($editor_size));
773
if (preg_match("/^(>+)/", $line, $matches)) {
775
$body .= '>' . str_replace("\n", "\n>$gt ", rtrim($line)) ."\n";
777
$body .= '> ' . str_replace("\n", "\n> ", rtrim($line)) . "\n";
780
$body = getReplyCitation($from) . $body;
781
$composeMessage->reply_rfc822_header = $orig_header;
763
$send_to = decodeHeader($send_to,false,false,true);
764
$subject = decodeHeader($orig_header->subject,false,false,true);
765
// $subject = str_replace('"', '"', $subject);
766
$subject = trim($subject);
767
if (substr(strtolower($subject), 0, 3) != 're:') {
768
$subject = 'Re: ' . $subject;
770
/* this corrects some wrapping/quoting problems on replies */
771
$rewrap_body = explode("\n", $body);
772
$from = (is_array($orig_header->from)) ? $orig_header->from[0] : $orig_header->from;
775
$cnt = count($rewrap_body);
776
for ($i=0;$i<$cnt;$i++) {
777
sqWordWrap($rewrap_body[$i], ($editor_size));
778
if (preg_match("/^(>+)/", $rewrap_body[$i], $matches)) {
780
$body .= '>' . str_replace("\n", "\n>$gt ", rtrim($rewrap_body[$i])) ."\n";
782
$body .= '> ' . str_replace("\n", "\n> ", rtrim($rewrap_body[$i])) . "\n";
784
unset($rewrap_body[$i]);
786
$body = getReplyCitation($from , $orig_header->date) . $body;
787
$composeMessage->reply_rfc822_header = $orig_header;
787
793
$compose_messages[$session] = $composeMessage;
788
794
sqsession_register($compose_messages, 'compose_messages');
790
796
sqimap_logout($imapConnection);
792
798
$ret = array( 'send_to' => $send_to,
793
'send_to_cc' => $send_to_cc,
794
'send_to_bcc' => $send_to_bcc,
795
'subject' => $subject,
796
'mailprio' => $mailprio,
798
'identity' => $identity );
799
'send_to_cc' => $send_to_cc,
800
'send_to_bcc' => $send_to_bcc,
801
'subject' => $subject,
802
'mailprio' => $mailprio,
804
'identity' => $identity );
801
807
} /* function newMail() */
803
809
function getAttachments($message, &$composeMessage, $passed_id, $entities, $imapConnection) {
804
global $attachment_dir, $username, $data_dir, $squirrelmail_language;
810
global $attachment_dir, $username, $data_dir, $squirrelmail_language, $languages;
805
811
$hashed_attachment_dir = getHashedDir($username, $attachment_dir);
806
812
if (!count($message->entities) ||
807
($message->type0 == 'message' && $message->type1 == 'rfc822')) {
813
($message->type0 == 'message' && $message->type1 == 'rfc822')) {
808
814
if ( !in_array($message->entity_id, $entities) && $message->entity_id) {
809
switch ($message->type0) {
811
if ($message->type1 == 'rfc822') {
812
$filename = $message->rfc822_header->subject;
813
if ($filename == "") {
814
$filename = "untitled-".$message->entity_id;
818
$filename = $message->getFilename();
822
if (!$message->mime_header) { /* temporary hack */
823
$message->mime_header = $message->header;
825
$filename = $message->getFilename();
828
$filename = str_replace(' ', ' ', decodeHeader($filename));
829
if (isset($languages[$squirrelmail_language]['XTRA_CODE']) &&
830
function_exists($languages[$squirrelmail_language]['XTRA_CODE'])) {
815
switch ($message->type0) {
817
if ($message->type1 == 'rfc822') {
818
$filename = $message->rfc822_header->subject;
819
if ($filename == "") {
820
$filename = "untitled-".$message->entity_id;
824
$filename = $message->getFilename();
828
if (!$message->mime_header) { /* temporary hack */
829
$message->mime_header = $message->header;
831
$filename = $message->getFilename();
834
$filename = decodeHeader($filename, false, false);
835
if (isset($languages[$squirrelmail_language]['XTRA_CODE']) &&
836
function_exists($languages[$squirrelmail_language]['XTRA_CODE'])) {
831
837
$filename = $languages[$squirrelmail_language]['XTRA_CODE']('encode', $filename);
833
$localfilename = GenerateRandomString(32, '', 7);
834
$full_localfilename = "$hashed_attachment_dir/$localfilename";
835
while (file_exists($full_localfilename)) {
836
$localfilename = GenerateRandomString(32, '', 7);
837
$full_localfilename = "$hashed_attachment_dir/$localfilename";
839
$message->att_local_name = $full_localfilename;
841
$composeMessage->initAttachment($message->type0.'/'.$message->type1,$filename,
842
$full_localfilename);
844
/* Write Attachment to file */
845
$fp = fopen ("$hashed_attachment_dir/$localfilename", 'wb');
846
fputs($fp, decodeBody(mime_fetch_body($imapConnection,
847
$passed_id, $message->entity_id),
848
$message->header->encoding));
839
$localfilename = GenerateRandomString(32, '', 7);
840
$full_localfilename = "$hashed_attachment_dir/$localfilename";
841
while (file_exists($full_localfilename)) {
842
$localfilename = GenerateRandomString(32, '', 7);
843
$full_localfilename = "$hashed_attachment_dir/$localfilename";
845
$message->att_local_name = $full_localfilename;
847
$composeMessage->initAttachment($message->type0.'/'.$message->type1,$filename,
848
$full_localfilename);
850
/* Write Attachment to file */
851
$fp = fopen ("$hashed_attachment_dir/$localfilename", 'wb');
852
fputs($fp, decodeBody(mime_fetch_body($imapConnection,
853
$passed_id, $message->entity_id),
854
$message->header->encoding));
852
858
for ($i=0, $entCount=count($message->entities); $i<$entCount;$i++) {
884
890
fwrite ($fp, $body);
886
892
$composeMessage->initAttachment('message/rfc822',$subject.'.msg',
887
$full_localfilename);
893
$full_localfilename);
889
895
return $composeMessage;
892
898
function showInputForm ($session, $values=false) {
893
899
global $send_to, $send_to_cc, $body, $startMessage,
894
$passed_body, $color, $use_signature, $signature, $prefix_sig,
895
$editor_size, $attachments, $subject, $newmail,
896
$use_javascript_addr_book, $send_to_bcc, $passed_id, $mailbox,
897
$from_htmladdr_search, $location_of_buttons, $attachment_dir,
898
$username, $data_dir, $identity, $idents, $draft_id, $delete_draft,
899
$mailprio, $default_use_mdn, $mdn_user_support, $compose_new_win,
900
$saved_draft, $mail_sent, $sig_first, $edit_as_new, $action,
901
$username, $compose_messages, $composesession, $default_charset;
900
$passed_body, $color, $use_signature, $signature, $prefix_sig,
901
$editor_size, $editor_height, $attachments, $subject, $newmail,
902
$use_javascript_addr_book, $send_to_bcc, $passed_id, $mailbox,
903
$from_htmladdr_search, $location_of_buttons, $attachment_dir,
904
$username, $data_dir, $identity, $draft_id, $delete_draft,
905
$mailprio, $default_use_mdn, $mdn_user_support, $compose_new_win,
906
$saved_draft, $mail_sent, $sig_first, $edit_as_new, $action,
907
$username, $compose_messages, $composesession, $default_charset;
903
909
$composeMessage = $compose_messages[$session];
906
$send_to = $values['send_to'];
907
$send_to_cc = $values['send_to_cc'];
908
$send_to_bcc = $values['send_to_bcc'];
909
$subject = $values['subject'];
910
$mailprio = $values['mailprio'];
911
$body = $values['body'];
912
$identity = (int) $values['identity'];
911
$send_to = $values['send_to'];
912
$send_to_cc = $values['send_to_cc'];
913
$send_to_bcc = $values['send_to_bcc'];
914
$subject = $values['subject'];
915
$mailprio = $values['mailprio'];
916
$body = $values['body'];
917
$identity = (int) $values['identity'];
914
$send_to = decodeHeader($send_to);
915
$send_to_cc = decodeHeader($send_to_cc);
916
$send_to_bcc = decodeHeader($send_to_bcc);
919
$send_to = decodeHeader($send_to, true, false);
920
$send_to_cc = decodeHeader($send_to_cc, true, false);
921
$send_to_bcc = decodeHeader($send_to_bcc, true, false);
919
924
if ($use_javascript_addr_book) {
920
echo "\n". '<SCRIPT LANGUAGE=JavaScript>'."\n<!--\n" .
921
'function open_abook() { ' . "\n" .
922
' var nwin = window.open("addrbook_popup.php","abookpopup",' .
923
'"width=670,height=300,resizable=yes,scrollbars=yes");' . "\n" .
924
' if((!nwin.opener) && (document.windows != null))' . "\n" .
925
' nwin.opener = document.windows;' . "\n" .
927
"// -->\n</SCRIPT>\n\n";
925
echo "\n". '<script language="JavaScript">'."\n<!--\n" .
926
'function open_abook() { ' . "\n" .
927
' var nwin = window.open("addrbook_popup.php","abookpopup",' .
928
'"width=670,height=300,resizable=yes,scrollbars=yes");' . "\n" .
929
' if((!nwin.opener) && (document.windows != null))' . "\n" .
930
' nwin.opener = document.windows;' . "\n" .
932
"// -->\n</script>\n\n";
930
935
echo "\n" . '<form name="compose" action="compose.php" method="post" ' .
931
'enctype="multipart/form-data"';
936
'enctype="multipart/form-data"';
932
937
do_hook('compose_form');
936
echo '<input type="hidden" name="startMessage" value="' . $startMessage . "\">\n";
941
echo addHidden('startMessage', $startMessage);
938
943
if ($action == 'draft') {
939
echo '<input type="hidden" name="delete_draft" value="' . $passed_id . "\">\n";
944
echo addHidden('delete_draft', $passed_id);
941
946
if (isset($delete_draft)) {
942
echo '<input type="hidden" name="delete_draft" value="' . $delete_draft. "\">\n";
947
echo addHidden('delete_draft', $delete_draft);
944
949
if (isset($session)) {
945
echo '<input type="hidden" name="session" value="' . $session . "\">\n";
950
echo addHidden('session', $session);
948
953
if (isset($passed_id)) {
949
echo '<input type="hidden" name="passed_id" value="' . $passed_id . "\">\n";
954
echo addHidden('passed_id', $passed_id);
952
957
if ($saved_draft == 'yes') {
953
echo '<BR><CENTER><B>'. _("Draft Saved").'</CENTER></B>';
958
echo '<br /><center><b>'. _("Draft Saved").'</center></b>';
955
960
if ($mail_sent == 'yes') {
956
echo '<BR><CENTER><B>'. _("Your Message has been sent.").'</CENTER></B>';
961
echo '<br /><center><b>'. _("Your Message has been sent.").'</center></b>';
958
963
echo '<table align="center" cellspacing="0" border="0">' . "\n";
959
964
if ($compose_new_win == '1') {
960
echo '<TABLE ALIGN=CENTER BGCOLOR="'.$color[0].'" WIDTH="100%" BORDER=0>'."\n" .
961
' <TR><TD></TD>'. html_tag( 'td', '', 'right' ) . '<INPUT TYPE="BUTTON" NAME="Close" onClick="return self.close()" VALUE='._("Close").'></TD></TR>'."\n";
965
echo '<table align="center" bgcolor="'.$color[0].'" width="100%" border="0">'."\n" .
966
' <tr><td></td>'. html_tag( 'td', '', 'right' ) . '<input type="button" name="Close" onClick="return self.close()" value="'._("Close").'" /></td></tr>'."\n";
963
968
if ($location_of_buttons == 'top') {
964
969
showComposeButtonRow();
967
972
/* display select list for identities */
968
if (count($idents) > 1) {
973
$idents = getPref($data_dir, $username, 'identities', 0);
975
$fn = getPref($data_dir, $username, 'full_name');
976
$em = getPref($data_dir, $username, 'email_address');
969
977
echo ' <tr>' . "\n" .
970
html_tag( 'td', '', 'right', $color[4], 'width="10%"' ) .
971
_("From:") . '</td>' . "\n" .
972
html_tag( 'td', '', 'left', $color[4], 'width="90%"' ) .
973
' <select name="identity">' . "\n" ;
974
foreach($idents as $id=>$data) {
975
echo '<option value="'.$id.'"';
976
if($id == $identity) {
979
echo '>'.htmlspecialchars($data['full_name'].' <'.$data['email_address'].'>').
978
html_tag( 'td', '', 'right', $color[4], 'width="10%"' ) .
979
_("From:") . '</td>' . "\n" .
980
html_tag( 'td', '', 'left', $color[4], 'width="90%"' ) .
981
' <select name="identity">' . "\n" .
982
' <option value="default">' .
983
htmlspecialchars($fn);
986
echo htmlspecialchars(' <' . $em . '>') . "\n";
988
echo htmlspecialchars($em) . "\n";
992
for ($i = 1; $i < $idents; $i ++) {
993
$fn = getPref($data_dir, $username, 'full_name' . $i);
994
$em = getPref($data_dir, $username, 'email_address' . $i);
996
echo '<option value="' . $i . '"';
997
if (isset($identity) && $identity == $i) {
998
echo ' selected="selected"';
1000
echo '>' . htmlspecialchars($fn);
1003
echo htmlspecialchars(' <' . $em . '>') . "\n";
1005
echo htmlspecialchars($em) . "\n";
983
1011
echo '</select>' . "\n" .
987
1016
echo ' <tr>' . "\n" .
988
html_tag( 'td', '', 'right', $color[4], 'width="10%"' ) .
989
_("To:") . '</TD>' . "\n" .
990
html_tag( 'td', '', 'left', $color[4], 'width="90%"' ) .
991
' <input type="text" name="send_to" value="' .
992
$send_to . '" size="60" /><br />' . "\n" .
996
html_tag( 'td', '', 'right', $color[4] ) .
997
_("CC:") . '</td>' . "\n" .
998
html_tag( 'td', '', 'left', $color[4] ) .
999
' <input type="text" name="send_to_cc" size="60" value="' .
1000
$send_to_cc . '" /><br />' . "\n" .
1004
html_tag( 'td', '', 'right', $color[4] ) .
1005
_("BCC:") . '</td>' . "\n" .
1006
html_tag( 'td', '', 'left', $color[4] ) .
1007
' <input type="text" name="send_to_bcc" value="' .
1008
$send_to_bcc . '" size="60" /><br />' . "\n" .
1012
html_tag( 'td', '', 'right', $color[4] ) .
1013
_("Subject:") . '</td>' . "\n" .
1014
html_tag( 'td', '', 'left', $color[4] ) . "\n";
1015
echo ' <input type="text" name="subject" size="60" value="' .
1016
$subject . '" />' . "\n" .
1017
html_tag( 'td', '', 'right', $color[4], 'width="10%"' ) .
1018
_("To") . ':</td>' . "\n" .
1019
html_tag( 'td', '', 'left', $color[4], 'width="90%"' ) .
1020
addInput('send_to', $send_to, 60). '<br />' . "\n" .
1024
html_tag( 'td', '', 'right', $color[4] ) .
1025
_("Cc") . ':</td>' . "\n" .
1026
html_tag( 'td', '', 'left', $color[4] ) .
1027
addInput('send_to_cc', $send_to_cc, 60). '<br />' . "\n" .
1031
html_tag( 'td', '', 'right', $color[4] ) .
1032
_("Bcc") . ':</td>' . "\n" .
1033
html_tag( 'td', '', 'left', $color[4] ) .
1034
addInput('send_to_bcc', $send_to_bcc, 60).'<br />' . "\n" .
1038
html_tag( 'td', '', 'right', $color[4] ) .
1039
_("Subject") . ':</td>' . "\n" .
1040
html_tag( 'td', '', 'left', $color[4] ) . "\n";
1041
echo ' '.addInput('subject', $subject, 60).
1020
1045
if ($location_of_buttons == 'between') {
1021
1046
showComposeButtonRow();
1024
1049
/* why this distinction? */
1025
1050
if ($compose_new_win == '1') {
1026
echo ' <TR>' . "\n" .
1027
' <TD BGCOLOR="' . $color[0] . '" COLSPAN=2 ALIGN=CENTER>' . "\n" .
1028
' <TEXTAREA NAME=body ID=body ROWS=20 COLS="' .
1029
$editor_size . '" WRAP="VIRTUAL">';
1051
echo ' <tr>' . "\n" .
1052
' <td bgcolor="' . $color[0] . '" colspan="2" align="center">' . "\n" .
1053
' <textarea name="body" id="body" rows="' . (int)$editor_height .
1054
'" cols="' . (int)$editor_size . '" wrap="virtual">';
1032
echo ' <TR>' . "\n" .
1033
' <TD BGCOLOR="' . $color[4] . '" COLSPAN=2>' . "\n" .
1034
' <TEXTAREA NAME=body ID=body ROWS=20 COLS="' .
1035
$editor_size . '" WRAP="VIRTUAL">';
1057
echo ' <tr>' . "\n" .
1058
' <td bgcolor="' . $color[4] . '" colspan="2">' . "\n" .
1059
' <textarea name="body" id="body" rows="' . (int)$editor_height .
1060
'" cols="' . (int)$editor_size . '" wrap="virtual">';
1038
1063
if ($use_signature == true && $newmail == true && !isset($from_htmladdr_search)) {
1039
$signature = $idents[$identity]['signature'];
1065
if ($identity == 'default') {
1070
$signature = getSig($data_dir, $username, $no);
1041
1073
if ($sig_first == '1') {
1042
1074
if ($default_charset == 'iso-2022-jp') {
1043
1075
echo "\n\n".($prefix_sig==true? "-- \n":'').mb_convert_encoding($signature, 'EUC-JP');
1045
echo "\n\n".($prefix_sig==true? "-- \n":'').decodeHeader($signature,false,false);
1077
echo "\n\n".($prefix_sig==true? "-- \n":'').decodeHeader($signature,false,false,true);
1047
echo "\n\n".decodeHeader($body,false,false);
1079
echo "\n\n".htmlspecialchars(decodeHeader($body,false,false,true));
1050
echo "\n\n".decodeHeader($body,false,false);
1082
echo "\n\n".htmlspecialchars(decodeHeader($body,false,false,true));
1051
1083
if ($default_charset == 'iso-2022-jp') {
1052
1084
echo "\n\n".($prefix_sig==true? "-- \n":'').mb_convert_encoding($signature, 'EUC-JP');
1054
echo "\n\n".($prefix_sig==true? "-- \n":'').decodeHeader($signature,false,false);
1086
echo "\n\n".($prefix_sig==true? "-- \n":'').decodeHeader($signature,false,false,true);
1059
echo decodeHeader($body,false,false);
1090
echo htmlspecialchars(decodeHeader($body,false,false,true));
1061
1092
echo '</textarea><br />' . "\n" .
1066
1097
if ($location_of_buttons == 'bottom') {
1067
1098
showComposeButtonRow();
1069
1100
echo ' <tr>' . "\n" .
1070
html_tag( 'td', '', 'right', '', 'colspan="2"' ) . "\n" .
1071
' <input type="submit" name="send" value="' . _("Send") . '" />' . "\n" .
1072
' <br /><br />' . "\n" .
1101
html_tag( 'td', '', 'right', '', 'colspan="2"' ) . "\n" .
1102
' ' . addSubmit(_("Send"), 'send').
1103
' <br /><br />' . "\n" .
1077
1108
/* This code is for attachments */
1078
if ((bool) ini_get('file_uploads')) {
1080
/* Calculate the max size for an uploaded file.
1081
* This is advisory for the user because we can't actually prevent
1082
* people to upload too large files. */
1084
/* php.ini vars which influence the max for uploads */
1085
$configvars = array('post_max_size', 'memory_limit', 'upload_max_filesize');
1086
foreach($configvars as $var) {
1087
/* skip 0 or empty values */
1088
if( $size = getByteSize(ini_get($var)) ) {
1093
if(count($sizes) > 0) {
1094
$maxsize = '(max. ' . show_readable_size( min( $sizes ) ) . ')';
1098
echo '<INPUT TYPE="hidden" name="MAX_FILE_SIZE" value="'.min( $sizes ).'">';
1099
echo ' <tr>' . "\n" .
1100
' <td colspan="2">' . "\n" .
1101
' <table width="100%" cellpadding="1" cellspacing="0" align="center"'.
1102
' border="0" bgcolor="'.$color[9].'">' . "\n" .
1105
' <table width="100%" cellpadding="3" cellspacing="0" align="center"'.
1106
' border="0">' . "\n" .
1108
html_tag( 'td', '', 'right', '', 'valign="middle"' ) .
1109
_("Attach:") . '</td>' . "\n" .
1110
html_tag( 'td', '', 'left', '', 'valign="middle"' ) .
1111
' <input name="attachfile" size="48" type="file" />' . "\n" .
1112
' <input type="submit" name="attach"' .
1113
' value="' . _("Add") .'">' . "\n" .
1120
if ($composeMessage->entities) {
1121
foreach ($composeMessage->entities as $key => $attachment) {
1122
$attached_file = $attachment->att_local_name;
1123
if ($attachment->att_local_name || $attachment->body_part) {
1124
$attached_filename = decodeHeader($attachment->mime_header->getParameter('name'));
1125
$type = $attachment->mime_header->type0.'/'.
1109
if ((bool) ini_get('file_uploads')) {
1111
/* Calculate the max size for an uploaded file.
1112
* This is advisory for the user because we can't actually prevent
1113
* people to upload too large files. */
1115
/* php.ini vars which influence the max for uploads */
1116
$configvars = array('post_max_size', 'memory_limit', 'upload_max_filesize');
1117
foreach($configvars as $var) {
1118
/* skip 0 or empty values, and -1 which means 'unlimited' */
1119
if( $size = getByteSize(ini_get($var)) ) {
1120
if ( $size != '-1' ) {
1126
if(count($sizes) > 0) {
1127
$maxsize = '(max. ' . show_readable_size( min( $sizes ) ) . ')';
1128
echo addHidden('MAX_FILE_SIZE', min( $sizes ));
1132
echo ' <tr>' . "\n" .
1133
' <td colspan="2">' . "\n" .
1134
' <table width="100%" cellpadding="1" cellspacing="0" align="center"'.
1135
' border="0" bgcolor="'.$color[9].'">' . "\n" .
1138
' <table width="100%" cellpadding="3" cellspacing="0" align="center"'.
1139
' border="0">' . "\n" .
1141
html_tag( 'td', '', 'right', '', 'valign="middle"' ) .
1142
_("Attach:") . '</td>' . "\n" .
1143
html_tag( 'td', '', 'left', '', 'valign="middle"' ) .
1144
' <input name="attachfile" size="48" type="file" />' . "\n" .
1145
' <input type="submit" name="attach"' .
1146
' value="' . _("Add") .'" />' . "\n" .
1152
if ($composeMessage->entities) {
1153
foreach ($composeMessage->entities as $key => $attachment) {
1154
$attached_file = $attachment->att_local_name;
1155
if ($attachment->att_local_name || $attachment->body_part) {
1156
$attached_filename = decodeHeader($attachment->mime_header->getParameter('name'));
1157
$type = $attachment->mime_header->type0.'/'.
1126
1158
$attachment->mime_header->type1;
1128
$s_a[] = '<table bgcolor="'.$color[0].
1129
'" border="0"><tr><td><input type="checkbox" name="delete[]" value="' .
1130
$key . "\"></td><td>\n" . $attached_filename .
1131
'</td><td>-</td><td> ' . $type . '</td><td>('.
1132
show_readable_size( filesize( $attached_file ) ) . ')</td></tr></table>'."\n";
1137
foreach ($s_a as $s) {
1138
echo '<tr>' . html_tag( 'td', '', 'left', $color[0], 'colspan="2"' ) . $s .'</td></tr>';
1140
echo '<tr><td colspan="2"><input type="submit" name="do_delete" value="' .
1141
_("Delete selected attachments") . "\">\n" .
1144
echo ' </table>' . "\n" .
1147
' </TABLE>' . "\n" .
1150
} // End of file_uploads if-block
1160
$s_a[] = '<table bgcolor="'.$color[0].
1161
'" border="0"><tr><td>'.
1162
addCheckBox('delete[]', FALSE, $key).
1163
"</td><td>\n" . $attached_filename .
1164
'</td><td>-</td><td> ' . $type . '</td><td>('.
1165
show_readable_size( filesize( $attached_file ) ) . ')</td></tr></table>'."\n";
1170
foreach ($s_a as $s) {
1171
echo '<tr>' . html_tag( 'td', '', 'left', $color[0], 'colspan="2"' ) . $s .'</td></tr>';
1173
echo '<tr><td colspan="2"><input type="submit" name="do_delete" value="' .
1174
_("Delete selected attachments") . "\" />\n" .
1177
echo ' </table>' . "\n" .
1180
' </table>' . "\n" .
1183
} // End of file_uploads if-block
1151
1184
/* End of attachment code */
1152
1185
if ($compose_new_win == '1') {
1153
echo '</TABLE>'."\n";
1186
echo '</table>'."\n";
1156
echo '</TABLE>' . "\n" .
1157
'<input type="hidden" name="username" value="'. $username . "\">\n" .
1158
'<input type=hidden name=smaction value="' . $action . "\">\n" .
1159
'<INPUT TYPE=hidden NAME=mailbox VALUE="' . htmlspecialchars($mailbox) .
1189
echo '</table>' . "\n" .
1190
addHidden('username', $username).
1191
addHidden('smaction', $action).
1192
addHidden('mailbox', $mailbox);
1162
1194
store the complete ComposeMessages array in a hidden input value
1163
1195
so we can restore them in case of a session timeout.
1165
1197
sqgetGlobalVar('QUERY_STRING', $queryString, SQ_SERVER);
1166
echo '<input type=hidden name=restoremessages value="' . urlencode(serialize($compose_messages)) . "\">\n";
1167
echo '<input type=hidden name=composesession value="' . $composesession . "\">\n";
1168
echo '<input type=hidden name=querystring value="' . $queryString . "\">\n";
1198
echo addHidden('restoremessages', serialize($compose_messages)).
1199
addHidden('composesession', $composesession).
1200
addHidden('querystring', $queryString).
1170
1202
if (!(bool) ini_get('file_uploads')) {
1171
/* File uploads are off, so we didn't show that part of the form.
1172
To avoid bogus bug reports, tell the user why. */
1173
echo 'Because PHP file uploads are turned off, you can not attach files ';
1174
echo "to this message. Please see your system administrator for details.\r\n";
1203
/* File uploads are off, so we didn't show that part of the form.
1204
To avoid bogus bug reports, tell the user why. */
1205
echo 'Because PHP file uploads are turned off, you can not attach files ';
1206
echo "to this message. Please see your system administrator for details.\r\n";
1177
1209
do_hook('compose_bottom');
1178
echo '</BODY></HTML>' . "\n";
1210
echo '</body></html>' . "\n";
1182
1214
function showComposeButtonRow() {
1183
1215
global $use_javascript_addr_book, $save_as_draft,
1184
$default_use_priority, $mailprio, $default_use_mdn,
1185
$request_mdn, $request_dr,
1186
$data_dir, $username;
1216
$default_use_priority, $mailprio, $default_use_mdn,
1217
$request_mdn, $request_dr,
1218
$data_dir, $username;
1188
echo ' <TR>' . "\n" .
1189
' <TD></TD>' . "\n" .
1220
echo ' <tr>' . "\n" .
1221
' <td></td>' . "\n" .
1191
1223
if ($default_use_priority) {
1192
1224
if(!isset($mailprio)) {
1195
echo ' ' . _("Priority") .': <select name="mailprio">'.
1196
'<option value="1"'.($mailprio=='1'?' selected':'').'>'. _("High") .'</option>'.
1197
'<option value="3"'.($mailprio=='3'?' selected':'').'>'. _("Normal") .'</option>'.
1198
'<option value="5"'.($mailprio=='5'?' selected':'').'>'. _("Low").'</option>'.
1227
echo ' ' . _("Priority") .
1228
addSelect('mailprio', array(
1231
'5' => _("Low") ), $mailprio, TRUE);
1201
1233
$mdn_user_support=getPref($data_dir, $username, 'mdn_user_support',$default_use_mdn);
1202
1234
if ($default_use_mdn) {
1203
1235
if ($mdn_user_support) {
1204
1236
echo ' ' . _("Receipt") .': '.
1205
'<input type="checkbox" name="request_mdn" value=1'.
1206
($request_mdn=='1'?' checked':'') .'>'. _("On Read").
1207
' <input type="checkbox" name="request_dr" value=1'.
1208
($request_dr=='1'?' checked':'') .'>'. _("On Delivery");
1237
addCheckBox('request_mdn', $request_mdn == '1', '1'). _("On Read").
1238
addCheckBox('request_dr', $request_dr == '1', '1'). _("On Delivery");
1212
echo ' </TD>' . "\n" .
1215
' <TD></TD>' . "\n" .
1217
' <INPUT TYPE=SUBMIT NAME="sigappend" VALUE="' . _("Signature") . '">' . "\n";
1242
echo ' </td>' . "\n" .
1245
' <td></td>' . "\n" .
1247
' <input type="submit" name="sigappend" value="' . _("Signature") . '" />' . "\n";
1218
1248
if ($use_javascript_addr_book) {
1219
echo " <SCRIPT LANGUAGE=JavaScript><!--\n document.write(\"".
1220
" <input type=button value=\\\""._("Addresses").
1221
"\\\" onclick='javascript:open_abook();'>\");".
1222
" // --></SCRIPT><NOSCRIPT>\n".
1223
" <input type=submit name=\"html_addr_search\" value=\"".
1224
_("Addresses")."\">".
1249
echo " <script language=\"JavaScript\"><!--\n document.write(\"".
1250
" <input type=button value=\\\""._("Addresses").
1251
"\\\" onclick=\\\"javascript:open_abook();\\\" />\");".
1252
" // --></script><noscript>\n".
1253
' <input type="submit" name="html_addr_search" value="'.
1254
_("Addresses").'" />'.
1227
echo ' <input type=submit name="html_addr_search" value="'.
1228
_("Addresses").'">' . "\n";
1257
echo ' <input type="submit" name="html_addr_search" value="'.
1258
_("Addresses").'" />' . "\n";
1231
1261
if ($save_as_draft) {
1232
echo ' <input type="submit" name ="draft" value="' . _("Save Draft") . "\">\n";
1262
echo ' <input type="submit" name ="draft" value="' . _("Save Draft") . "\" />\n";
1235
echo ' <INPUT TYPE=submit NAME=send VALUE="'. _("Send") . '">' . "\n";
1265
echo ' <input type="submit" name="send" value="'. _("Send") . '" />' . "\n";
1236
1266
do_hook('compose_button_row');
1238
echo ' </TD>' . "\n" .
1268
echo ' </td>' . "\n" .
1242
1272
function checkInput ($show) {
1463
1488
global $smtpServerAddress, $smtpPort, $pop_before_smtp, $smtp_auth_mech;
1465
1490
$authPop = (isset($pop_before_smtp) && $pop_before_smtp) ? true : false;
1466
get_smtp_user($user, $pass);
1492
if ($smtp_auth_mech == 'none' && !$authPop) {
1496
global $key, $onetimepad;
1498
$pass = OneTimePadDecrypt($key, $onetimepad);
1467
1501
$stream = $deliver->initStream($composeMessage,$domain,0,
1468
$smtpServerAddress, $smtpPort, $user, $pass, $authPop);
1502
$smtpServerAddress, $smtpPort, $user, $pass, $authPop);
1469
1503
} elseif (!$draft) {
1470
require_once(SM_PATH . 'class/deliver/Deliver_SendMail.class.php');
1471
global $sendmail_path;
1472
$deliver = new Deliver_SendMail();
1473
$stream = $deliver->initStream($composeMessage,$sendmail_path);
1504
require_once(SM_PATH . 'class/deliver/Deliver_SendMail.class.php');
1505
global $sendmail_path;
1506
$deliver = new Deliver_SendMail();
1507
$stream = $deliver->initStream($composeMessage,$sendmail_path);
1474
1508
} elseif ($draft) {
1475
global $draft_folder;
1476
require_once(SM_PATH . 'class/deliver/Deliver_IMAP.class.php');
1477
$imap_stream = sqimap_login($username, $key, $imapServerAddress,
1479
if (sqimap_mailbox_exists ($imap_stream, $draft_folder)) {
1480
require_once(SM_PATH . 'class/deliver/Deliver_IMAP.class.php');
1481
$imap_deliver = new Deliver_IMAP();
1482
$length = $imap_deliver->mail($composeMessage);
1483
sqimap_append ($imap_stream, $draft_folder, $length);
1484
$imap_deliver->mail($composeMessage, $imap_stream);
1485
sqimap_append_done ($imap_stream, $draft_folder);
1486
sqimap_logout($imap_stream);
1487
unset ($imap_deliver);
1509
global $draft_folder;
1510
require_once(SM_PATH . 'class/deliver/Deliver_IMAP.class.php');
1511
$imap_stream = sqimap_login($username, $key, $imapServerAddress,
1513
if (sqimap_mailbox_exists ($imap_stream, $draft_folder)) {
1514
require_once(SM_PATH . 'class/deliver/Deliver_IMAP.class.php');
1515
$imap_deliver = new Deliver_IMAP();
1516
$length = $imap_deliver->mail($composeMessage);
1517
sqimap_append ($imap_stream, $draft_folder, $length);
1518
$imap_deliver->mail($composeMessage, $imap_stream);
1519
sqimap_append_done ($imap_stream, $draft_folder);
1520
sqimap_logout($imap_stream);
1521
unset ($imap_deliver);
1490
$msg = '<br>Error: '._("Draft folder")." $draft_folder" . ' does not exist.';
1491
plain_error_message($msg, $color);
1524
$msg = '<br />'.sprintf(_("Error: Draft folder %s does not exist."), $draft_folder);
1525
plain_error_message($msg, $color);
1495
1529
$succes = false;