/**
 * Moves a file on the open AFM connection.
 *
 * @param  PATH		The path to the file we are moving from.
 * @param  PATH		The target path.
 */
function afm_move($basic_old_path, $basic_new_path)
{
    if (is_dir(get_custom_file_base() . '/' . $basic_new_path)) {
        $basic_new_path .= substr($basic_old_path, strrpos($basic_old_path, '/'));
    }
    // If we are moving to a path, add on the filename to that path
    $old_path = _rescope_path($basic_old_path);
    $new_path = _rescope_path($basic_new_path);
    $conn = _ftp_info();
    if ($conn !== false) {
        $success = @ftp_rename($conn, $old_path, $new_path);
        if (!$success) {
            if (running_script('upgrader')) {
                echo @strval($php_errormsg);
                return;
            }
            warn_exit(protect_from_escaping(@strval($php_errormsg)));
        }
        clearstatcache();
        sync_file_move(get_custom_file_base() . '/' . $basic_old_path, get_custom_file_base() . '/' . $basic_new_path);
    } else {
        @rename($old_path, $new_path) or intelligent_write_error($old_path);
        sync_file_move($old_path, $new_path);
    }
}
Exemple #2
0
/**
 * Rename a zone in the database and move any custom pages in it.
 *
 * @param  ID_TEXT		The old name of the zone
 * @param  ID_TEXT		The new name of the zone
 * @param  boolean		Whether to assume the main zone row has already been renamed as part of a wider editing operation
 */
function fu_rename_zone($zone, $new_zone, $dont_bother_with_main_row = false)
{
    if (function_exists('set_time_limit')) {
        @set_time_limit(0);
    }
    require_code('zones2');
    if (file_exists(get_file_base() . '/sources/zones3.php')) {
        require_code('zones3');
    }
    actual_rename_zone_lite($zone, $new_zone, $dont_bother_with_main_row);
    $pages = find_all_pages_wrap($zone, true, false, FIND_ALL_PAGES__ALL);
    foreach ($pages as $page => $type) {
        $path = get_file_base() . '/' . $zone . '/pages/' . $type . '/' . $page;
        $new_path = get_file_base() . '/' . $new_zone . '/pages/' . $type . '/' . $page;
        if (is_writable_wrap($path) && is_writable_wrap($new_path)) {
            rename($path, $new_path);
            sync_file_move($path, $new_path);
        }
    }
}