move_messages.php 3.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  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. function putSelectedMessagesIntoString($msg) {
  10. $j = 0;
  11. $i = 0;
  12. $firstLoop = true;
  13. // If they have selected nothing msg is size one still, but will be an infinite
  14. // loop because we never increment j. so check to see if msg[0] is set or not to fix this.
  15. while (($j < count($msg)) && ($msg[0])) {
  16. if ($msg[$i]) {
  17. if ($firstLoop != true)
  18. $selectedMessages .= "&";
  19. else
  20. $firstLoop = false;
  21. $selectedMessages .= "selMsg[$j]=$msg[$i]";
  22. $j++;
  23. }
  24. $i++;
  25. }
  26. }
  27. $imapConnection = loginToImapServer($username, $key, $imapServerAddress);
  28. // switch to the mailbox, and get the number of messages in it.
  29. selectMailbox($imapConnection, $mailbox, $numMessages, $imapServerAddress);
  30. // If the delete button was pressed, the moveButton variable will not be set.
  31. if (!$moveButton) {
  32. displayPageHeader($mailbox);
  33. if (is_array($msg) == 1) {
  34. // Marks the selected messages ad 'Deleted'
  35. $j = 0;
  36. $i = 0;
  37. // If they have selected nothing msg is size one still, but will be an infinite
  38. // loop because we never increment j. so check to see if msg[0] is set or not to fix this.
  39. while ($j < count($msg)) {
  40. if ($msg[$i]) {
  41. echo "MSG: $msg[$i]<BR>";
  42. deleteMessages($imapConnection, $msg[$i], $msg[$i], $numMessages, $trash_folder, $move_to_trash, $auto_expunge, $mailbox);
  43. $j++;
  44. }
  45. $i++;
  46. }
  47. messages_deleted_message($mailbox, $sort, $startMessage);
  48. } else {
  49. echo "<BR><BR><CENTER>No messages selected.</CENTER>";
  50. }
  51. } else { // Move messages
  52. displayPageHeader($mailbox);
  53. // lets check to see if they selected any messages
  54. if (is_array($msg) == 1) {
  55. $j = 0;
  56. $i = 0;
  57. // If they have selected nothing msg is size one still, but will be an infinite
  58. // loop because we never increment j. so check to see if msg[0] is set or not to fix this.
  59. while ($j < count($msg)) {
  60. if ($msg[$i]) {
  61. /** check if they would like to move it to the trash folder or not */
  62. $success = copyMessages($imapConnection, $msg[$i], $msg[$i], $targetMailbox);
  63. if ($success == true)
  64. setMessageFlag($imapConnection, $msg[$i], $msg[$i], "Deleted");
  65. $j++;
  66. }
  67. $i++;
  68. }
  69. if ($auto_expunge == true)
  70. expungeBox($imapConnection, $mailbox, $numMessages);
  71. messages_moved_message($mailbox, $sort, $startMessage);
  72. } else {
  73. error_message("No messages were selected.", $mailbox, $sort, $startMessage);
  74. }
  75. }
  76. // Log out this session
  77. fputs($imapConnection, "1 logout");
  78. ?>
  79. </BODY></HTML>