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