3de6307345f37f1797f5fcceee19911da5d857c8
[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 include("../functions/array.php");
9
10 $imapConnection = loginToImapServer($username, $key, $imapServerAddress);
11
12 getFolderList($imapConnection, $boxes);
13
14 $mailbox = $trash_folder;
15 fputs($imapConnection, "1 LIST \"$mailbox\" *\n");
16 $data = imapReadData($imapConnection , "1", false, $response, $message);
17 while (substr($data[0], strpos($data[0], " ")+1, 4) == "LIST") {
18 for ($i = 0; $i < count($boxes); $i++) {
19 if (($boxes[$i]["UNFORMATTED"] == $mailbox) ||
20 (substr($boxes[$i]["UNFORMATTED"], 0, strlen($mailbox . $dm)) == $mailbox . $dm)) {
21 removeFolder($imapConnection, $boxes[$i]["UNFORMATTED"]);
22 }
23 }
24 fputs($imapConnection, "1 LIST \"$mailbox\" *\n");
25 $data = imapReadData($imapConnection , "1", false, $response, $message);
26 }
27
28 createFolder($imapConnection, "$trash_folder", "");
29
30 selectMailbox($imapConnection, $trash_folder, $numMessages);
31 echo "<HTML><BODY TEXT=\"$color[8]\" BGCOLOR=\"$color[4]\" LINK=\"$color[7]\" VLINK=\"$color[7]\" ALINK=\"$color[7]\">\n";
32 displayPageHeader($color, $mailbox);
33 messages_deleted_message($trash_folder, $sort, $startMessage, $color);
34 fputs($imapConnection, "1 logout");
35 ?>