b40316f9 |
1 | <? |
2 | include("../config/config.php"); |
3 | include("../functions/strings.php"); |
4 | include("../functions/page_header.php"); |
5 | include("../functions/imap.php"); |
597d8f1d |
6 | include("../functions/mailbox.php"); |
7ce342dc |
7 | include("../functions/array.php"); |
b40316f9 |
8 | |
d92b6f31 |
9 | echo "<HTML><BODY TEXT=\"$color[8]\" BGCOLOR=\"$color[4]\" LINK=\"$color[7]\" VLINK=\"$color[7]\" ALINK=\"$color[7]\">\n"; |
2aa12d5e |
10 | $imapConnection = loginToImapServer($username, $key, $imapServerAddress); |
7ce342dc |
11 | getFolderList($imapConnection, $boxes); |
d92b6f31 |
12 | |
13 | $dm = findMailboxDelimeter($imapConnection); |
14 | /** lets see if we CAN move folders to the trash.. otherwise, just delete them **/ |
7ce342dc |
15 | for ($i = 0; $i < count($boxes[$i]["UNFORMATTED"]); $i++) { |
16 | if ($boxes[$i]["UNFORMATTED"] == $trash_folder) |
17 | $tmp_trash_folder = $boxes[$i]["RAW"]; |
d92b6f31 |
18 | } |
19 | |
20 | $tmpflags = getMailboxFlags($tmp_trash_folder); |
21 | $can_move_to_trash = true; |
22 | for ($i = 0; $i < count($tmpflags); $i++) { |
23 | if (strtolower($tmpflags[$i]) == "noinferiors") |
24 | $can_move_to_trash = false; |
25 | } |
54e3c1d8 |
26 | |
27 | /** Lets start removing the folders and messages **/ |
d92b6f31 |
28 | if (($move_to_trash == true) && ($can_move_to_trash == true)) { /** if they wish to move messages to the trash **/ |
54e3c1d8 |
29 | /** Creates the subfolders under $trash_folder **/ |
7ce342dc |
30 | for ($i = 0; $i < count($boxes); $i++) { |
31 | if (($boxes[$i]["UNFORMATTED"] == $mailbox) || |
32 | (substr($boxes[$i]["UNFORMATTED"], 0, strlen($mailbox . $dm)) == $mailbox . $dm)) { |
33 | $folderWithoutINBOX = getFolderNameMinusINBOX($boxes[$i]["UNFORMATTED"], $dm); |
34 | $flags = getMailboxFlags($boxes[$i]["RAW"]); |
d92b6f31 |
35 | for ($b = 0; $b < count($flags); $b++) { |
36 | $type = $flags[$b]; |
37 | } |
38 | createFolder($imapConnection, "$trash_folder" . $dm . "$folderWithoutINBOX", $type); |
54e3c1d8 |
39 | } |
40 | } |
7ce342dc |
41 | for ($i = 0; $i < count($boxes); $i++) { |
42 | if (($boxes[$i]["UNFORMATTED"] == $mailbox) || |
43 | (substr($boxes[$i]["UNFORMATTED"], 0, strlen($mailbox . $dm)) == $mailbox . $dm)) { |
44 | selectMailbox($imapConnection, $boxes[$i]["UNFORMATTED"], $numMessages); |
45 | $folder = getFolderNameMinusINBOX($boxes[$i]["UNFORMATTED"]); |
54e3c1d8 |
46 | |
47 | if ($numMessages > 0) |
d92b6f31 |
48 | $success = copyMessages($imapConnection, 1, $numMessages, "$trash_folder" . $dm . "$folder"); |
54e3c1d8 |
49 | else |
50 | $success = true; |
51 | |
52 | if ($success == true) |
7ce342dc |
53 | removeFolder($imapConnection, $boxes[$i]["UNFORMATTED"]); |
54e3c1d8 |
54 | } |
55 | } |
d92b6f31 |
56 | } else { /** if they do NOT wish to move messages to the trash (or cannot)**/ |
57 | fputs($imapConnection, "1 LIST \"$mailbox\" *\n"); |
58 | $data = imapReadData($imapConnection , "1", false, $response, $message); |
59 | while (substr($data[0], strpos($data[0], " ")+1, 4) == "LIST") { |
7ce342dc |
60 | for ($i = 0; $i < count($boxes); $i++) { |
61 | if (($boxes[$i]["UNFORMATTED"] == $mailbox) || |
62 | (substr($boxes[$i]["UNFORMATTED"], 0, strlen($mailbox . $dm)) == $mailbox . $dm)) { |
63 | removeFolder($imapConnection, $boxes[$i]["UNFORMATTED"]); |
d92b6f31 |
64 | } |
54e3c1d8 |
65 | } |
d92b6f31 |
66 | fputs($imapConnection, "1 LIST \"$mailbox\" *\n"); |
67 | $data = imapReadData($imapConnection , "1", false, $response, $message); |
54e3c1d8 |
68 | } |
8c7dfc99 |
69 | } |
b40316f9 |
70 | |
54e3c1d8 |
71 | /** Log out this session **/ |
8c7dfc99 |
72 | fputs($imapConnection, "1 logout"); |
b40316f9 |
73 | |
907165ca |
74 | echo "<BR><BR><A HREF=\"webmail.php?right_frame=folders.php\" TARGET=_top>Return</A>"; |
f8f9bed9 |
75 | echo "</BODY></HTML>"; |
b40316f9 |
76 | ?> |
77 | |
78 | |