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"); |
b40316f9 |
7 | |
2aa12d5e |
8 | $imapConnection = loginToImapServer($username, $key, $imapServerAddress); |
8c7dfc99 |
9 | selectMailbox($imapConnection, $mailbox, $numMessages); |
54e3c1d8 |
10 | getFolderList($imapConnection, $boxesFormatted, $boxesUnformatted); |
11 | |
12 | /** Lets start removing the folders and messages **/ |
13 | if ($move_to_trash == true) { /** if they wish to move messages to the trash **/ |
14 | /** Creates the subfolders under $trash_folder **/ |
15 | for ($i = 0; $i < count($boxesUnformatted); $i++) { |
16 | if (substr($boxesUnformatted[$i], 0, strlen($mailbox)) == $mailbox) { |
17 | $folderWithoutINBOX = getFolderNameMinusINBOX($boxesUnformatted[$i]); |
18 | createFolder($imapConnection, "$trash_folder.$folderWithoutINBOX"); |
19 | } |
20 | } |
21 | for ($i = 0; $i < count($boxesUnformatted); $i++) { |
22 | if (substr($boxesUnformatted[$i], 0, strlen($mailbox)) == $mailbox) { |
23 | selectMailbox($imapConnection, $boxesUnformatted[$i], $numMessages); |
24 | $folder = getFolderNameMinusINBOX($boxesUnformatted[$i]); |
25 | |
26 | if ($numMessages > 0) |
27 | $success = copyMessages($imapConnection, 1, $numMessages, "$trash_folder.$folder"); |
28 | else |
29 | $success = true; |
30 | |
31 | if ($success == true) |
32 | removeFolder($imapConnection, "$boxesUnformatted[$i]"); |
33 | } |
34 | } |
35 | } else { /** if they do NOT wish to move messages to the trash **/ |
36 | for ($i = 0; $i < count($boxesUnformatted); $i++) { |
37 | if (substr($boxesUnformatted[$i], 0, strlen($mailbox)) == $mailbox) { |
38 | removeFolder($imapConnection, "$boxesUnformatted[$i]"); |
39 | } |
40 | } |
8c7dfc99 |
41 | } |
b40316f9 |
42 | |
54e3c1d8 |
43 | /** Log out this session **/ |
8c7dfc99 |
44 | fputs($imapConnection, "1 logout"); |
b40316f9 |
45 | |
f8f9bed9 |
46 | echo "<HTML><BODY TEXT=\"$color[8]\" BGCOLOR=\"$color[4]\" LINK=\"$color[7]\" VLINK=\"$color[7]\" ALINK=\"$color[7]\">\n"; |
907165ca |
47 | echo "<BR><BR><A HREF=\"webmail.php?right_frame=folders.php\" TARGET=_top>Return</A>"; |
f8f9bed9 |
48 | echo "</BODY></HTML>"; |
b40316f9 |
49 | ?> |
50 | |
51 | |