If stream is FALSE also don't logout
[squirrelmail.git] / src / folders_create.php
CommitLineData
59177427 1<?php
895905c0 2
35586184 3/**
4 * folders_create.php
5 *
15e6162e 6 * Copyright (c) 1999-2002 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');
86725763 20require_once(SM_PATH . 'functions/imap.php');
21require_once(SM_PATH . 'functions/display_messages.php');
d3cdb279 22
a32985a5 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'];
31if (isset($_POST['contain_subs'])) {
32 $contain_subs = $_POST['contain_subs'];
33}
34
35/* end of get globals */
36
1c52ba77 37$imapConnection = sqimap_login($username, $key, $imapServerAddress, $imapPort, 0);
1c52ba77 38
c6ee68f5 39$folder_name = trim($folder_name);
40
3d3afeeb 41if (substr_count($folder_name, "\"") || substr_count($folder_name, "\\") ||
42 substr_count($folder_name, "'") || substr_count($folder_name, "$delimiter") ||
0037f048 43 ($folder_name == '')) {
44 displayPageHeader($color, 'None');
3d3afeeb 45
1c52ba77 46 plain_error_message(_("Illegal folder name. Please select a different name.")."<BR><A HREF=\"../src/folders.php\">"._("Click here to go back")."</A>.", $color);
47 sqimap_logout($imapConnection);
48 exit;
49}
50
51if (isset($contain_subs) && $contain_subs ) {
52 $folder_name = "$folder_name$delimiter";
53}
54
55if ($folder_prefix && (substr($folder_prefix, -1) != $delimiter)) {
56 $folder_prefix = $folder_prefix . $delimiter;
57}
58if ($folder_prefix && (substr($subfolder, 0, strlen($folder_prefix)) != $folder_prefix)){
59 $subfolder_orig = $subfolder;
60 $subfolder = $folder_prefix . $subfolder;
61} else {
62 $subfolder_orig = $subfolder;
63}
64
65if (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$location = get_location();
72header ("Location: $location/folders.php?success=create");
73sqimap_logout($imapConnection);
525b7ae6 74?>