Drop unused file imap_search.php.
[squirrelmail.git] / src / folders_create.php
1 <?php
2
3 /**
4 * folders_create.php
5 *
6 * Copyright (c) 1999-2005 The SquirrelMail Project Team
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 * @version $Id$
13 * @package squirrelmail
14 */
15
16 /**
17 * Path for SquirrelMail required files.
18 * @ignore
19 */
20 define('SM_PATH','../');
21
22 /* SquirrelMail required files. */
23 require_once(SM_PATH . 'include/validate.php');
24 require_once(SM_PATH . 'functions/global.php');
25 require_once(SM_PATH . 'functions/imap.php');
26 require_once(SM_PATH . 'functions/display_messages.php');
27
28 /* get globals we may need */
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);
36 /* end of get globals */
37
38 $folder_name = trim($folder_name);
39
40 if (substr_count($folder_name, '"') || substr_count($folder_name, "\\") ||
41 substr_count($folder_name, $delimiter) || ($folder_name == '')) {
42 displayPageHeader($color, 'None');
43
44 plain_error_message(_("Illegal folder name. Please select a different name.").
45 '<br /><a href="../src/folders.php">'._("Click here to go back").'</a>.', $color);
46
47 exit;
48 }
49
50 $folder_name = imap_utf7_encode_local($folder_name);
51
52 if (isset($contain_subs) && $contain_subs ) {
53 $folder_name = $folder_name . $delimiter;
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
66 $imapConnection = sqimap_login($username, $key, $imapServerAddress, $imapPort, 0);
67
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
74 sqimap_logout($imapConnection);
75
76 $location = get_location();
77 header ("Location: $location/folders.php?success=create");
78
79 ?>