Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Now Wiki's FileManager is using central zip & unzip functions.

  • Loading branch information...
commit dcf2a27a32286b4fbe558e10f8a40de25ef2e74a 1 parent 83b640f
stronk7 authored

Showing 1 changed file with 11 additions and 57 deletions. Show diff stats Hide diff stats

  1. +11 57 mod/wiki/wikifiles.php
68 mod/wiki/wikifiles.php
@@ -363,25 +363,16 @@ function set_value(txt) {
363 363 if (!empty($name)) {
364 364 html_header($course, $wdir);
365 365 $name = clean_filename($name);
366   - if (empty($CFG->zip)) { // Use built-in php-based zip function
367   - $files = array();
368   - foreach ($USER->filelist as $file) {
369   - $files[] = "$basedir/$file";
370   - }
371   - include_once($CFG->libdir.'/pclzip/pclzip.lib.php');
372   - $archive = new PclZip("$basedir/$wdir/$name");
373   - if (($list = $archive->create($files,'',"$basedir/$wdir/")) == 0) {
374   - error($archive->errorInfo(true));
375   - }
376   - } else { // Use external zip program
377   - $files = "";
378   - foreach ($USER->filelist as $file) {
379   - $files .= basename($file);
380   - $files .= " ";
381   - }
382   - $command = "cd $basedir/$wdir ; $CFG->zip -r $name $files";
383   - Exec($command);
  366 +
  367 + $files = array();
  368 + foreach ($USER->filelist as $file) {
  369 + $files[] = "$basedir/$file";
  370 + }
  371 +
  372 + if (!zip_files($files,"$basedir/$wdir/$name")) {
  373 + error(get_string("zipfileserror","error"));
384 374 }
  375 +
385 376 clearfilelist();
386 377 displaydir($wdir);
387 378
@@ -422,10 +413,6 @@ function set_value(txt) {
422 413 case "unzip":
423 414 html_header($course, $wdir);
424 415 if (!empty($file)) {
425   - $strname = get_string("name");
426   - $strsize = get_string("size");
427   - $strmodified = get_string("modified");
428   - $strstatus = get_string("status");
429 416 $strok = get_string("ok");
430 417 $strunpacking = get_string("unpacking", "", $file);
431 418
@@ -433,41 +420,8 @@ function set_value(txt) {
433 420
434 421 $file = basename($file);
435 422
436   - if (empty($CFG->unzip)) { // Use built-in php-based unzip function
437   - include_once($CFG->libdir.'/pclzip/pclzip.lib.php');
438   - $archive = new PclZip("$basedir/$wdir/$file");
439   - if (!$list = $archive->extract("$basedir/$wdir")) {
440   - error($archive->errorInfo(true));
441   - } else { // print some output
442   - echo "<table cellpadding=\"4\" cellspacing=\"2\" border=\"0\" width=640>";
443   - echo "<tr><th align=left>$strname</th>";
444   - echo "<th align=right>$strsize</th>";
445   - echo "<th align=right>$strmodified</th>";
446   - echo "<th align=right>$strstatus</th></tr>";
447   - foreach ($list as $item) {
448   - echo "<tr>";
449   - $item['filename'] = str_replace("$basedir/$wdir/", "", $item['filename']);
450   - print_cell("left", $item['filename']);
451   - if (! $item['folder']) {
452   - print_cell("right", display_size($item['size']));
453   - } else {
454   - echo "<td>&nbsp;</td>";
455   - }
456   - $filedate = userdate($item['mtime'], get_string("strftimedatetime"));
457   - print_cell("right", $filedate);
458   - print_cell("right", $item['status']);
459   - echo "</tr>";
460   - }
461   - echo "</table>";
462   - }
463   -
464   - } else { // Use external unzip program
465   - print_simple_box_start("center");
466   - echo "<PRE>";
467   - $command = "cd $basedir/$wdir ; $CFG->unzip -o $file 2>&1";
468   - passthru($command);
469   - echo "</PRE>";
470   - print_simple_box_end();
  423 + if (!unzip_file("$basedir/$wdir/$file")) {
  424 + error(get_string("unzipfileserror","error"));
471 425 }
472 426
473 427 echo "<CENTER><FORM ACTION=\"".$ME."\" METHOD=get>";

0 comments on commit dcf2a27

Please sign in to comment.
Something went wrong with that request. Please try again.