function addDirContent($path, $zip, $innerDir = null) { foreach (getContentOf($path) as $file) { $filePath = $path . DIRECTORY_SEPARATOR . $file; $innerPath = ($innerDir == null ? "" : $innerDir . DIRECTORY_SEPARATOR) . $file; if (is_dir($filePath)) { if (!$zip->addEmptyDir($innerPath)) { die("Impossible de créer le dossier : " . $innerPath); } addDirContent($filePath, $zip, $innerPath); } else { if (is_file($filePath)) { if (!$zip->addFile($filePath, $innerPath)) { die("Impossible de rajouter le fichier : " . $innerPath . " [" . $filePath . "]"); } } } } }
foreach ($_POST['selection'] as $md5) { $filePaths[] = getPathForMD5Chain(DOWNLOADS_DIR, $md5); } } else { throw new Exception("No selection provided."); } } else { $filePaths[] = getPathFromURL(); } $fileName = ""; foreach ($filePaths as $path) { $fileName .= fileName($path) . ' + '; } $fileName = substr($fileName, 0, strlen($fileName) - 3); $dirPath = DOWNLOADS_DIR; $allFiles = getContentOf($dirPath); $dirs = array(); foreach ($allFiles as $file) { $path = $dirPath . "/" . $file; if (is_dir($path) && !in_array($path, $filePaths)) { array_push($dirs, $path); } } $title = TITLE . " - Déplacer " . $fileName; $formList = ""; foreach ($filePaths as $path) { $formList .= '<input type="hidden" name="files[]" value="' . htmlentities($path) . '"/>'; } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd">
function getSize($path) { if ($path === null) { return 0; } else { if (is_file($path)) { $stat = stat($path); return min($stat['size'], 512 * $stat['blocks']); } else { if (is_dir($path)) { $size = 0; foreach (getContentOf($path, true) as $file) { $size += getSize($path . DIRECTORY_SEPARATOR . $file); } return $size; } else { debug_print_backtrace(); die("Chemin invalide : " . $path); } } } }