| 1 | <? |
| 2 | include("../config/config.php"); |
| 3 | include("../functions/strings.php"); |
| 4 | include("../functions/page_header.php"); |
| 5 | include("../functions/imap.php"); |
| 6 | include("../functions/mailbox.php"); |
| 7 | |
| 8 | $imapConnection = loginToImapServer($username, $key, $imapServerAddress); |
| 9 | selectMailbox($imapConnection, $mailbox, $numMessages); |
| 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 | } |
| 41 | } |
| 42 | |
| 43 | /** Log out this session **/ |
| 44 | fputs($imapConnection, "1 logout"); |
| 45 | |
| 46 | echo "<BR><BR><A HREF=\"webmail.php?right_frame=folders.php\" TARGET=_top>Return</A>"; |
| 47 | ?> |
| 48 | |
| 49 | |