We're living in 2004 now... perl is your friend for these kinds of things :)
[squirrelmail.git] / src / folders_rename_getname.php
1 <?php
2
3 /**
4 * folders_rename_getname.php
5 *
6 * Copyright (c) 1999-2004 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 * @package squirrelmail
14 */
15
16 /** Path for SquirrelMail required files. */
17 define('SM_PATH','../');
18
19 /* SquirrelMail required files. */
20 require_once(SM_PATH . 'include/validate.php');
21 require_once(SM_PATH . 'functions/global.php');
22 require_once(SM_PATH . 'functions/imap_mailbox.php');
23 require_once(SM_PATH . 'functions/html.php');
24 require_once(SM_PATH . 'functions/display_messages.php');
25
26 /* get globals we may need */
27 sqgetGlobalVar('key', $key, SQ_COOKIE);
28 sqgetGlobalVar('username', $username, SQ_SESSION);
29 sqgetGlobalVar('onetimepad',$onetimepad, SQ_SESSION);
30 sqgetGlobalVar('delimiter', $delimiter, SQ_SESSION);
31 sqgetGlobalVar('old', $old, SQ_POST);
32 /* end of get globals */
33
34 if ($old == '') {
35 displayPageHeader($color, 'None');
36
37 plain_error_message(_("You have not selected a folder to rename. Please do so.").
38 '<BR><A HREF="../src/folders.php">'._("Click here to go back").'</A>.', $color);
39 exit;
40 }
41
42 if (substr($old, strlen($old) - strlen($delimiter)) == $delimiter) {
43 $isfolder = TRUE;
44 $old = substr($old, 0, strlen($old) - 1);
45 } else {
46 $isfolder = FALSE;
47 }
48
49 $old = imap_utf7_decode_local($old);
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
60 displayPageHeader($color, 'None');
61 echo '<br>' .
62 html_tag( 'table', '', 'center', '', 'width="95%" border="0"' ) .
63 html_tag( 'tr',
64 html_tag( 'td', '<b>' . _("Rename a folder") . '</b>', 'center', $color[0] )
65 ) .
66 html_tag( 'tr' ) .
67 html_tag( 'td', '', 'center', $color[4] ) .
68 '<FORM ACTION="folders_rename_do.php" METHOD="POST">'.
69 _("New name:").
70 '<br><b>' . htmlspecialchars($old_parent) . ' ' . htmlspecialchars($delimiter) . '</b>' .
71 '<INPUT TYPE="TEXT" SIZE="25" NAME="new_name" VALUE="' . htmlspecialchars($old_name) . '"><BR>' . "\n";
72 if ( $isfolder ) {
73 echo '<INPUT TYPE=HIDDEN NAME="isfolder" VALUE="true">';
74 }
75 printf("<INPUT TYPE=HIDDEN NAME=\"orig\" VALUE=\"%s\">\n", htmlspecialchars($old));
76 printf("<INPUT TYPE=HIDDEN NAME=\"old_name\" VALUE=\"%s\">\n", htmlspecialchars($old_name));
77 echo '<INPUT TYPE=SUBMIT VALUE="'._("Submit")."\">\n".
78 '</FORM><BR></td></tr></table>';
79
80 ?>