Fixed a minor bug with slashes before quotes
[squirrelmail.git] / src / move_messages.php
1 <HTML><BODY TEXT="#000000" BGCOLOR="#FFFFFF" LINK="#0000EE" VLINK="#0000EE" ALINK="#0000EE">
2 <?
3 include("../config/config.php");
4 include("../functions/mailbox.php");
5 include("../functions/strings.php");
6 include("../functions/page_header.php");
7 include("../functions/display_messages.php");
8 include("../functions/imap.php");
9
10 $imapConnection = loginToImapServer($username, $key, $imapServerAddress);
11
12 // switch to the mailbox, and get the number of messages in it.
13 selectMailbox($imapConnection, $mailbox, $numMessages, $imapServerAddress);
14
15 if (strtolower($move_or_delete) == "delete selected messages") {
16 // Marks the selected messages ad 'Deleted'
17 $j = 0;
18 $i = 0;
19
20 // If they have selected nothing msg is size one still, but will be an infinite
21 // loop because we never increment j. so check to see if msg[0] is set or not to fix this.
22 while (($j < count($msg)) && ($msg[0])) {
23 if ($msg[$i]) {
24 /** check if they would like to move it to the trash folder or not */
25 if ($move_to_trash == true) {
26 $success = copyMessages($imapConnection, $msg[$i], $msg[$i], $trash_folder);
27 if ($success == true)
28 setMessageFlag($imapConnection, $msg[$i], $msg[$i], "Deleted");
29 } else {
30 setMessageFlag($imapConnection, $msg[$i], "Deleted");
31 }
32 $j++;
33 }
34 $i++;
35 }
36 if ($auto_expunge == true)
37 expungeBox($imapConnection, $mailbox, $numMessages);
38 displayPageHeader($mailbox);
39 messages_deleted_message($mailbox, $sort, $startMessage);
40 } else {
41 $j = 0;
42 $i = 0;
43
44 // If they have selected nothing msg is size one still, but will be an infinite
45 // loop because we never increment j. so check to see if msg[0] is set or not to fix this.
46 while (($j < count($msg)) && ($msg[0])) {
47 if ($msg[$i]) {
48 $success = copyMessages($imapConnection, $msg[$i], $msg[$i], $trash_folder);
49 if ($success == true) {
50 setMessageFlag($imapConnection, $msg[$i], $msg[$i], "Deleted");
51 displayPageHeader($mailbox);
52 }
53 if ($auto_expunge == true)
54 expungeBox($imapConnection, $mailbox, $numMessages);
55 $j++;
56 }
57 $i++;
58 }
59 }
60
61 // Log out this session
62 fputs($imapConnection, "1 logout");
63
64 ?>
65 </BODY></HTML>