a16b43d933be6c14561b4bb27f0ba1a726f4e72e
[squirrelmail.git] / src / folders_create.php
1 <?php
2 /**
3 ** folders_create.php
4 **
5 ** Copyright (c) 1999-2000 The SquirrelMail development team
6 ** Licensed under the GNU GPL. For full terms see the file COPYING.
7 **
8 ** Creates folders on the IMAP server.
9 ** Called from folders.php
10 **
11 ** $Id$
12 **/
13
14 include('../src/validate.php');
15 include("../functions/page_header.php");
16 include("../functions/imap.php");
17 include("../functions/display_messages.php");
18 include("../src/load_prefs.php");
19
20 $imapConnection = sqimap_login($username, $key, $imapServerAddress, $imapPort, 0);
21 $dm = sqimap_get_delimiter($imapConnection);
22
23 if (strpos($folder_name, "\"") || strpos($folder_name, "\\") ||
24 strpos($folder_name, "'") || strpos($folder_name, "$dm")) {
25 print "<html><body bgcolor=$color[4]>";
26 plain_error_message(_("Illegal folder name. Please select a different name.")."<BR><A HREF=\"../src/folders.php\">"._("Click here to go back")."</A>.", $color);
27 sqimap_logout($imapConnection);
28 exit;
29 }
30
31 if (isset($contain_subs) && $contain_subs == true)
32 $folder_name = "$folder_name$dm";
33
34 if ($folder_prefix && (substr($folder_prefix, -1) != $dm)) {
35 $folder_prefix = $folder_prefix . $dm;
36 }
37 if ($folder_prefix && (substr($subfolder, 0, strlen($folder_prefix)) != $folder_prefix)){
38 $subfolder_orig = $subfolder;
39 $subfolder = $folder_prefix . $subfolder;
40 } else {
41 $subfolder_orig = $subfolder;
42 }
43
44 if (trim($subfolder_orig) == '') {
45 sqimap_mailbox_create ($imapConnection, $folder_prefix.$folder_name, "");
46 } else {
47 sqimap_mailbox_create ($imapConnection, $subfolder.$dm.$folder_name, "");
48 }
49
50 $location = get_location();
51 header ("Location: $location/folders.php?success=create");
52 sqimap_logout($imapConnection);
53 ?>
54