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