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