Only show text/plain if show_html_default=0
[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 require_once('../src/validate.php');
16 require_once('../functions/imap.php');
17 require_once('../functions/display_messages.php');
18
19 $imapConnection = sqimap_login($username, $key, $imapServerAddress, $imapPort, 0);
20 global $delimiter;
21
22 $folder_name = trim($folder_name);
23
24 if (strpos($folder_name, "\"") || strpos($folder_name, "\\") ||
25 strpos($folder_name, "'") || strpos($folder_name, "$delimiter") ||
26 ($folder_name == '')) {
27 displayPageHeader($color, 'None');
28 echo "<html><body bgcolor=$color[4]>";
29 plain_error_message(_("Illegal folder name. Please select a different name.")."<BR><A HREF=\"../src/folders.php\">"._("Click here to go back")."</A>.", $color);
30 sqimap_logout($imapConnection);
31 exit;
32 }
33
34 if (isset($contain_subs) && $contain_subs ) {
35 $folder_name = "$folder_name$delimiter";
36 }
37
38 if ($folder_prefix && (substr($folder_prefix, -1) != $delimiter)) {
39 $folder_prefix = $folder_prefix . $delimiter;
40 }
41 if ($folder_prefix && (substr($subfolder, 0, strlen($folder_prefix)) != $folder_prefix)){
42 $subfolder_orig = $subfolder;
43 $subfolder = $folder_prefix . $subfolder;
44 } else {
45 $subfolder_orig = $subfolder;
46 }
47
48 if (trim($subfolder_orig) == '') {
49 sqimap_mailbox_create ($imapConnection, $folder_prefix.$folder_name, '');
50 } else {
51 sqimap_mailbox_create ($imapConnection, $subfolder.$delimiter.$folder_name, '');
52 }
53
54 $location = get_location();
55 header ("Location: $location/folders.php?success=create");
56 sqimap_logout($imapConnection);
57 ?>