bc554d636e71037f6b36a475387775510aeb05dd
[squirrelmail.git] / src / empty_trash.php
1 <?
2 include("../config/config.php");
3 include("../functions/mailbox.php");
4 include("../functions/strings.php");
5 include("../functions/page_header.php");
6 include("../functions/display_messages.php");
7 include("../functions/imap.php");
8
9 $imapConnection = loginToImapServer($username, $key, $imapServerAddress);
10
11 // switch to the mailbox, and get the number of messages in it.
12 selectMailbox($imapConnection, $mailbox, $numMessages);
13
14 if ($mailbox != $trash_folder) {
15 echo "ERROR -- I'm not in the trash folder!<BR>";
16 exit;
17 }
18
19
20 /** GET FOLDER ARRAY OF TRASH SUBFOLDERS **/
21 fputs($imapConnection, "1 list \"\" *\n");
22 $str = imapReadData($imapConnection);
23
24 for ($i = 0;$i < count($str); $i++) {
25 $box = Chop($str[$i]);
26 $mailbox = findMailboxName($box);
27
28 if (strpos($box, $trash_folder) > 0) {
29 $folders[$i] = $mailbox;
30 } else {
31 $folders[$i] = "NOPE";
32 }
33 }
34
35 // mark them as deleted
36 setMessageFlag($imapConnection, 1, $numMessages, "Deleted");
37 expungeBox($imapConnection, $mailbox);
38
39 // remove subfolders
40 for ($i = 0; $i < count($folders); $i++) {
41 if (($folders[$i] == "NOPE") || ($folders[$i] == "$trash_folder")) {
42 } else {
43 $thisfolder = getFolderNameMinusINBOX($folders[$i]);
44 $thisfolder = "user.$username.$thisfolder";
45 removeFolder($imapConnection, $thisfolder);
46 }
47 }
48 // Log out this session
49 fputs($imapConnection, "1 logout");
50
51 echo "<HTML><BODY TEXT=\"#000000\" BGCOLOR=\"#FFFFFF\" LINK=\"#0000EE\" VLINK=\"#0000EE\" ALINK=\"#0000EE\">";
52 displayPageHeader($mailbox);
53
54 messages_deleted_message("INBOX", $sort, $startMessage);
55 ?>