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 | * |
12 | * $Id$ |
8f6f9ba5 |
13 | * @package squirrelmail |
35586184 |
14 | */ |
ef870322 |
15 | |
8f6f9ba5 |
16 | /** Path for SquirrelMail required files. */ |
86725763 |
17 | define('SM_PATH','../'); |
18 | |
19 | /* SquirrelMail required files. */ |
08185f2a |
20 | require_once(SM_PATH . 'include/validate.php'); |
8650e9e1 |
21 | require_once(SM_PATH . 'functions/global.php'); |
86725763 |
22 | require_once(SM_PATH . 'functions/imap.php'); |
23 | require_once(SM_PATH . 'functions/display_messages.php'); |
d3cdb279 |
24 | |
a32985a5 |
25 | /* get globals we may need */ |
1e12d1ff |
26 | sqgetGlobalVar('key', $key, SQ_COOKIE); |
27 | sqgetGlobalVar('username', $username, SQ_SESSION); |
28 | sqgetGlobalVar('onetimepad', $onetimepad, SQ_SESSION); |
29 | sqgetGlobalVar('delimiter', $delimiter, SQ_SESSION); |
30 | sqgetGlobalVar('folder_name', $folder_name, SQ_POST); |
31 | sqgetGlobalVar('subfolder', $subfolder, SQ_POST); |
32 | sqgetGlobalVar('contain_subs', $contain_subs, SQ_POST); |
a32985a5 |
33 | /* end of get globals */ |
34 | |
c6ee68f5 |
35 | $folder_name = trim($folder_name); |
36 | |
b7f83b61 |
37 | if (substr_count($folder_name, '"') || substr_count($folder_name, "\\") || |
38 | substr_count($folder_name, $delimiter) || ($folder_name == '')) { |
0037f048 |
39 | displayPageHeader($color, 'None'); |
3d3afeeb |
40 | |
b7f83b61 |
41 | plain_error_message(_("Illegal folder name. Please select a different name."). |
42 | '<BR><A HREF="../src/folders.php">'._("Click here to go back").'</A>.', $color); |
43 | |
1c52ba77 |
44 | exit; |
45 | } |
46 | |
e429f014 |
47 | $folder_name = imap_utf7_encode_local($folder_name); |
68f2ce7a |
48 | |
1c52ba77 |
49 | if (isset($contain_subs) && $contain_subs ) { |
b7f83b61 |
50 | $folder_name = $folder_name . $delimiter; |
1c52ba77 |
51 | } |
52 | |
53 | if ($folder_prefix && (substr($folder_prefix, -1) != $delimiter)) { |
54 | $folder_prefix = $folder_prefix . $delimiter; |
55 | } |
56 | if ($folder_prefix && (substr($subfolder, 0, strlen($folder_prefix)) != $folder_prefix)){ |
57 | $subfolder_orig = $subfolder; |
58 | $subfolder = $folder_prefix . $subfolder; |
59 | } else { |
60 | $subfolder_orig = $subfolder; |
61 | } |
62 | |
b7f83b61 |
63 | $imapConnection = sqimap_login($username, $key, $imapServerAddress, $imapPort, 0); |
64 | |
1c52ba77 |
65 | if (trim($subfolder_orig) == '') { |
66 | sqimap_mailbox_create ($imapConnection, $folder_prefix.$folder_name, ''); |
67 | } else { |
68 | sqimap_mailbox_create ($imapConnection, $subfolder.$delimiter.$folder_name, ''); |
69 | } |
70 | |
b7f83b61 |
71 | sqimap_logout($imapConnection); |
72 | |
1c52ba77 |
73 | $location = get_location(); |
74 | header ("Location: $location/folders.php?success=create"); |
b7f83b61 |
75 | |
525b7ae6 |
76 | ?> |