From 1a11dfd14adbd305b736090bcc2a545f1861b90f Mon Sep 17 00:00:00 2001 From: stronk7 Date: Sun, 10 Oct 2004 01:20:59 +0000 Subject: [PATCH] iNow FileManager is using the new, central zip_files() function. Only tested under MacOS X. It should support all the new features of that function (Win32 external zip, imporved security...). TODO: Create the unzip_file() function and use it here too!! Apply this changes to the rest of filemanagers (coursefiles.php...) TEST, TEST, TEST...!! Merged from MOODLE_14_STABLE --- files/index.php | 28 +++++++++------------------- 1 file changed, 9 insertions(+), 19 deletions(-) diff --git a/files/index.php b/files/index.php index 0145a3049b8..20ea0f2f048 100644 --- a/files/index.php +++ b/files/index.php @@ -338,26 +338,16 @@ if (!empty($name)) { html_header($course, $wdir); $name = clean_filename($name); - if (empty($CFG->zip)) { // Use built-in php-based zip function - $files = array(); - foreach ($USER->filelist as $file) { - $files[] = cleardoubleslashes("$basedir/$file"); // no doubleslashes! - } - include_once("$CFG->libdir/pclzip/pclzip.lib.php"); - $archive = new PclZip(cleardoubleslashes("$basedir/$wdir/$name")); - if (($list = $archive->create($files, PCLZIP_OPT_REMOVE_PATH, - rtrim(cleardoubleslashes("$basedir/$wdir"), "/"))) == 0) { // no double slashes and trailing slash! - error($archive->errorInfo(true)); - } - } else { // Use external zip program - $files = ""; - foreach ($USER->filelist as $file) { - $files .= basename($file); - $files .= " "; - } - $command = "cd $basedir/$wdir ; $CFG->zip -r $name $files"; - Exec($command); + + $files = array(); + foreach ($USER->filelist as $file) { + $files[] = "$basedir/$file"; } + + if (!zip_files($files,"$basedir/$wdir/$name")) { + error(get_string("zipfileserror","error")); + } + clearfilelist(); displaydir($wdir);