| 1 | <?php |
| 2 | |
| 3 | /** |
| 4 | * folders_rename_getname.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 | * Gets folder names and enables renaming |
| 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 . 'include/validate.php'); |
| 20 | require_once(SM_PATH . 'functions/imap.php'); |
| 21 | require_once(SM_PATH . 'functions/html.php'); |
| 22 | |
| 23 | /* get globals we may need */ |
| 24 | |
| 25 | $username = $_SESSION['username']; |
| 26 | $key = $_COOKIE['key']; |
| 27 | $delimiter = $_SESSION['delimiter']; |
| 28 | $onetimepad = $_SESSION['onetimepad']; |
| 29 | |
| 30 | $old = $_POST['old']; |
| 31 | |
| 32 | /* end of get globals */ |
| 33 | |
| 34 | if ($old == '') { |
| 35 | displayPageHeader($color, 'None'); |
| 36 | echo "<html><body bgcolor=$color[4]>"; |
| 37 | plain_error_message(_("You have not selected a folder to rename. Please do so.")."<BR><A HREF=\"../src/folders.php\">"._("Click here to go back")."</A>.", $color); |
| 38 | exit; |
| 39 | } |
| 40 | |
| 41 | |
| 42 | $imapConnection = sqimap_login($username, $key, $imapServerAddress, $imapPort, 0); |
| 43 | |
| 44 | if (substr($old, strlen($old) - strlen($delimiter)) == $delimiter) { |
| 45 | $isfolder = TRUE; |
| 46 | $old = substr($old, 0, strlen($old) - 1); |
| 47 | } else { |
| 48 | $isfolder = FALSE; |
| 49 | } |
| 50 | |
| 51 | if (strpos($old, $delimiter)) { |
| 52 | $old_name = substr($old, strrpos($old, $delimiter)+1, strlen($old)); |
| 53 | $old_parent = substr($old, 0, strrpos($old, $delimiter)); |
| 54 | } else { |
| 55 | $old_name = $old; |
| 56 | $old_parent = ''; |
| 57 | } |
| 58 | |
| 59 | displayPageHeader($color, 'None'); |
| 60 | echo '<br>' . |
| 61 | html_tag( 'table', '', 'center', '', 'width="95%" cols="1" border="0"' ) . |
| 62 | html_tag( 'tr', |
| 63 | html_tag( 'td', '<b>' . _("Rename a folder") . '</b>', 'center', $color[0] ) |
| 64 | ) . |
| 65 | html_tag( 'tr' ) . |
| 66 | html_tag( 'td', '', 'center', $color[4] ) . |
| 67 | "<FORM ACTION=\"folders_rename_do.php\" METHOD=\"POST\">\n". |
| 68 | _("New name:"). |
| 69 | "<br><B>$old_parent $delimiter </B><INPUT TYPE=TEXT SIZE=25 NAME=new_name VALUE=\"$old_name\"><BR>\n"; |
| 70 | if ( $isfolder ) { |
| 71 | echo "<INPUT TYPE=HIDDEN NAME=isfolder VALUE=\"true\">"; |
| 72 | } |
| 73 | printf("<INPUT TYPE=HIDDEN NAME=orig VALUE=\"%s\">\n", $old); |
| 74 | printf("<INPUT TYPE=HIDDEN NAME=old_name VALUE=\"%s\">\n", $old_name); |
| 75 | echo "<INPUT TYPE=SUBMIT VALUE=\""._("Submit")."\">\n". |
| 76 | "</FORM><BR></td></tr>". |
| 77 | "</table>"; |
| 78 | |
| 79 | /** Log out this session **/ |
| 80 | sqimap_logout($imapConnection); |
| 81 | ?> |