function rrename($source, $destination, $is_rec = FALSE) { if (is_dir($source)) { if ($is_rec === FALSE) { $pinfo = pathinfo($source); $destination = rtrim($destination, '/') . DIRECTORY_SEPARATOR . $pinfo['basename']; } if (is_dir($destination) === FALSE) { mkdir($destination, 0755, true); } $files = scandir($source); foreach ($files as $file) { if ($file != "." && $file != "..") { rrename($source . DIRECTORY_SEPARATOR . $file, rtrim($destination, '/') . DIRECTORY_SEPARATOR . $file, TRUE); } } } else { if (file_exists($source)) { if (is_dir($destination) === TRUE) { $pinfo = pathinfo($source); $dest2 = rtrim($destination, '/') . DIRECTORY_SEPARATOR . $pinfo['basename']; } else { $dest2 = $destination; } rename($source, $dest2); } } }
// check for writability if (is_really_writable($path) === FALSE || is_really_writable($path_thumb) === FALSE) { response(trans('Dir_No_Write') . '<br/>' . str_replace('../', '', $path) . '<br/>' . str_replace('../', '', $path_thumb), 403)->send(); exit; } // check if server disables copy or rename if (is_function_callable($action == 'copy' ? 'copy' : 'rename') === FALSE) { response(sprintf(trans('Function_Disabled'), $action == 'copy' ? lcfirst(trans('Copy')) : lcfirst(trans('Cut'))), 403)->send(); exit; } if ($action == 'copy') { rcopy($data['path'], $path); rcopy($data['path_thumb'], $path_thumb); } elseif ($action == 'cut') { rrename($data['path'], $path); rrename($data['path_thumb'], $path_thumb); // cleanup if (is_dir($data['path']) === TRUE) { rrename_after_cleaner($data['path']); rrename_after_cleaner($data['path_thumb']); } } // cleanup $_SESSION['RF']['clipboard']['path'] = NULL; $_SESSION['RF']['clipboard_action'] = NULL; break; case 'chmod': $mode = $_POST['new_mode']; $rec_option = $_POST['is_recursive']; $valid_options = array('none', 'files', 'folders', 'both'); $chmod_perm = is_dir($path) ? $chmod_dirs : $chmod_files;