| 1 | <? |
| 2 | include("../config/config.php"); |
| 3 | include("../functions/strings.php"); |
| 4 | include("../functions/page_header.php"); |
| 5 | include("../functions/imap.php"); |
| 6 | include("../functions/mailbox.php"); |
| 7 | |
| 8 | $imapConnection = loginToImapServer($username, $key, $imapServerAddress); |
| 9 | selectMailbox($imapConnection, $orig, $numMessages); |
| 10 | getFolderList($imapConnection, $boxesFormatted, $boxesUnformatted); |
| 11 | |
| 12 | $mailbox = "$subfolder.$new_name"; |
| 13 | $old_name = substr($orig, strrpos($orig, ".")+1, strlen($orig)); |
| 14 | $old_parent = substr($orig, 0, strrpos($orig, ".")); |
| 15 | |
| 16 | for ($i = 0; $i < count($boxesUnformatted); $i++) { |
| 17 | if (substr($boxesUnformatted[$i], 0, strlen($orig)) == $orig) { |
| 18 | $after = substr($boxesUnformatted[$i], strlen($orig)+1, strlen($boxesUnformatted[$i])); |
| 19 | selectMailbox($imapConnection, $boxesUnformatted[$i], $numMessages); |
| 20 | if (strlen($after) > 0) { |
| 21 | createFolder($imapConnection, "$mailbox.$after"); |
| 22 | if ($numMessages > 0) |
| 23 | $success = copyMessages($imapConnection, 1, $numMessages, "$mailbox.$after"); |
| 24 | else |
| 25 | $success = true; |
| 26 | |
| 27 | if ($success == true) |
| 28 | removeFolder($imapConnection, "$boxesUnformatted[$i]"); |
| 29 | } |
| 30 | else { |
| 31 | createFolder($imapConnection, "$mailbox"); |
| 32 | if ($numMessages > 0) |
| 33 | $success = copyMessages($imapConnection, 1, $numMessages, "$mailbox"); |
| 34 | else |
| 35 | $success = true; |
| 36 | |
| 37 | if ($success == true) |
| 38 | removeFolder($imapConnection, "$boxesUnformatted[$i]"); |
| 39 | } |
| 40 | } |
| 41 | } |
| 42 | |
| 43 | /** Log out this session **/ |
| 44 | fputs($imapConnection, "1 logout"); |
| 45 | |
| 46 | echo "<HTML><BODY TEXT=\"$color[8]\" BGCOLOR=\"$color[4]\" LINK=\"$color[7]\" VLINK=\"$color[7]\" ALINK=\"$color[7]\">\n"; |
| 47 | echo "<BR><BR><A HREF=\"webmail.php?right_frame=folders.php\" TARGET=_top>Return</A>"; |
| 48 | echo "</BODY></HTML>"; |
| 49 | ?> |
| 50 | |
| 51 | |