be69e508 |
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); |
d92b6f31 |
9 | $dm = findMailboxDelimeter($imapConnection); |
10 | |
11 | if (strpos($orig, $dm)) |
12 | $old_dir = substr($orig, 0, strrpos($orig, $dm)); |
13 | else |
14 | $old_dir = ""; |
15 | |
16 | if ($old_dir != "") |
17 | $newone = "$old_dir$dm$new_name"; |
18 | else |
19 | $newone = "$new_name"; |
20 | |
21 | fputs ($imapConnection, ". RENAME \"$orig\" \"$newone\"\n"); |
22 | $data = imapReadData($imapConnection, ".", true, $a, $b); |
23 | |
24 | /* fputs ($imapConnection, ". RENAME \"$old_name\" \"$mailbox\"\n"; |
25 | |
be69e508 |
26 | selectMailbox($imapConnection, $orig, $numMessages); |
d92b6f31 |
27 | getFolderList($imapConnection, $boxesFormatted, $boxesUnformatted, $boxesRaw); |
be69e508 |
28 | |
29 | $mailbox = "$subfolder.$new_name"; |
30 | $old_name = substr($orig, strrpos($orig, ".")+1, strlen($orig)); |
31 | $old_parent = substr($orig, 0, strrpos($orig, ".")); |
32 | |
33 | for ($i = 0; $i < count($boxesUnformatted); $i++) { |
34 | if (substr($boxesUnformatted[$i], 0, strlen($orig)) == $orig) { |
35 | $after = substr($boxesUnformatted[$i], strlen($orig)+1, strlen($boxesUnformatted[$i])); |
36 | selectMailbox($imapConnection, $boxesUnformatted[$i], $numMessages); |
37 | if (strlen($after) > 0) { |
38 | createFolder($imapConnection, "$mailbox.$after"); |
39 | if ($numMessages > 0) |
40 | $success = copyMessages($imapConnection, 1, $numMessages, "$mailbox.$after"); |
41 | else |
42 | $success = true; |
43 | |
44 | if ($success == true) |
45 | removeFolder($imapConnection, "$boxesUnformatted[$i]"); |
46 | } |
47 | else { |
48 | createFolder($imapConnection, "$mailbox"); |
49 | if ($numMessages > 0) |
50 | $success = copyMessages($imapConnection, 1, $numMessages, "$mailbox"); |
51 | else |
52 | $success = true; |
53 | |
54 | if ($success == true) |
55 | removeFolder($imapConnection, "$boxesUnformatted[$i]"); |
56 | } |
57 | } |
58 | } |
d92b6f31 |
59 | */ |
be69e508 |
60 | /** Log out this session **/ |
61 | fputs($imapConnection, "1 logout"); |
62 | |
f8f9bed9 |
63 | echo "<HTML><BODY TEXT=\"$color[8]\" BGCOLOR=\"$color[4]\" LINK=\"$color[7]\" VLINK=\"$color[7]\" ALINK=\"$color[7]\">\n"; |
be69e508 |
64 | echo "<BR><BR><A HREF=\"webmail.php?right_frame=folders.php\" TARGET=_top>Return</A>"; |
f8f9bed9 |
65 | echo "</BODY></HTML>"; |
be69e508 |
66 | ?> |
67 | |
68 | |