Add function sqimap_run_command which combines sending and receiving a
[squirrelmail.git] / functions / imap_mailbox.php
CommitLineData
59177427 1<?php
bccadd02 2
35586184 3/**
4 * imap_mailbox.php
5 *
15e6162e 6 * Copyright (c) 1999-2002 The SquirrelMail Project Team
35586184 7 * Licensed under the GNU GPL. For full terms see the file COPYING.
8 *
9 * This impliments all functions that manipulate mailboxes
10 *
11 * $Id$
12 */
f435778e 13
35586184 14/*************************
15 ** Expunges a mailbox **
16 *************************/
43b698c7 17function sqimap_mailbox_expunge ($imap_stream, $mailbox,$handle_errors = true)
18{
19 fputs ($imap_stream, sqimap_session_id() . " EXPUNGE\r\n");
20 $read = sqimap_read_data($imap_stream, sqimap_session_id(),
21 $handle_errors, $response, $message);
22}
23
24
25/******************************************************************************
26 ** Checks whether or not the specified mailbox exists
27 ******************************************************************************/
28function sqimap_mailbox_exists ($imap_stream, $mailbox)
29{
30 if (! isset($mailbox)) {
31 return false;
32 }
33 fputs ($imap_stream, sqimap_session_id() . " LIST \"\" \"$mailbox\"\r\n");
34 $mbx = sqimap_read_data($imap_stream, sqimap_session_id(),
35 true, $response, $message);
36 return isset($mbx[0]);
37}
38
39/******************************************************************************
40 ** Selects a mailbox
41 ******************************************************************************/
42function sqimap_mailbox_select ($imap_stream, $mailbox,
43 $hide=true, $recent=false)
44{
45 global $auto_expunge;
46
47 if ( $mailbox == 'None' ) {
48 return;
49 }
50
51 fputs ($imap_stream, sqimap_session_id() . " SELECT \"$mailbox\"\r\n");
52 $read = sqimap_read_data($imap_stream, sqimap_session_id(),
53 true, $response, $message);
54 if ($recent) {
55 for ($i=0; $i<count($read); $i++) {
bccadd02 56 if (strpos(strtolower($read[$i]), 'recent')) {
43b698c7 57 $r = explode(' ', $read[$i]);
04632dbc 58 }
43b698c7 59 }
60 return $r[1];
61 }
62 if ($auto_expunge) {
63 fputs ($imap_stream, sqimap_session_id() . " EXPUNGE\r\n");
64 $tmp = sqimap_read_data($imap_stream, sqimap_session_id(),
65 false, $a, $b);
66 }
67}
68
69
70
71/******************************************************************************
72 ** Creates a folder
73 ******************************************************************************/
74function sqimap_mailbox_create ($imap_stream, $mailbox, $type)
75{
76 global $delimiter;
77 if (strtolower($type) == 'noselect') {
78 $mailbox = $mailbox.$delimiter;
79 }
80 fputs ($imap_stream, sqimap_session_id() . " CREATE \"$mailbox\"\r\n");
81 $read_ary = sqimap_read_data($imap_stream, sqimap_session_id(),
82 true, $response, $message);
83
84 sqimap_subscribe ($imap_stream, $mailbox);
85}
86
87
88
89/******************************************************************************
90 ** Subscribes to an existing folder
91 ******************************************************************************/
92function sqimap_subscribe ($imap_stream, $mailbox)
93{
94 fputs ($imap_stream, sqimap_session_id() . " SUBSCRIBE \"$mailbox\"\r\n");
95 $read_ary = sqimap_read_data($imap_stream, sqimap_session_id(),
96 true, $response, $message);
97}
98
99
100
101/******************************************************************************
102 ** Unsubscribes to an existing folder
103 ******************************************************************************/
104function sqimap_unsubscribe ($imap_stream, $mailbox)
105{
106 global $imap_server_type;
107
108 fputs ($imap_stream, sqimap_session_id() . " UNSUBSCRIBE \"$mailbox\"\r\n");
109 $read_ary = sqimap_read_data($imap_stream, sqimap_session_id(),
110 true, $response, $message);
111}
112
113
114
115/******************************************************************************
116 ** This function simply deletes the given folder
117 ******************************************************************************/
118function sqimap_mailbox_delete ($imap_stream, $mailbox)
119{
120 fputs ($imap_stream, sqimap_session_id() . " DELETE \"$mailbox\"\r\n");
121 $read_ary = sqimap_read_data($imap_stream, sqimap_session_id(),
122 true, $response, $message);
123 sqimap_unsubscribe ($imap_stream, $mailbox);
124}
125
126/***********************************************************************
127 ** Determines if the user is subscribed to the folder or not
128 **********************************************************************/
129function sqimap_mailbox_is_subscribed($imap_stream, $folder)
130{
131 $boxes = sqimap_mailbox_list ($imap_stream);
132 foreach ($boxes as $ref) {
133 if ($ref['unformatted'] == $folder) {
134 return true;
135 }
136 }
137 return false;
138}
139
1c52ba77 140/*
141 Renames a mailbox
142*/
143function sqimap_mailbox_rename( $imap_stream, $old_name, $new_name ) {
43b698c7 144
1c52ba77 145 if ( $old_name <> $new_name ) {
146
147 global $delimiter;
148
149 if ( substr( $old_name, -1 ) == $delimiter ) {
150 $old_name = substr( $old_name, 0, strlen( $old_name ) - 1 );
151 $new_name = substr( $new_name, 0, strlen( $new_name ) - 1 );
152 $postfix = $delimiter;
153 $boxes = sqimap_mailbox_list($imap_stream);
154 } else {
155 $postfix = '';
156 $boxes = FALSE;
157 }
158
159 $cmd = sqimap_session_id() . " RENAME \"" . quoteIMAP($old_name) . "\" \"" .
160 quoteIMAP($new_name) . "\"\r\n";
161 fputs($imap_stream, $cmd);
162 $data = sqimap_read_data($imap_stream, sqimap_session_id(),
163 TRUE, $response, $message);
164 sqimap_unsubscribe($imap_stream, $old_name.$postfix);
165 sqimap_subscribe($imap_stream, $new_name.$postfix);
166
167 if ( $boxes ) {
168 // Sub-unsub subfolders
169 $l = strlen( $old_name ) + 1;
170 $p = 'unformatted';
171 foreach ( $boxes as $box ) {
172 if ( substr( $box[$p], 0, $l ) == $old_name . $delimiter ) {
173 sqimap_unsubscribe($imap_stream, $box[$p]);
174 sqimap_subscribe($imap_stream,
175 $new_name . $delimiter . substr( $box[$p], $l ) );
176 }
177 }
178 }
179
180 }
181
182}
43b698c7 183
184/******************************************************************************
185 ** Formats a mailbox into 4 parts for the $boxes array
186 **
187 ** The four parts are:
188 **
189 ** raw - Raw LIST/LSUB response from the IMAP server
190 ** formatted - nicely formatted folder name
191 ** unformatted - unformatted, but with delimiter at end removed
192 ** unformatted-dm - folder name as it appears in raw response
193 ** unformatted-disp - unformatted without $folder_prefix
194 **
195 ******************************************************************************/
196function sqimap_mailbox_parse ($line, $line_lsub)
197{
198 global $folder_prefix, $delimiter;
199
200 /* Process each folder line */
201 for ($g=0; $g < count($line); $g++) {
202
203 /* Store the raw IMAP reply */
204 if (isset($line[$g])) {
a7ea7540 205 $boxes[$g]["raw"] = $line[$g];
43b698c7 206 }
207 else {
a7ea7540 208 $boxes[$g]["raw"] = "";
43b698c7 209 }
210
211
212 /* Count number of delimiters ($delimiter) in folder name */
213 $mailbox = trim($line_lsub[$g]);
602e1431 214 $dm_count = substr_count($mailbox, $delimiter);
43b698c7 215 if (substr($mailbox, -1) == $delimiter) {
216 /* If name ends in delimiter - decrement count by one */
217 $dm_count--;
218 }
219
220 /* Format folder name, but only if it's a INBOX.* or have */
221 /* a parent. */
222 $boxesbyname[$mailbox] = $g;
223 $parentfolder = readMailboxParent($mailbox, $delimiter);
224 if ( (strtolower(substr($mailbox, 0, 5)) == "inbox") ||
225 (substr($mailbox, 0, strlen($folder_prefix)) == $folder_prefix) ||
226 ( isset($boxesbyname[$parentfolder]) &&
227 (strlen($parentfolder) > 0) ) ) {
602e1431 228 $indent = $dm_count - ( substr_count($folder_prefix, $delimiter));
43b698c7 229 if ($indent > 0) {
0debfed6 230 $boxes[$g]["formatted"] = str_repeat("&nbsp;&nbsp;", $indent);
43b698c7 231 }
232 else {
0debfed6 233 $boxes[$g]["formatted"] = '';
43b698c7 234 }
525b7ae6 235 $boxes[$g]["formatted"] .= readShortMailboxName($mailbox, $delimiter);
43b698c7 236 }
237 else {
2752bb16 238 $boxes[$g]["formatted"] = $mailbox;
43b698c7 239 }
240
241 $boxes[$g]['unformatted-dm'] = $mailbox;
242 if (substr($mailbox, -1) == $delimiter) {
8e9e8afa 243 $mailbox = substr($mailbox, 0, strlen($mailbox) - 1);
43b698c7 244 }
245 $boxes[$g]['unformatted'] = $mailbox;
246 if (substr($mailbox,0,strlen($folder_prefix))==$folder_prefix) {
631b9da3 247 $mailbox = substr($mailbox, strlen($folder_prefix));
43b698c7 248 }
249 $boxes[$g]['unformatted-disp'] = $mailbox;
250 $boxes[$g]['id'] = $g;
251
252 $boxes[$g]['flags'] = array();
253 if (isset($line[$g])) {
36dfb0c9 254 ereg("\(([^)]*)\)",$line[$g],$regs);
1a7e1e97 255 $flags = trim(strtolower(str_replace('\\', '',$regs[1])));
43b698c7 256 if ($flags) {
257 $boxes[$g]['flags'] = explode(' ', $flags);
258 }
259 }
260 }
261
262 return $boxes;
263}
264
a3439b27 265/**
266 * Sorting function used to sort mailbox names.
267 * + Original patch from dave_michmerhuizen@yahoo.com
268 * + Allows case insensitivity when sorting folders
269 * + Takes care of the delimiter being sorted to the end, causing
270 * subfolders to be listed in below folders that are prefixed
271 * with their parent folders name.
272 * For example: INBOX.foo, INBOX.foobar, and INBOX.foo.bar
273 * Without special sort function: foobar between foo and foo.bar
274 * With special sort function: foobar AFTER foo and foo.bar :)
43b698c7 275 */
a3439b27 276function user_strcasecmp($a, $b) {
277 global $delimiter;
278
279 /* Calculate the length of some strings. */
280 $a_length = strlen($a);
281 $b_length = strlen($b);
282 $min_length = min($a_length, $b_length);
283 $delimiter_length = strlen($delimiter);
284
285 /* Set the initial result value. */
286 $result = 0;
287
288 /* Check the strings... */
289 for ($c = 0; $c < $min_length; ++$c) {
290 $a_del = substr($a, $c, $delimiter_length);
291 $b_del = substr($b, $c, $delimiter_length);
292
293 if (($a_del == $delimiter) && ($b_del == $delimiter)) {
294 $result = 0;
295 } else if (($a_del == $delimiter) && ($b_del != $delimiter)) {
a3439b27 296 $result = -1;
c64c33f4 297 } else if (($a_del != $delimiter) && ($b_del == $delimiter)) {
298 $result = 1;
a3439b27 299 } else {
300 $result = strcasecmp($a{$c}, $b{$c});
301 }
302
303 if ($result != 0) {
304 break;
305 }
306 }
307
308 /* If one string is a prefix of the other... */
309 if ($result == 0) {
310 if ($a_length < $b_length) {
311 $result = -1;
312 } else if ($a_length > $b_length) {
313 $result = 1;
314 }
315 }
316
317 return ($result);
43b698c7 318}
319
320
321/******************************************************************************
322 ** Returns sorted mailbox lists in several different ways.
323 ** See comment on sqimap_mailbox_parse() for info about the returned array.
324 ******************************************************************************/
a3439b27 325function sqimap_mailbox_list ($imap_stream) {
43b698c7 326 global $data_dir, $username, $list_special_folders_first;
327 global $folder_prefix, $trash_folder, $sent_folder, $draft_folder;
328 global $move_to_trash, $move_to_sent, $save_as_draft;
329 global $delimiter;
330
331 $inbox_in_list = false;
332 $inbox_subscribed = false;
333
334 require_once('../src/load_prefs.php');
335 require_once('../functions/array.php');
336
337 /** LSUB array **/
338 fputs ($imap_stream, sqimap_session_id() .
339 " LSUB \"$folder_prefix\" \"*\"\r\n");
340 $lsub_ary = sqimap_read_data ($imap_stream, sqimap_session_id(),
341 true, $response, $message);
342
343 /* Section about removing the last element was removed */
344 /* We don't return "* OK" anymore from sqimap_read_data */
345
346 $sorted_lsub_ary = array();
347 for ($i=0;$i < count($lsub_ary); $i++) {
348 /* Workaround for EIMS */
349 /* Doesn't work if the mailbox name is multiple lines */
350 if (isset($lsub_ary[$i + 1]) &&
351 ereg("^(\\* [A-Z]+.*)\\{[0-9]+\\}([ \n\r\t]*)$",
352 $lsub_ary[$i], $regs)) {
353 $i ++;
354 $lsub_ary[$i] = $regs[1] . '"' . addslashes(trim($lsub_ary[$i])) .
355 '"' . $regs[2];
356 }
357 $temp_mailbox_name = find_mailbox_name($lsub_ary[$i]);
358 $sorted_lsub_ary[] = $temp_mailbox_name;
359 if (strtoupper($temp_mailbox_name) == 'INBOX') {
8e9e8afa 360 $inbox_subscribed = true;
43b698c7 361 }
362 }
363 $new_ary = array();
364 for ($i=0; $i < count($sorted_lsub_ary); $i++) {
365 if (!in_array($sorted_lsub_ary[$i], $new_ary)) {
ee62ce13 366 $new_ary[] = $sorted_lsub_ary[$i];
43b698c7 367 }
368 }
369 $sorted_lsub_ary = $new_ary;
370 if (isset($sorted_lsub_ary)) {
371 usort($sorted_lsub_ary, 'user_strcasecmp');
43b698c7 372 }
373
374 /** LIST array **/
375 $sorted_list_ary = array();
376 for ($i=0; $i < count($sorted_lsub_ary); $i++) {
377 if (substr($sorted_lsub_ary[$i], -1) == $delimiter) {
f9b3e5d9 378 $mbx = substr($sorted_lsub_ary[$i], 0, strlen($sorted_lsub_ary[$i])-1);
43b698c7 379 }
380 else {
f9b3e5d9 381 $mbx = $sorted_lsub_ary[$i];
43b698c7 382 }
383
384 fputs ($imap_stream, sqimap_session_id() . " LIST \"\" \"$mbx\"\r\n");
0cfd745a 385 $read = sqimap_read_data ($imap_stream, sqimap_session_id(),
386 true, $response, $message);
43b698c7 387 /* Another workaround for EIMS */
388 if (isset($read[1]) &&
389 ereg("^(\\* [A-Z]+.*)\\{[0-9]+\\}([ \n\r\t]*)$",
390 $read[0], $regs)) {
391 $read[0] = $regs[1] . '"' . addslashes(trim($read[1])) .
392 '"' . $regs[2];
393 }
394
395 if (isset($sorted_list_ary[$i])) {
a7ea7540 396 $sorted_list_ary[$i] = "";
43b698c7 397 }
398
399 if (isset($read[0])) {
44a3ca20 400 $sorted_list_ary[$i] = $read[0];
43b698c7 401 }
402 else {
44a3ca20 403 $sorted_list_ary[$i] = "";
43b698c7 404 }
405
406 if (isset($sorted_list_ary[$i]) &&
407 strtoupper(find_mailbox_name($sorted_list_ary[$i])) == "INBOX") {
3cb866d7 408 $inbox_in_list = true;
43b698c7 409 }
410 }
411
412 /**
413 * Just in case they're not subscribed to their inbox,
414 * we'll get it for them anyway
415 */
416 if ($inbox_subscribed == false || $inbox_in_list == false) {
417 fputs ($imap_stream, sqimap_session_id() . " LIST \"\" \"INBOX\"\r\n");
418 $inbox_ary = sqimap_read_data ($imap_stream, sqimap_session_id(),
419 true, $response, $message);
420 /* Another workaround for EIMS */
421 if (isset($inbox_ary[1]) &&
422 ereg("^(\\* [A-Z]+.*)\\{[0-9]+\\}([ \n\r\t]*)$",
423 $inbox_ary[0], $regs)) {
424 $inbox_ary[0] = $regs[1] . '"' . addslashes(trim($inbox_ary[1])) .
425 '"' . $regs[2];
426 }
427
428 $sorted_list_ary[] = $inbox_ary[0];
429 $sorted_lsub_ary[] = find_mailbox_name($inbox_ary[0]);
430 }
431
432 $boxes = sqimap_mailbox_parse ($sorted_list_ary, $sorted_lsub_ary);
433
434 /** Now, lets sort for special folders **/
435 $boxesnew = Array();
436
437 /* Find INBOX */
438 for ($i = 0; $i < count($boxes); $i++) {
439 if (strtolower($boxes[$i]["unformatted"]) == "inbox") {
5bdd7223 440 $boxesnew[] = $boxes[$i];
283db905 441 $used[$i] = true;
2752bb16 442 $i = count($boxes);
43b698c7 443 }
444 }
445
446 /* List special folders and their subfolders, if requested. */
447 if ($list_special_folders_first == true) {
448 /* First list the trash folder. */
449 for ($i = 0 ; $i < count($boxes) ; $i++) {
23ed73eb 450 if ($move_to_trash &&
43b698c7 451 eregi('^' . quotemeta($trash_folder) . '(' .
452 quotemeta($delimiter) . '.*)?$', $boxes[$i]['unformatted'])) {
453 $boxesnew[] = $boxes[$i];
454 $used[$i] = true;
1e0628fb 455 }
43b698c7 456 }
457
458 /* Then list the sent folder. */
459 for ($i = 0 ; $i < count($boxes) ; $i++) {
f7b1b3b1 460 if ($move_to_sent &&
43b698c7 461 eregi('^' . quotemeta($sent_folder) . '(' .
462 quotemeta($delimiter) . '.*)?$', $boxes[$i]['unformatted'])) {
463 $boxesnew[] = $boxes[$i];
464 $used[$i] = true;
8e9e8afa 465 }
43b698c7 466 }
467
468 /* Lastly, list the list the draft folder. */
469 for ($i = 0 ; $i < count($boxes) ; $i++) {
f7b1b3b1 470 if ($save_as_draft &&
43b698c7 471 eregi('^' . quotemeta($draft_folder) . '(' .
472 quotemeta($delimiter) . '.*)?$', $boxes[$i]['unformatted'])) {
473 $boxesnew[] = $boxes[$i];
474 $used[$i] = true;
f7b1b3b1 475 }
43b698c7 476 }
477
478 /* Put INBOX.* folders ahead of the rest. */
479 for ($i = 0; $i < count($boxes); $i++) {
146e0c45 480 if (eregi('^inbox\\.', $boxes[$i]["unformatted"]) &&
283db905 481 (!isset($used[$i]) || $used[$i] == false)) {
43b698c7 482 $boxesnew[] = $boxes[$i];
483 $used[$i] = true;
2752bb16 484 }
43b698c7 485 }
486 }
487
488 /* Rest of the folders */
489 for ($i = 0; $i < count($boxes); $i++) {
490 if ((strtolower($boxes[$i]["unformatted"]) != "inbox") &&
491 (!isset($used[$i]) || $used[$i] == false)) {
5bdd7223 492 $boxesnew[] = $boxes[$i];
283db905 493 $used[$i] = true;
43b698c7 494 }
495 }
496
497 return $boxesnew;
498}
499
500/******************************************************************************
501 ** Returns a list of all folders, subscribed or not
502 ******************************************************************************/
503function sqimap_mailbox_list_all ($imap_stream)
504{
505 global $list_special_folders_first, $folder_prefix;
506 global $delimiter;
507
508 if (!function_exists ("ary_sort")) {
509 include_once('../functions/array.php');
510 }
511
512 $ssid = sqimap_session_id();
513 $lsid = strlen( $ssid );
514 fputs ($imap_stream, $ssid . " LIST \"$folder_prefix\" *\r\n");
515 $read_ary = sqimap_read_data ($imap_stream, $ssid, true, $response, $message);
516 $g = 0;
517 $phase = "inbox";
518
519 for ($i = 0; $i < count($read_ary); $i++) {
520 /* Another workaround for EIMS */
521 if (isset($read_ary[$i + 1]) &&
522 ereg("^(\\* [A-Z]+.*)\\{[0-9]+\\}([ \n\r\t]*)$",
523 $read_ary[$i], $regs)) {
524 $i ++;
525 $read_ary[$i] = $regs[1] . '"' .
1c52ba77 526 addslashes(trim($read_ary[$i])) .
527 '"' . $regs[2];
43b698c7 528 }
529 if (substr ($read_ary[$i], 0, $lsid) != $ssid ) {
530
531 /* Store the raw IMAP reply */
8e9e8afa 532 $boxes[$g]["raw"] = $read_ary[$i];
1c52ba77 533
43b698c7 534 /* Count number of delimiters ($delimiter) in folder name */
8e9e8afa 535 $mailbox = find_mailbox_name($read_ary[$i]);
602e1431 536 $dm_count = substr_count($mailbox, $delimiter);
43b698c7 537 if (substr($mailbox, -1) == $delimiter) {
0cfd745a 538 /* If name ends in delimiter - decrement count by one */
539 $dm_count--;
43b698c7 540 }
2752bb16 541
43b698c7 542 /* Format folder name, but only if it's a INBOX.* or have */
543 /* a parent. */
2752bb16 544 $boxesbyname[$mailbox] = $g;
525b7ae6 545 $parentfolder = readMailboxParent($mailbox, $delimiter);
546 if((eregi('^inbox'.quotemeta($delimiter), $mailbox)) ||
146e0c45 547 (ereg('^'.$folder_prefix, $mailbox)) ||
2752bb16 548 ( isset($boxesbyname[$parentfolder]) && (strlen($parentfolder) > 0) ) ) {
43b698c7 549 if ($dm_count) {
550 $boxes[$g]["formatted"] = str_repeat("&nbsp;&nbsp;", $dm_count);
551 }
552 else {
553 $boxes[$g]["formatted"] = '';
554 }
555 $boxes[$g]["formatted"] .= readShortMailboxName($mailbox, $delimiter);
2752bb16 556 }
43b698c7 557 else {
558 $boxes[$g]["formatted"] = $mailbox;
559 }
560
8e9e8afa 561 $boxes[$g]["unformatted-dm"] = $mailbox;
43b698c7 562 if (substr($mailbox, -1) == $delimiter) {
563 $mailbox = substr($mailbox, 0, strlen($mailbox) - 1);
564 }
8e9e8afa 565 $boxes[$g]["unformatted"] = $mailbox;
0cfd745a 566 $boxes[$g]["unformatted-disp"] =
567 ereg_replace('^' . $folder_prefix, '', $mailbox);
8e9e8afa 568 $boxes[$g]["id"] = $g;
43b698c7 569
8e9e8afa 570 /** Now lets get the flags for this mailbox **/
0cfd745a 571 fputs ($imap_stream, sqimap_session_id() . " LIST \"\" \"$mailbox\"\r\n");
572 $read_mlbx = sqimap_read_data ($imap_stream, sqimap_session_id(),
573 true, $response, $message);
180aa6d7 574
43b698c7 575 /* Another workaround for EIMS */
576 if (isset($read_mlbx[1]) &&
577 ereg("^(\\* [A-Z]+.*)\\{[0-9]+\\}([ \n\r\t]*)$",
578 $read_mlbx[0], $regs)) {
1c52ba77 579 $read_mlbx[0] = $regs[1] . '"' .
580 addslashes(trim($read_mlbx[1])) .
581 '"' . $regs[2];
43b698c7 582 }
583
8e9e8afa 584 $flags = substr($read_mlbx[0], strpos($read_mlbx[0], "(")+1);
585 $flags = substr($flags, 0, strpos($flags, ")"));
146e0c45 586 $flags = str_replace('\\', '', $flags);
8e9e8afa 587 $flags = trim(strtolower($flags));
588 if ($flags) {
1c52ba77 589 $boxes[$g]['flags'] = explode(' ', $flags);
8e9e8afa 590 }
43b698c7 591 else {
592 $boxes[$g]['flags'] = array();
12d61439 593 }
43b698c7 594 }
595 $g++;
596 }
597 if(is_array($boxes)) {
1c52ba77 598 $boxes = ary_sort ($boxes, 'unformatted', 1);
43b698c7 599 }
600
601 return $boxes;
602}
5bdd7223 603
f7b1b3b1 604?>