59177427 |
1 | <?php |
895905c0 |
2 | |
35586184 |
3 | /** |
4 | * folders_create.php |
5 | * |
82d304a0 |
6 | * Copyright (c) 1999-2004 The SquirrelMail Project Team |
35586184 |
7 | * Licensed under the GNU GPL. For full terms see the file COPYING. |
8 | * |
9 | * Creates folders on the IMAP server. |
10 | * Called from folders.php |
11 | * |
30967a1e |
12 | * @version $Id$ |
8f6f9ba5 |
13 | * @package squirrelmail |
35586184 |
14 | */ |
ef870322 |
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'); |
26 | require_once(SM_PATH . 'functions/display_messages.php'); |
d3cdb279 |
27 | |
a32985a5 |
28 | /* get globals we may need */ |
1e12d1ff |
29 | sqgetGlobalVar('key', $key, SQ_COOKIE); |
30 | sqgetGlobalVar('username', $username, SQ_SESSION); |
31 | sqgetGlobalVar('onetimepad', $onetimepad, SQ_SESSION); |
32 | sqgetGlobalVar('delimiter', $delimiter, SQ_SESSION); |
33 | sqgetGlobalVar('folder_name', $folder_name, SQ_POST); |
34 | sqgetGlobalVar('subfolder', $subfolder, SQ_POST); |
35 | sqgetGlobalVar('contain_subs', $contain_subs, SQ_POST); |
a32985a5 |
36 | /* end of get globals */ |
37 | |
c6ee68f5 |
38 | $folder_name = trim($folder_name); |
39 | |
b7f83b61 |
40 | if (substr_count($folder_name, '"') || substr_count($folder_name, "\\") || |
41 | substr_count($folder_name, $delimiter) || ($folder_name == '')) { |
0037f048 |
42 | displayPageHeader($color, 'None'); |
3d3afeeb |
43 | |
99aaff8b |
44 | plain_error_message(_("Illegal folder name. Please select a different name."). |
b7f83b61 |
45 | '<BR><A HREF="../src/folders.php">'._("Click here to go back").'</A>.', $color); |
46 | |
1c52ba77 |
47 | exit; |
48 | } |
49 | |
e429f014 |
50 | $folder_name = imap_utf7_encode_local($folder_name); |
68f2ce7a |
51 | |
1c52ba77 |
52 | if (isset($contain_subs) && $contain_subs ) { |
b7f83b61 |
53 | $folder_name = $folder_name . $delimiter; |
1c52ba77 |
54 | } |
55 | |
56 | if ($folder_prefix && (substr($folder_prefix, -1) != $delimiter)) { |
57 | $folder_prefix = $folder_prefix . $delimiter; |
58 | } |
59 | if ($folder_prefix && (substr($subfolder, 0, strlen($folder_prefix)) != $folder_prefix)){ |
60 | $subfolder_orig = $subfolder; |
61 | $subfolder = $folder_prefix . $subfolder; |
62 | } else { |
63 | $subfolder_orig = $subfolder; |
64 | } |
65 | |
b7f83b61 |
66 | $imapConnection = sqimap_login($username, $key, $imapServerAddress, $imapPort, 0); |
67 | |
1c52ba77 |
68 | if (trim($subfolder_orig) == '') { |
69 | sqimap_mailbox_create ($imapConnection, $folder_prefix.$folder_name, ''); |
70 | } else { |
71 | sqimap_mailbox_create ($imapConnection, $subfolder.$delimiter.$folder_name, ''); |
72 | } |
73 | |
b7f83b61 |
74 | sqimap_logout($imapConnection); |
75 | |
1c52ba77 |
76 | $location = get_location(); |
77 | header ("Location: $location/folders.php?success=create"); |
b7f83b61 |
78 | |
525b7ae6 |
79 | ?> |