changed <? to <?php in everything
[squirrelmail.git] / src / empty_trash.php
CommitLineData
59177427 1<?php
2a32fc83 2 session_start();
3
7a783442 4 include("../config/config.php");
7a783442 5 include("../functions/strings.php");
6 include("../functions/page_header.php");
7 include("../functions/display_messages.php");
2aa12d5e 8 include("../functions/imap.php");
7ce342dc 9 include("../functions/array.php");
7a783442 10
97dd6a62 11 if (!isset($tree_php))
12 include("../functions/tree.php");
13
d3cdb279 14 include("../src/load_prefs.php");
15
e1469126 16 $imap_stream = sqimap_login($username, $key, $imapServerAddress, $imapPort, 0);
7a783442 17
97dd6a62 18 sqimap_mailbox_list($imap_stream, $boxes);
d92b6f31 19
20 $mailbox = $trash_folder;
97dd6a62 21 $boxes = sqimap_mailbox_list($imap_stream);
22 $dm = sqimap_get_delimiter($imap_stream);
7cad6205 23
0a1d5f3a 24 // According to RFC2060, a DELETE command should NOT remove inferiors (sub folders)
25 // so lets go through the list of subfolders and remove them before removing the
26 // parent.
0a1d5f3a 27
97dd6a62 28 /** First create the top node in the tree **/
29 for ($i = 0;$i < count($boxes);$i++) {
30 if (($boxes[$i]["unformatted"] == $mailbox) && (strlen($boxes[$i]["unformatted"]) == strlen($mailbox))) {
31 $foldersTree[0]["value"] = $mailbox;
32 $foldersTree[0]["doIHaveChildren"] = false;
33 continue;
34 }
35 }
36 // Now create the nodes for subfolders of the parent folder
37 // You can tell that it is a subfolder by tacking the mailbox delimiter
38 // on the end of the $mailbox string, and compare to that.
39 $j = 0;
40 for ($i = 0;$i < count($boxes);$i++) {
41 if (substr($boxes[$i]["unformatted"], 0, strlen($mailbox . $dm)) == ($mailbox . $dm)) {
c5f5cd59 42 addChildNodeToTree($boxes[$i]["unformatted"], $boxes[$i]["unformatted-dm"], $foldersTree);
97dd6a62 43 }
44 }
45
46 // now lets go through the tree and delete the folders
294bf31a 47 walkTreeInPreOrderEmptyTrash(0, $imap_stream, $foldersTree);
a11899fd 48
97dd6a62 49 sqimap_mailbox_select($imap_stream, $trash_folder, $numMessages);
f8f9bed9 50 echo "<HTML><BODY TEXT=\"$color[8]\" BGCOLOR=\"$color[4]\" LINK=\"$color[7]\" VLINK=\"$color[7]\" ALINK=\"$color[7]\">\n";
51 displayPageHeader($color, $mailbox);
d92b6f31 52 messages_deleted_message($trash_folder, $sort, $startMessage, $color);
97dd6a62 53 sqimap_logout($imap_stream);
2aa12d5e 54?>