$msgi+1 doesn't work when using anything but the system's default sort.
[squirrelmail.git] / functions / imap_messages.php
... / ...
CommitLineData
1<?php
2
3/**
4 * imap_messages.php
5 *
6 * Copyright (c) 1999-2002 The SquirrelMail Project Team
7 * Licensed under the GNU GPL. For full terms see the file COPYING.
8 *
9 * This implements functions that manipulate messages
10 *
11 * $Id$
12 */
13
14/* Copies specified messages to specified folder */
15function sqimap_messages_copy ($imap_stream, $start, $end, $mailbox) {
16 global $uid_support;
17 $read = sqimap_run_command ($imap_stream, "COPY $start:$end \"$mailbox\"", true, $response, $message, $uid_support);
18}
19
20/* Deletes specified messages and moves them to trash if possible */
21function sqimap_messages_delete ($imap_stream, $start, $end, $mailbox) {
22 global $move_to_trash, $trash_folder, $auto_expunge, $uid_support;
23
24 if (($move_to_trash == true) && (sqimap_mailbox_exists($imap_stream, $trash_folder) && ($mailbox != $trash_folder))) {
25 sqimap_messages_copy ($imap_stream, $start, $end, $trash_folder);
26 }
27 sqimap_messages_flag ($imap_stream, $start, $end, "Deleted");
28}
29
30/* Sets the specified messages with specified flag */
31function sqimap_messages_flag ($imap_stream, $start, $end, $flag) {
32 global $uid_support;
33 $read = sqimap_run_command ($imap_stream, "STORE $start:$end +FLAGS (\\$flag)", true, $response, $message, $uid_support);
34}
35
36/* Remove specified flag from specified messages */
37function sqimap_messages_remove_flag ($imap_stream, $start, $end, $flag) {
38 global $uid_support;
39 $read = sqimap_run_command ($imap_stream, "STORE $start:$end -FLAGS (\\$flag)", true, $response, $message, $uid_support);
40}
41
42/* Returns some general header information -- FROM, DATE, and SUBJECT */
43class small_header {
44 var $from = '', $subject = '', $date = '', $to = '',
45 $priority = 0, $message_id = 0, $cc = '', $uid = '';
46}
47
48function sqimap_get_small_header ($imap_stream, $id, $sent) {
49 $res = sqimap_get_small_header_list($imap_stream, array($id), $sent);
50 return $res[0];
51}
52
53/*
54 * Sort the message list and crunch to be as small as possible
55 * (overflow could happen, so make it small if possible)
56 */
57function sqimap_message_list_squisher($messages_array) {
58 if( !is_array( $messages_array ) ) {
59 return;
60 }
61
62 sort($messages_array, SORT_NUMERIC);
63 $msgs_str = '';
64 while ($messages_array) {
65 $start = array_shift($messages_array);
66 $end = $start;
67 while (isset($messages_array[0]) && $messages_array[0] == $end + 1) {
68 $end = array_shift($messages_array);
69 }
70 if ($msgs_str != '') {
71 $msgs_str .= ',';
72 }
73 $msgs_str .= $start;
74 if ($start != $end) {
75 $msgs_str .= ':' . $end;
76 }
77 }
78 return $msgs_str;
79}
80
81/* returns the references header lines */
82function get_reference_header ($imap_stream, $message) {
83 global $uid_support;
84 $responses = array ();
85 $sid = sqimap_session_id($uid_support);
86 $results = array();
87 $references = "";
88 $query = "$sid FETCH $message BODY[HEADER.FIELDS (References)]\r\n";
89 fputs ($imap_stream, $query);
90 $responses = sqimap_read_data_list($imap_stream, $sid, true, $responses, $message);
91 if (!eregi("^\\* ([0-9]+) FETCH", $responses[0][0], $regs)) {
92 $responses = array ();
93 }
94 return $responses;
95}
96
97
98/* get sort order from server and
99 * return it as the $id array for
100 * mailbox_display
101 */
102
103function sqimap_get_sort_order ($imap_stream, $sort, $mbxresponse) {
104 global $default_charset, $thread_sort_messages,
105 $internal_date_sort, $server_sort_array,
106 $sent_folder, $mailbox, $uid_support;
107
108 if (session_is_registered('server_sort_array')) {
109 session_unregister('server_sort_array');
110 }
111
112 $sid = sqimap_session_id($uid_support);
113 $sort_on = array();
114 $reverse = 0;
115 $server_sort_array = array();
116 $sort_test = array();
117 $sort_query = '';
118
119 if ($sort == 6) {
120 if ($uid_support) {
121 $uidnext = $mbxresponse['UIDNEXT']-1;
122 $uid_query = "$sid SEARCH UID 1:$uidnext\r\n";
123 fputs($imap_stream, $uid_query);
124 $uids = sqimap_read_data($imap_stream, $sid, true ,&$response, $message);
125 if (isset($uids[0])) {
126 if (preg_match("/^\* SEARCH (.+)$/", $uids[0], $regs)) {
127 $server_sort_array = preg_split("/ /", trim($regs[1]));
128 }
129 }
130 if (!preg_match("/OK/", $response)) {
131 $server_sort_array = 'no';
132 }
133 } else {
134 $qty = $mbxresponse['EXISTS'];
135 $server_sort_array = range(1, $qty);
136 }
137 session_register('server_sort_array');
138 return $server_sort_array;
139 }
140
141 $sort_on = array (0=> 'DATE',
142 1=> 'DATE',
143 2=> 'FROM',
144 3=> 'FROM',
145 4=> 'SUBJECT',
146 5=> 'SUBJECT');
147 if ($internal_date_sort == true) {
148 $sort_on[0] = 'ARRIVAL';
149 $sort_on[1] = 'ARRIVAL';
150 }
151 if ($sent_folder == $mailbox) {
152 $sort_on[2] = 'TO';
153 $sort_on[3] = 'TO';
154 }
155 if (!empty($sort_on[$sort])) {
156 $sort_query = "$sid SORT ($sort_on[$sort]) ".strtoupper($default_charset)." ALL\r\n";
157 fputs($imap_stream, $sort_query);
158 $sort_test = sqimap_read_data($imap_stream, $sid, true ,&$response, $message);
159 }
160 if (isset($sort_test[0])) {
161 if (preg_match("/^\* SORT (.+)$/", $sort_test[0], $regs)) {
162 $server_sort_array = preg_split("/ /", trim($regs[1]));
163 }
164 }
165 if ($sort == 0 || $sort == 2 || $sort == 4) {
166 $server_sort_array = array_reverse($server_sort_array);
167 }
168 if (!preg_match("/OK/", $response)) {
169 $server_sort_array = 'no';
170 }
171 session_register('server_sort_array');
172 return $server_sort_array;
173}
174
175
176function sqimap_get_php_sort_order ($imap_stream, $mbxresponse) {
177 global $uid_support;
178
179 if (session_is_registered('php_sort_array')) {
180 session_unregister('php_sort_array');
181 }
182
183 $sid = sqimap_session_id($uid_support);
184 $php_sort_array = array();
185
186 if ($uid_support) {
187 $uidnext = $mbxresponse['UIDNEXT']-1;
188 $uid_query = "$sid SEARCH UID 1:$uidnext\r\n";
189 fputs($imap_stream, $uid_query);
190 $uids = sqimap_read_data($imap_stream, $sid, true ,&$response, $message);
191 if (isset($uids[0])) {
192 if (preg_match("/^\* SEARCH (.+)$/", $uids[0], $regs)) {
193 $php_sort_array = preg_split("/ /", trim($regs[1]));
194 }
195 }
196 if (!preg_match("/OK/", $response)) {
197 $php_sort_array = 'no';
198 }
199 } else {
200 $qty = $mbxresponse['EXISTS'];
201 $php_sort_array = range(1, $qty);
202 }
203 session_register('php_sort_array');
204 return $php_sort_array;
205}
206
207
208/* returns an indent array for printMessageinfo()
209 this represents the amount of indent needed (value)
210 for this message number (key)
211*/
212
213function get_parent_level ($imap_stream) {
214 global $sort_by_ref, $default_charset, $thread_new;
215 $parent = "";
216 $child = "";
217 $cutoff = 0;
218
219 /* loop through the threads and take unwanted characters out
220 of the thread string then chop it up
221 */
222 for ($i=0;$i<count($thread_new);$i++) {
223 $thread_new[$i] = preg_replace("/\s\(/", "(", $thread_new[$i]);
224 $thread_new[$i] = preg_replace("/(\d+)/", "$1|", $thread_new[$i]);
225 $thread_new[$i] = preg_split("/\|/", $thread_new[$i], -1, PREG_SPLIT_NO_EMPTY);
226 }
227 $indent_array = array();
228 if (!$thread_new) {
229 $thread_new = array();
230 }
231 /* looping through the parts of one message thread */
232
233 for ($i=0;$i<count($thread_new);$i++) {
234 /* first grab the parent, it does not indent */
235
236 if (isset($thread_new[$i][0])) {
237 if (preg_match("/(\d+)/", $thread_new[$i][0], $regs)) {
238 $parent = $regs[1];
239 }
240 }
241 $indent_array[$parent] = 0;
242
243 /* now the children, checking each thread portion for
244 ),(, and space, adjusting the level and space values
245 to get the indent level
246 */
247 $level = 0;
248 $spaces = array();
249 $spaces_total = 0;
250 $indent = 0;
251 $fake = FALSE;
252 for ($k=1;$k<(count($thread_new[$i]))-1;$k++) {
253 $chars = count_chars($thread_new[$i][$k], 1);
254 if (isset($chars['40'])) { /* testing for ( */
255 $level = $level + $chars['40'];
256 }
257 if (isset($chars['41'])) { /* testing for ) */
258 $level = $level - $chars['41'];
259 $spaces[$level] = 0;
260 /* if we were faking lets stop, this portion
261 of the thread is over
262 */
263 if ($level == $cutoff) {
264 $fake = FALSE;
265 }
266 }
267 if (isset($chars['32'])) { /* testing for space */
268 if (!isset($spaces[$level])) {
269 $spaces[$level] = 0;
270 }
271 $spaces[$level] = $spaces[$level] + $chars['32'];
272 }
273 for ($x=0;$x<=$level;$x++) {
274 if (isset($spaces[$x])) {
275 $spaces_total = $spaces_total + $spaces[$x];
276 }
277 }
278 $indent = $level + $spaces_total;
279 /* must have run into a message that broke the thread
280 so we are adjusting for that portion
281 */
282 if ($fake == TRUE) {
283 $indent = $indent +1;
284 }
285 if (preg_match("/(\d+)/", $thread_new[$i][$k], $regs)) {
286 $child = $regs[1];
287 }
288 /* the thread must be broken if $indent == 0
289 so indent the message once and start faking it
290 */
291 if ($indent == 0) {
292 $indent = 1;
293 $fake = TRUE;
294 $cutoff = $level;
295 }
296 /* dont need abs but if indent was negative
297 errors would occur
298 */
299 $indent_array[$child] = abs($indent);
300 $spaces_total = 0;
301 }
302 }
303 return $indent_array;
304}
305
306
307/* returns an array with each element as a string
308 representing one message thread as returned by
309 the IMAP server
310*/
311
312function get_thread_sort ($imap_stream) {
313 global $thread_new, $sort_by_ref, $default_charset, $server_sort_array, $uid_support;
314 if (session_is_registered('thread_new')) {
315 session_unregister('thread_new');
316 }
317 if (session_is_registered('server_sort_array')) {
318 session_unregister('server_srot_array');
319 }
320 $sid = sqimap_session_id($uid_support);
321 $thread_temp = array ();
322 if ($sort_by_ref == 1) {
323 $sort_type = 'REFERENCES';
324 }
325 else {
326 $sort_type = 'ORDEREDSUBJECT';
327 }
328 $thread_query = "$sid THREAD $sort_type ".strtoupper($default_charset)." ALL\r\n";
329 fputs($imap_stream, $thread_query);
330 $thread_test = sqimap_read_data($imap_stream, $sid, false, $response, $message);
331 if (isset($thread_test[0])) {
332 if (preg_match("/^\* THREAD (.+)$/", $thread_test[0], $regs)) {
333 $thread_list = trim($regs[1]);
334 }
335 }
336 else {
337 $thread_list = "";
338 }
339 if (!preg_match("/OK/", $response)) {
340 $server_sort_array = 'no';
341 return $server_sort_array;
342 }
343 if (isset($thread_list)) {
344 $thread_temp = preg_split("//", $thread_list, -1, PREG_SPLIT_NO_EMPTY);
345 }
346 $char_count = count($thread_temp);
347 $counter = 0;
348 $thread_new = array();
349 $k = 0;
350 $thread_new[0] = "";
351 for ($i=0;$i<$char_count;$i++) {
352 if ($thread_temp[$i] != ')' && $thread_temp[$i] != '(') {
353 $thread_new[$k] = $thread_new[$k] . $thread_temp[$i];
354 }
355 elseif ($thread_temp[$i] == '(') {
356 $thread_new[$k] .= $thread_temp[$i];
357 $counter++;
358 }
359 elseif ($thread_temp[$i] == ')') {
360 if ($counter > 1) {
361 $thread_new[$k] .= $thread_temp[$i];
362 $counter = $counter - 1;
363 }
364 else {
365 $thread_new[$k] .= $thread_temp[$i];
366 $k++;
367 $thread_new[$k] = "";
368 $counter = $counter - 1;
369 }
370 }
371 }
372 session_register('thread_new');
373 $thread_new = array_reverse($thread_new);
374 $thread_list = implode(" ", $thread_new);
375 $thread_list = str_replace("(", " ", $thread_list);
376 $thread_list = str_replace(")", " ", $thread_list);
377 $thread_list = preg_split("/\s/", $thread_list, -1, PREG_SPLIT_NO_EMPTY);
378 $server_sort_array = $thread_list;
379 session_register('server_sort_array');
380 return $thread_list;
381}
382
383function elapsedTime($start) {
384 $stop = gettimeofday();
385 $timepassed = 1000000 * ($stop['sec'] - $start['sec']) + $stop['usec'] - $start['usec'];
386 return $timepassed;
387}
388
389function sqimap_get_small_header_list ($imap_stream, $msg_list, $issent) {
390 global $squirrelmail_language, $color, $data_dir, $username, $imap_server_type;
391 global $uid_support;
392
393 /* Get the small headers for each message in $msg_list */
394 $sid = sqimap_session_id($uid_support);
395
396 $maxmsg = sizeof($msg_list);
397 $msgs_str = sqimap_message_list_squisher($msg_list);
398 $results = array();
399 $read_list = array();
400 /*
401 * We need to return the data in the same order as the caller supplied
402 * in $msg_list, but IMAP servers are free to return responses in
403 * whatever order they wish... So we need to re-sort manually
404 */
405 for ($i = 0; $i < sizeof($msg_list); $i++) {
406 $id2index[$msg_list[$i]] = $i;
407 }
408
409 $internaldate = getPref($data_dir, $username, 'internal_date_sort');
410 if ($internaldate) {
411 $query = "$sid FETCH $msgs_str (FLAGS UID RFC822.SIZE INTERNALDATE BODY.PEEK[HEADER.FIELDS (Date To From Cc Subject X-Priority Content-Type)])\r\n";
412 } else {
413 $query = "$sid FETCH $msgs_str (FLAGS UID RFC822.SIZE BODY.PEEK[HEADER.FIELDS (Date To From Cc Subject X-Priority Content-Type)])\r\n";
414 }
415 fputs ($imap_stream, $query);
416 $readin_list = sqimap_read_data_list($imap_stream, $sid, false, $response, $message);
417 $i = 0;
418 foreach ($readin_list as $r) {
419 if (!$uid_support) {
420 if (!preg_match("/^\\*\s+([0-9]+)\s+FETCH/iAU",$r[0], $regs)) {
421 set_up_language($squirrelmail_language);
422 echo '<br><b><font color=$color[2]>' .
423 _("ERROR : Could not complete request.") .
424 '</b><br>' .
425 _("Unknown response from IMAP server: ") . ' 1.' .
426 $r[0] . "</font><br>\n";
427
428 } else if (! isset($id2index[$regs[1]]) || !count($id2index[$regs[1]])) {
429 set_up_language($squirrelmail_language);
430 echo '<br><b><font color=$color[2]>' .
431 _("ERROR : Could not complete request.") .
432 '</b><br>' .
433 _("Unknown message number in reply from server: ") .
434 $regs[1] . "</font><br>\n";
435 } else {
436 $read_list[$id2index[$regs[1]]] = $r;
437 }
438 } else {
439 if (!preg_match("/^\\*\s+([0-9]+)\s+FETCH.*UID\s+([0-9]+)\s+/iAU",$r[0], $regs)) {
440 set_up_language($squirrelmail_language);
441 echo '<br><b><font color=$color[2]>' .
442 _("ERROR : Could not complete request.") .
443 '</b><br>' .
444 _("Unknown response from IMAP server: ") . ' 1.' .
445 $r[0] . "</font><br>\n";
446 } else if (! isset($id2index[$regs[2]]) || !count($id2index[$regs[2]])) {
447 set_up_language($squirrelmail_language);
448 echo '<br><b><font color=$color[2]>' .
449 _("ERROR : Could not complete request.") .
450 '</b><br>' .
451 _("Unknown message number in reply from server: ") .
452 $regs[2] . "</font><br>\n";
453 } else {
454 $read_list[$id2index[$regs[2]]] = $r;
455 $unique_id = $regs[2];
456 }
457 }
458 }
459 arsort($read_list);
460
461 $patterns = array (
462 "/^To:(.*)\$/AUi",
463 "/^From:(.*)\$/AUi",
464 "/^X-Priority:(.*)\$/AUi",
465 "/^Cc:(.*)\$/AUi",
466 "/^Date:(.*)\$/AUi",
467 "/^Subject:(.*)\$/AUi",
468 "/^Content-Type:(.*)\$/AUi"
469 );
470 $regpattern = '';
471
472 for ($msgi = 0; $msgi < $maxmsg; $msgi++) {
473 $subject = _("(no subject)");
474 $from = _("Unknown Sender");
475 $priority = 0;
476 $messageid = "<>";
477 $cc = "";
478 $to = "";
479 $date = "";
480 $type[0] = "";
481 $type[1] = "";
482 $inrepto = "";
483 $flag_seen = false;
484 $flag_answered = false;
485 $flag_deleted = false;
486 $flag_flagged = false;
487 $read = $read_list[$msgi];
488 $prevline = false;
489
490 foreach ($read as $read_part) {
491 //unfold multi-line headers
492 while ($prevline && strspn($read_part, "\t ") > 0) {
493 $read_part = substr($prevline, 0, -2) . ' ' . ltrim($read_part);
494 }
495 $prev_line = $read_part;
496 if ($read_part{0} == '*') {
497 if ($internaldate) {
498 if (preg_match ("/^.+INTERNALDATE\s+\"(.+)\".+/iUA",$read_part, $reg)) {
499 $tmpdate = trim($reg[1]);
500 $tmpdate = str_replace(' ',' ',$tmpdate);
501 $tmpdate = explode(' ',$tmpdate);
502 $date = str_replace('-',' ',$tmpdate[0]) . " " .
503 $tmpdate[1] . " " .
504 $tmpdate[2];
505 }
506 }
507 if (preg_match ("/^.+RFC822.SIZE\s+(\d+).+/iA",$read_part, $reg)) {
508 $size = $reg[1];
509 }
510 if (preg_match("/^.+FLAGS\s+\((.*)\).+/iUA", $read_part, $regs)) {
511 $flags = explode(' ',trim($regs[1]));
512 foreach ($flags as $flag) {
513 $flag = strtolower($flag);
514 if ($flag == '\\seen') {
515 $flag_seen = true;
516 } else if ($flag == '\\answered') {
517 $flag_answered = true;
518 } else if ($flag == '\\deleted') {
519 $flag_deleted = true;
520 } else if ($flag == '\\flagged') {
521 $flag_flagged = true;
522 }
523 }
524 }
525 if (preg_match ("/^.+UID\s+(\d+).+/iA",$read_part, $reg)) {
526 $unique_id = $reg[1];
527 }
528
529 } else {
530 $firstchar = $read_part{0};
531 if ($firstchar == 'T') {
532 $regpattern = $patterns[0];
533 $id = 1;
534 } else if ($firstchar == 'F') {
535 $regpattern = $patterns[1];
536 $id = 2;
537 } else if ($firstchar == 'X') {
538 $regpattern = $patterns[2];
539 $id = 3;
540 } else if ($firstchar == 'C') {
541 if (strtolower($read_part{1}) == 'c') {
542 $regpattern = $patterns[3];
543 $id = 4;
544 } else if (strtolower($read_part{1}) == 'o') {
545 $regpattern = $patterns[6];
546 $id = 7;
547 }
548 } else if ($firstchar == 'D' && !$internaldate ) {
549 $regpattern = $patterns[4];
550 $id = 5;
551 } else if ($firstchar == 'S') {
552 $regpattern = $patterns[5];
553 $id = 6;
554 } else $regpattern = '';
555
556 if ($regpattern) {
557 if (preg_match ($regpattern, $read_part, $regs)) {
558 switch ($id) {
559 case 1:
560 $to = $regs[1];
561 break;
562 case 2:
563 $from = $regs[1];
564 break;
565 case 3:
566 $priority = $regs[1];
567 break;
568 case 4:
569 $cc = $regs[1];
570 break;
571 case 5:
572 $date = $regs[1];
573 break;
574 case 6:
575 $subject = htmlspecialchars(trim($regs[1]));
576 if ($subject == "") {
577 $subject = _("(no subject)");
578 }
579 break;
580 case 7:
581 $type = strtolower(trim($regs[1]));
582 if ($pos = strpos($type, ";")) {
583 $type = substr($type, 0, $pos);
584 }
585 $type = explode("/", $type);
586 if (!isset($type[1])) {
587 $type[1] = '';
588 }
589 break;
590 default:
591 break;
592 }
593 }
594 }
595 }
596
597 }
598 $header = new small_header;
599 if ($issent) {
600 $header->from = (trim($to) != '' ? $to : '(' ._("No To Address") . ')');
601 } else {
602 $header->from = $from;
603 }
604
605 if ($uid_support) {
606 $header->uid = $unique_id;
607 } else {
608 $header->uid = $msg_list[$msgi];
609 }
610 $header->date = $date;
611 $header->subject = $subject;
612 $header->to = $to;
613 $header->priority = $priority;
614 $header->message_id = $messageid;
615 $header->cc = $cc;
616 $header->size = $size;
617 $header->type0 = $type[0];
618 $header->type1 = $type[1];
619 $header->flag_seen = $flag_seen;
620 $header->flag_answered = $flag_answered;
621 $header->flag_deleted = $flag_deleted;
622 $header->flag_flagged = $flag_flagged;
623 $header->inrepto = $inrepto;
624 $result[] = $header;
625 }
626 return $result;
627}
628
629/*
630 * Returns a message array with all the information about a message.
631 * See the documentation folder for more information about this array.
632 */
633function sqimap_get_message ($imap_stream, $id, $mailbox) {
634 global $uid_support;
635
636 $flags = array();
637 $read = sqimap_run_command ($imap_stream, "FETCH $id (FLAGS BODYSTRUCTURE)", true, $response, $message, $uid_support);
638 if ($read) {
639 if (preg_match('/.+FLAGS\s\((.*)\)\s/AUi',$read[0],$regs)) {
640 if (trim($regs[1])) {
641 $flags = preg_split('/ /', $regs[1],-1,'PREG_SPLIT_NI_EMPTY');
642 }
643 }
644 } else {
645 echo "ERROR Yeah I know, not a very usefull errormessage (sqimap_get_message)";
646 exit;
647 }
648 $bodystructure = implode('',$read);
649 $msg = mime_structure($bodystructure,$flags);
650 $read = sqimap_run_command ($imap_stream, "FETCH $id BODY[HEADER]", true, $response, $message, $uid_support);
651 $msg->addRFC822Header($read);
652 $msg->id = $id;
653 $msg->mailbox = $mailbox;
654 return $msg;
655}
656
657/* Wrapper function that reformats the header information. */
658function sqimap_get_message_header ($imap_stream, $id, $mailbox) {
659 global $uid_support;
660 $read = sqimap_run_command ($imap_stream, "FETCH $id BODY[HEADER]", true, $response, $message, $uid_support);
661 $header = sqimap_get_header($imap_stream, $read);
662 $header->id = $id;
663 $header->mailbox = $mailbox;
664 return $header;
665}
666
667/* Wrapper function that reformats the entity header information. */
668function sqimap_get_ent_header ($imap_stream, $id, $mailbox, $ent) {
669 global $uid_support;
670 $read = sqimap_run_command ($imap_stream, "FETCH $id BODY[$ent.HEADER]", true, $response, $message, $uid_support);
671 $header = sqimap_get_header($imap_stream, $read);
672 $header->id = $id;
673 $header->mailbox = $mailbox;
674 return $header;
675}
676
677
678/* Wrapper function that returns entity headers for use by decodeMime */
679/*
680function sqimap_get_entity_header ($imap_stream, &$read, &$type0, &$type1, &$bound, &$encoding, &$charset, &$filename) {
681 $header = sqimap_get_header($imap_stream, $read);
682 $type0 = $header["TYPE0"];
683 $type1 = $header["TYPE1"];
684 $bound = $header["BOUNDARY"];
685 $encoding = $header["ENCODING"];
686 $charset = $header["CHARSET"];
687 $filename = $header["FILENAME"];
688}
689
690/* function to get the mime headers */
691function sqimap_get_mime_ent_header ($imap_stream, $id, $mailbox, $ent) {
692 global $uid_support;
693 $read = sqimap_run_command ($imap_stream, "FETCH $id:$id BODY[$ent.MIME]", true, $response, $message, $uid_support);
694 $header = sqimap_get_header($imap_stream, $read);
695 $header->id = $id;
696 $header->mailbox = $mailbox;
697 return $header;
698}
699
700/* Returns the body of a message. */
701function sqimap_get_message_body ($imap_stream, &$header) {
702// return decodeMime($imap_stream, $header->id);
703}
704
705?>