3af351a89ae6178fb72dc38689293af5dce9d1d3
[squirrelmail.git] / src / folders_delete.php
1 <?
2 include("../config/config.php");
3 include("../functions/strings.php");
4 include("../functions/page_header.php");
5 include("../functions/imap.php");
6
7 $imapConnection = fsockopen($imapServerAddress, 143, &$errorNumber, &$errorString);
8 if (!$imapConnection) {
9 echo "Error connecting to IMAP Server.<br>";
10 echo "$errorNumber : $errorString<br>";
11 exit;
12 }
13 $serverInfo = fgets($imapConnection, 256);
14
15 fputs($imapConnection, "1 login $username $key\n");
16 $read = fgets($imapConnection, 1024);
17 echo $read;
18
19 if (strpos($read, "NO")) {
20 error_username_password_incorrect();
21 exit;
22 }
23
24 // switch to the mailbox, and get the number of messages in it.
25 selectMailbox($imapConnection, $mailbox, $numMessages);
26
27 // Marks the selected messages ad 'Deleted'
28 $j = 0;
29 $i = 0;
30
31 while ($j < count($msg)) {
32 if ($msg[$i]) {
33 /** check if they would like to move it to the trash folder or not */
34 if ($move_to_trash == true) {
35 createFolder($imapConnection, "user.$username.$folder");
36 $success = copyMessages($imapConnection, $msg[$i], $msg[$i], $trash_folder);
37 if ($success == true)
38 setMessageFlag($imapConnection, $msg[$i], $msg[$i], "Deleted");
39 } else {
40 setMessageFlag($imapConnection, $msg[$i], "Deleted");
41 }
42 $j++;
43 }
44 $i++;
45 }
46
47 if ($auto_expunge == true)
48 expungeBox($imapConnection, $mailbox, $numMessages);
49
50 // Log out this session
51 fputs($imapConnection, "1 logout");
52
53 echo "<BR><BR><A HREF=\"folders.php\">Return</A>";
54 ?>
55
56