59177427 |
1 | <?php |
895905c0 |
2 | |
35586184 |
3 | /** |
4 | * folders_rename_do.php |
5 | * |
6c84ba1e |
6 | * Copyright (c) 1999-2005 The SquirrelMail Project Team |
35586184 |
7 | * Licensed under the GNU GPL. For full terms see the file COPYING. |
8 | * |
1c52ba77 |
9 | * Does the actual renaming of files on the IMAP server. |
35586184 |
10 | * Called from the folders.php |
11 | * |
30967a1e |
12 | * @version $Id$ |
8f6f9ba5 |
13 | * @package squirrelmail |
35586184 |
14 | */ |
15 | |
30967a1e |
16 | /** |
17 | * Path for SquirrelMail required files. |
18 | * @ignore |
19 | */ |
86725763 |
20 | define('SM_PATH','../'); |
21 | |
22 | /* SquirrelMail required files. */ |
08185f2a |
23 | require_once(SM_PATH . 'include/validate.php'); |
8650e9e1 |
24 | require_once(SM_PATH . 'functions/global.php'); |
86725763 |
25 | require_once(SM_PATH . 'functions/imap.php'); |
b7f83b61 |
26 | require_once(SM_PATH . 'functions/display_messages.php'); |
5bdd7223 |
27 | |
a32985a5 |
28 | /* globals */ |
1e12d1ff |
29 | sqgetGlobalVar('key', $key, SQ_COOKIE); |
30 | sqgetGlobalVar('username', $username, SQ_SESSION); |
31 | sqgetGlobalVar('delimiter', $delimiter, SQ_SESSION); |
32 | sqgetGlobalVar('onetimepad',$onetimepad, SQ_SESSION); |
33 | sqgetGlobalVar('orig', $orig, SQ_POST); |
34 | sqgetGlobalVar('old_name', $old_name, SQ_POST); |
35 | sqgetGlobalVar('new_name', $new_name, SQ_POST); |
a32985a5 |
36 | /* end globals */ |
08185f2a |
37 | |
c6ee68f5 |
38 | $new_name = trim($new_name); |
39 | |
b7f83b61 |
40 | if (substr_count($new_name, '"') || substr_count($new_name, "\\") || |
41 | substr_count($new_name, $delimiter) || ($new_name == '')) { |
42 | displayPageHeader($color, 'None'); |
43 | |
99aaff8b |
44 | plain_error_message(_("Illegal folder name. Please select a different name."). |
ff0969a0 |
45 | '<br /><a href="../src/folders.php">'._("Click here to go back").'</a>.', $color); |
b7f83b61 |
46 | |
47 | exit; |
48 | } |
49 | |
e429f014 |
50 | $orig = imap_utf7_encode_local($orig); |
51 | $old_name = imap_utf7_encode_local($old_name); |
52 | $new_name = imap_utf7_encode_local($new_name); |
53 | |
1c52ba77 |
54 | if ($old_name <> $new_name) { |
5bdd7223 |
55 | |
1c52ba77 |
56 | $imapConnection = sqimap_login($username, $key, $imapServerAddress, $imapPort, 0); |
ef870322 |
57 | |
1c52ba77 |
58 | if (strpos($orig, $delimiter)) { |
59 | $old_dir = substr($orig, 0, strrpos($orig, $delimiter)); |
60 | } else { |
61 | $old_dir = ''; |
62 | } |
d92b6f31 |
63 | |
1c52ba77 |
64 | if ($old_dir != '') { |
65 | $newone = $old_dir . $delimiter . $new_name; |
66 | } else { |
67 | $newone = $new_name; |
68 | } |
d92b6f31 |
69 | |
b7f83b61 |
70 | // Renaming a folder doesn't rename the folder but leaves you unsubscribed |
1c52ba77 |
71 | // at least on Cyrus IMAP servers. |
72 | if (isset($isfolder)) { |
73 | $newone = $newone.$delimiter; |
74 | $orig = $orig.$delimiter; |
75 | } |
76 | sqimap_mailbox_rename( $imapConnection, $orig, $newone ); |
d92b6f31 |
77 | |
91e0dccc |
78 | // Log out this session |
1c52ba77 |
79 | sqimap_logout($imapConnection); |
d92b6f31 |
80 | |
1c52ba77 |
81 | } |
b7f83b61 |
82 | |
83 | header ('Location: ' . get_location() . '/folders.php?success=rename'); |
84 | |
ff0969a0 |
85 | ?> |