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