function tfu_copy_move($dir, $file, $enable_file_copymove, $enable_folder_copymove) { // first we check if delete is enabled! if ($enable_file_copymove != 'true' && $enable_folder_copymove != 'true') { echo 'This action is not enabled!'; exit(0); } $done = 0; $total = 0; $error = 0; $exists = 0; $overwrite = parseInputParameter($_GET['overwrite']); $folder = getDestinationFolder(parseInputParameter($_GET['target'])); $dest_folder = $folder . '/' . my_basename($dir); if ($_GET['copyfolder'] == 'true') { if ($folder == $dir) { $error = 1; } else { if (strpos($folder, $dir) !== false) { $error = 2; } else { if ($overwrite == 'false' && file_exists($dest_folder)) { $error = 3; } else { if (@rename($dir, $dest_folder)) { $done = 1; $upperdir = substr($dir, 0, strrpos($dir, "/")); $_SESSION['TFU_DIR'] = $upperdir; } else { $error = 4; } } } } } else { foreach ($file as $ff) { $total++; $dest = $folder . '/' . my_basename($ff); if ($_GET['type'] == 'c') { if ($folder == $dir) { $u_file = get_unique_filename($folder, my_basename($ff)); $dest = $folder . "/" . $u_file; } if (file_exists($dest) && $overwrite == 'false') { // if file exists and not overwrite = error $exists++; } else { if ($ff == $dest) { $nr = 2; $dest = $folder . '/Copy of ' . my_basename($ff); while (file_exists($dest)) { $dest = $folder . '/Copy (' . $nr++ . ') of ' . my_basename($ff); } } if (@copy($ff, $dest)) { $done++; } else { $error++; } } } else { if ($ff != $dest) { if (file_exists($dest) && $overwrite) { @unlink($dest); } if (!file_exists($dest)) { if (@rename($ff, $dest)) { $done++; } else { $error++; } } } } } } echo '&total=' . $total . '&ok=' . $done . '&error=' . $error . '&exists=' . $exists; }
$notdel++; } } else { $perm++; } } echo "&result=multiple&nr_del=" . $deleted . "&nr_perm=" . $perm . "&nr_not_del=" . $notdel; } else { if ($action == "copymove") { // copy move files! $done = 0; $total = 0; $error = 0; $exists = 0; $overwrite = $_GET['overwrite']; $folder = getDestinationFolder($_GET['target']); $dest_folder = $folder . "/" . basename($dir); if ($_GET['copyfolder'] == "true") { if ($folder == $dir) { $error = 1; } else { if (strpos($folder, $dir) !== false) { $error = 2; } else { if ($overwrite == "false" && file_exists($dest_folder)) { $error = 3; } else { if (@rename($dir, $dest_folder)) { $done = 1; $upperdir = substr($dir, 0, strrpos($dir, "/")); $_SESSION["TFU_DIR"] = $upperdir;