/**
* folders_rename_getname.php
*
- * Copyright (c) 1999-2001 The Squirrelmail Development Team
+ * Copyright (c) 1999-2003 The SquirrelMail Project Team
* Licensed under the GNU GPL. For full terms see the file COPYING.
*
* Gets folder names and enables renaming
* Called from folders.php
*
* $Id$
+ * @package squirrelmail
*/
-/*****************************************************************/
-/*** THIS FILE NEEDS TO HAVE ITS FORMATTING FIXED!!! ***/
-/*** PLEASE DO SO AND REMOVE THIS COMMENT SECTION. ***/
-/*** + Base level indent should begin at left margin, as ***/
-/*** the require_once below looks. ***/
-/*** + All identation should consist of four space blocks ***/
-/*** + Tab characters are evil. ***/
-/*** + all comments should use "slash-star ... star-slash" ***/
-/*** style -- no pound characters, no slash-slash style ***/
-/*** + FLOW CONTROL STATEMENTS (if, while, etc) SHOULD ***/
-/*** ALWAYS USE { AND } CHARACTERS!!! ***/
-/*** + Please use ' instead of ", when possible. Note " ***/
-/*** should always be used in _( ) function calls. ***/
-/*** Thank you for your help making the SM code more readable. ***/
-/*****************************************************************/
+/** Path for SquirrelMail required files. */
+define('SM_PATH','../');
-require_once('../src/validate.php');
-require_once('../functions/imap.php');
+/* SquirrelMail required files. */
+require_once(SM_PATH . 'include/validate.php');
+require_once(SM_PATH . 'functions/global.php');
+require_once(SM_PATH . 'functions/imap_mailbox.php');
+require_once(SM_PATH . 'functions/html.php');
+require_once(SM_PATH . 'functions/display_messages.php');
- $imapConnection = sqimap_login($username, $key, $imapServerAddress, $imapPort, 0);
+/* get globals we may need */
+sqgetGlobalVar('key', $key, SQ_COOKIE);
+sqgetGlobalVar('username', $username, SQ_SESSION);
+sqgetGlobalVar('onetimepad',$onetimepad, SQ_SESSION);
+sqgetGlobalVar('delimiter', $delimiter, SQ_SESSION);
+sqgetGlobalVar('old', $old, SQ_POST);
+/* end of get globals */
- global $delimiter;
- if (substr($old, strlen($old) - strlen($delimiter)) == $delimiter) {
- $isfolder = true;
- $old = substr($old, 0, strlen($old) - 1);
- }
-
- if (strpos($old, $delimiter)) {
- $old_name = substr($old, strrpos($old, $delimiter)+1, strlen($old));
- $old_parent = substr($old, 0, strrpos($old, $delimiter));
- } else {
- $old_name = $old;
- $old_parent = "";
- }
+if ($old == '') {
+ displayPageHeader($color, 'None');
- displayPageHeader($color, 'None');
- echo "<br><TABLE align=center border=0 WIDTH=95% COLS=1>";
- echo "<TR><TD BGCOLOR=\"$color[0]\" ALIGN=CENTER><B>";
- echo _("Rename a folder");
- echo "</B></TD></TR>";
- echo "<TR><TD BGCOLOR=\"$color[4]\" ALIGN=CENTER>";
- echo "<FORM ACTION=\"folders_rename_do.php\" METHOD=\"POST\">\n";
- echo _("New name:");
- echo "<br><B>$old_parent . </B><INPUT TYPE=TEXT SIZE=25 NAME=new_name VALUE=\"$old_name\"><BR>\n";
- if (isset($isfolder))
- echo "<INPUT TYPE=HIDDEN NAME=isfolder VALUE=\"true\">";
- printf("<INPUT TYPE=HIDDEN NAME=orig VALUE=\"%s\">\n", $old);
- printf("<INPUT TYPE=HIDDEN NAME=old_name VALUE=\"%s\">\n", $old_name);
- echo "<INPUT TYPE=SUBMIT VALUE=\""._("Submit")."\">\n";
- echo "</FORM><BR></TD></TR>";
- echo "</TABLE>";
+ 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);
+ exit;
+}
+
+if (substr($old, strlen($old) - strlen($delimiter)) == $delimiter) {
+ $isfolder = TRUE;
+ $old = substr($old, 0, strlen($old) - 1);
+} else {
+ $isfolder = FALSE;
+}
+
+$old = imap_utf7_decode_local($old);
+
+if (strpos($old, $delimiter)) {
+ $old_name = substr($old, strrpos($old, $delimiter)+1, strlen($old));
+ $old_parent = substr($old, 0, strrpos($old, $delimiter));
+} else {
+ $old_name = $old;
+ $old_parent = '';
+}
+
+
+displayPageHeader($color, 'None');
+echo '<br>' .
+ html_tag( 'table', '', 'center', '', 'width="95%" border="0"' ) .
+ html_tag( 'tr',
+ html_tag( 'td', '<b>' . _("Rename a folder") . '</b>', 'center', $color[0] )
+ ) .
+ html_tag( 'tr' ) .
+ html_tag( 'td', '', 'center', $color[4] ) .
+ '<FORM ACTION="folders_rename_do.php" METHOD="POST">'.
+ _("New name:").
+ '<br><b>' . htmlspecialchars($old_parent) . ' ' . htmlspecialchars($delimiter) . '</b>' .
+ '<INPUT TYPE="TEXT" SIZE="25" NAME="new_name" VALUE="' . htmlspecialchars($old_name) . '"><BR>' . "\n";
+if ( $isfolder ) {
+ echo '<INPUT TYPE=HIDDEN NAME="isfolder" VALUE="true">';
+}
+printf("<INPUT TYPE=HIDDEN NAME=\"orig\" VALUE=\"%s\">\n", htmlspecialchars($old));
+printf("<INPUT TYPE=HIDDEN NAME=\"old_name\" VALUE=\"%s\">\n", htmlspecialchars($old_name));
+echo '<INPUT TYPE=SUBMIT VALUE="'._("Submit")."\">\n".
+ '</FORM><BR></td></tr></table>';
- /** Log out this session **/
- sqimap_logout($imapConnection);
?>