SM_PATH already defined
[squirrelmail.git] / src / folders_create.php
1 <?php
2
3 /**
4 * folders_create.php
5 *
6 * Copyright (c) 1999-2002 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 * $Id$
13 */
14
15 /* Path for SquirrelMail required files. */
16 define('SM_PATH','../');
17
18 /* SquirrelMail required files. */
19 require_once(SM_PATH . 'include/validate.php');
20 require_once(SM_PATH . 'functions/imap.php');
21 require_once(SM_PATH . 'functions/display_messages.php');
22
23 /* get globals we may need */
24
25 $username = $_SESSION['username'];
26 $key = $_COOKIE['key'];
27 $delimiter = $_SESSION['delimiter'];
28 $onetimepad = $_SESSION['onetimepad'];
29 $folder_name = $_POST['folder_name'];
30 $subfolder = $_POST['subfolder'];
31 if (isset($_POST['contain_subs'])) {
32 $contain_subs = $_POST['contain_subs'];
33 }
34
35 /* end of get globals */
36
37 $folder_name = trim($folder_name);
38
39 if (substr_count($folder_name, '"') || substr_count($folder_name, "\\") ||
40 substr_count($folder_name, $delimiter) || ($folder_name == '')) {
41 displayPageHeader($color, 'None');
42
43 plain_error_message(_("Illegal folder name. Please select a different name.").
44 '<BR><A HREF="../src/folders.php">'._("Click here to go back").'</A>.', $color);
45
46 exit;
47 }
48
49 if (isset($contain_subs) && $contain_subs ) {
50 $folder_name = $folder_name . $delimiter;
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
63 $imapConnection = sqimap_login($username, $key, $imapServerAddress, $imapPort, 0);
64
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
71 sqimap_logout($imapConnection);
72
73 $location = get_location();
74 header ("Location: $location/folders.php?success=create");
75
76 ?>