* Bugfix from Albert Novak <anovak@pu.carnet.hr>
[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 session_start();
15
16 if (!isset($strings_php))
17 include("../functions/strings.php");
18 if (!isset($config_php))
19 include("../config/config.php");
20 if (!isset($page_header_php))
21 include("../functions/page_header.php");
22 if (!isset($imap_php))
23 include("../functions/imap.php");
24 if (!isset($display_messages_php))
25 include("../functions/display_messages.php");
26
27 include("../src/load_prefs.php");
28
29 $imapConnection = sqimap_login($username, $key, $imapServerAddress, $imapPort, 0);
30 $dm = sqimap_get_delimiter($imapConnection);
31
32 if (strpos($folder_name, "\"") || strpos($folder_name, "\\") ||
33 strpos($folder_name, "'") || strpos($folder_name, "$dm")) {
34 print "<html><body bgcolor=$color[4]>";
35 plain_error_message(_("Illegal folder name. Please select a different name.")."<BR><A HREF=\"../src/folders.php\">"._("Click here to go back")."</A>.", $color);
36 sqimap_logout($imapConnection);
37 exit;
38 }
39
40 if (isset($contain_subs) && $contain_subs == true)
41 $folder_name = "$folder_name$dm";
42
43 if ($folder_prefix && (substr($folder_prefix, -1) != $dm)) {
44 $folder_prefix = $folder_prefix . $dm;
45 }
46 if ($folder_prefix && (substr($subfolder, 0, strlen($folder_prefix)) != $folder_prefix)){
47 $subfolder_orig = $subfolder;
48 $subfolder = $folder_prefix . $subfolder;
49 } else {
50 $subfolder_orig = $subfolder;
51 }
52
53 if (trim($subfolder_orig) == '[ ' . _('None') . ' ]' ||
54 trim($subfolder_orig) == '') {
55 sqimap_mailbox_create ($imapConnection, $folder_prefix.$folder_name, "");
56 } else {
57 sqimap_mailbox_create ($imapConnection, $subfolder.$dm.$folder_name, "");
58 }
59 fputs($imapConnection, "1 logout\n");
60
61 $location = get_location();
62 header ("Location: $location/folders.php?success=create");
63 sqimap_logout($imapConnection);
64 ?>
65