if (substr_count($new_name, '"') || substr_count($new_name, "\\") || substr_count($new_name, $delimiter) || $new_name == '') {
    displayPageHeader($color, 'None');
    plain_error_message(_("Illegal folder name. Please select a different name.") . '<br /><a href="../src/folders.php">' . _("Click here to go back") . '</a>.', $color);
    exit;
}
$orig = imap_utf7_encode_local($orig);
$old_name = imap_utf7_encode_local($old_name);
$new_name = imap_utf7_encode_local($new_name);
if ($old_name != $new_name) {
    $imapConnection = sqimap_login($username, $key, $imapServerAddress, $imapPort, 0);
    if (strpos($orig, $delimiter)) {
        $old_dir = substr($orig, 0, strrpos($orig, $delimiter));
    } else {
        $old_dir = '';
    }
    if ($old_dir != '') {
        $newone = $old_dir . $delimiter . $new_name;
    } else {
        $newone = $new_name;
    }
    // Renaming a folder doesn't rename the folder but leaves you unsubscribed
    //    at least on Cyrus IMAP servers.
    if (isset($isfolder)) {
        $newone = $newone . $delimiter;
        $orig = $orig . $delimiter;
    }
    sqimap_mailbox_rename($imapConnection, $orig, $newone);
    // Log out this session
    sqimap_logout($imapConnection);
}
header('Location: ' . get_location() . '/folders.php?success=rename');
Ejemplo n.º 2
0
/**
 * Given an old and new folder name, renames the folder.
 */
function folders_rename_do($imapConnection, $delimiter, $orig, $old_name, $new_name)
{
    folders_checkname($imapConnection, $new_name, $delimiter);
    $orig = imap_utf7_encode_local($orig);
    $old_name = imap_utf7_encode_local($old_name);
    $new_name = imap_utf7_encode_local($new_name);
    if ($old_name != $new_name) {
        if (strpos($orig, $delimiter)) {
            $old_dir = substr($orig, 0, strrpos($orig, $delimiter));
        } else {
            $old_dir = '';
        }
        if ($old_dir != '') {
            $newone = $old_dir . $delimiter . $new_name;
        } else {
            $newone = $new_name;
        }
        // Renaming a folder doesn't rename the folder but leaves you unsubscribed
        //    at least on Cyrus IMAP servers.
        if (isset($isfolder)) {
            $newone = $newone . $delimiter;
            $orig = $orig . $delimiter;
        }
        sqimap_mailbox_rename($imapConnection, $orig, $newone);
    }
    return;
}