diff --git a/admin/settings/server.php b/admin/settings/server.php
index 095c0b5850d..d00d24bb3b7 100644
--- a/admin/settings/server.php
+++ b/admin/settings/server.php
@@ -10,8 +10,6 @@ $temp = new admin_settingpage('systempaths', get_string('systempaths','admin'));
$temp->add(new admin_setting_configselect('gdversion', get_string('gdversion','admin'), get_string('configgdversion', 'admin'), check_gd_version(), array('0' => get_string('gdnot'),
'1' => get_string('gd1'),
'2' => get_string('gd2'))));
-$temp->add(new admin_setting_configexecutable('zip', get_string('pathtozip','admin'), get_string('configzip', 'admin'), ''));
-$temp->add(new admin_setting_configexecutable('unzip', get_string('pathtounzip','admin'), get_string('configunzip', 'admin'), ''));
$temp->add(new admin_setting_configexecutable('pathtodu', get_string('pathtodu', 'admin'), get_string('configpathtodu', 'admin'), ''));
$temp->add(new admin_setting_configexecutable('aspellpath', get_string('aspellpath', 'admin'), get_string('edhelpaspellpath'), ''));
$ADMIN->add('server', $temp, 0);
diff --git a/backup/backuplib.php b/backup/backuplib.php
index 3b62bfed9a0..336bce67866 100644
--- a/backup/backuplib.php
+++ b/backup/backuplib.php
@@ -473,12 +473,6 @@
fwrite ($bf,full_tag("DATE",2,false,$preferences->backup_unique_code));
//The original site wwwroot
fwrite ($bf,full_tag("ORIGINAL_WWWROOT",2,false,$CFG->wwwroot));
- //The zip method used
- if (!empty($CFG->zip)) {
- $zipmethod = 'external';
- } else {
- $zipmethod = 'internal';
- }
//Indicate if it includes external MNET users
$sql = "SELECT b.old_id
FROM {backup_ids} b
@@ -488,7 +482,6 @@
if ($DB->record_exists_sql($sql, array($preferences->backup_unique_code, $CFG->mnet_localhost_id))) {
fwrite ($bf,full_tag("MNET_REMOTEUSERS",2,false,'true'));
}
- fwrite ($bf,full_tag("ZIP_METHOD",2,false,$zipmethod));
//Te includes tag
fwrite ($bf,start_tag("DETAILS",2,true));
//Now, go to mod element of preferences to print its status
diff --git a/install/stringnames.txt b/install/stringnames.txt
index 8b17f03a16a..41a8e479eed 100644
--- a/install/stringnames.txt
+++ b/install/stringnames.txt
@@ -251,3 +251,4 @@ wwwroot
wwwrooterror
yourchoice
xmlrpcrecommended
+ziprequired
diff --git a/lang/en_utf8/admin.php b/lang/en_utf8/admin.php
index 004ed39a515..d8308239b77 100644
--- a/lang/en_utf8/admin.php
+++ b/lang/en_utf8/admin.php
@@ -783,5 +783,6 @@ $string['webproxy'] = 'Web proxy';
$string['webproxyinfo'] = 'Fill in following options if your Moodle server can not access internet directly. Internet access is required for download of environment data, language packs, RSS feeds, timezones, etc.
PHP cURL extension is highly recommended.';
$string['xmlrpcrecommended'] = 'Installing the optional xmlrpc extension is useful for Moodle Networking functionality.';
$string['xmlstrictheaders'] = 'XML strict headers';
+$string['ziprequired'] = 'The Zip PHP extension is now required by Moodle, info-ZIP binaries or PclZip library are not used anymore.';
?>
diff --git a/lib/db/upgrade.php b/lib/db/upgrade.php
index 3eb0821f0bf..ce0461e02c3 100644
--- a/lib/db/upgrade.php
+++ b/lib/db/upgrade.php
@@ -566,6 +566,13 @@ function xmldb_main_upgrade($oldversion=0) {
upgrade_main_savepoint($result, 2008080400);
}
+ if ($result && $oldversion < 2008080401) {
+ // zip binaries not used anymore
+ unset_config('zip');
+ unset_config('unzip');
+ /// Main savepoint reached
+ upgrade_main_savepoint($result, 2008080401);
+ }
return $result;
}
diff --git a/lib/deprecatedlib.php b/lib/deprecatedlib.php
index 213ac7b46e3..cfeac99e1e3 100644
--- a/lib/deprecatedlib.php
+++ b/lib/deprecatedlib.php
@@ -389,6 +389,74 @@ function unzip_file($zipfile, $destination = '', $showstatus_ignored = true) {
return true;
}
+/**
+ * Zip an array of files/dirs to a destination zip file
+ * Both parameters must be FULL paths to the files/dirs
+ */
+function zip_files ($originalfiles, $destination) {
+ global $CFG;
+
+ //Extract everything from destination
+ $path_parts = pathinfo(cleardoubleslashes($destination));
+ $destpath = $path_parts["dirname"]; //The path of the zip file
+ $destfilename = $path_parts["basename"]; //The name of the zip file
+ $extension = $path_parts["extension"]; //The extension of the file
+
+ //If no file, error
+ if (empty($destfilename)) {
+ return false;
+ }
+
+ //If no extension, add it
+ if (empty($extension)) {
+ $extension = 'zip';
+ $destfilename = $destfilename.'.'.$extension;
+ }
+
+ //Check destination path exists
+ if (!is_dir($destpath)) {
+ return false;
+ }
+
+ //Check destination path is writable. TODO!!
+
+ //Clean destination filename
+ $destfilename = clean_filename($destfilename);
+
+ //Now check and prepare every file
+ $files = array();
+ $origpath = NULL;
+
+ foreach ($originalfiles as $file) { //Iterate over each file
+ //Check for every file
+ $tempfile = cleardoubleslashes($file); // no doubleslashes!
+ //Calculate the base path for all files if it isn't set
+ if ($origpath === NULL) {
+ $origpath = rtrim(cleardoubleslashes(dirname($tempfile)), "/");
+ }
+ //See if the file is readable
+ if (!is_readable($tempfile)) { //Is readable
+ continue;
+ }
+ //See if the file/dir is in the same directory than the rest
+ if (rtrim(cleardoubleslashes(dirname($tempfile)), "/") != $origpath) {
+ continue;
+ }
+ //Add the file to the array
+ $files[] = $tempfile;
+ }
+
+ $zipfiles = array();
+ $start = strlen($origpath)+1;
+ foreach($files as $file) {
+ $zipfiles[substr($file, $start)] = $file;
+ }
+
+ $packer = get_file_packer();
+
+ return $packer->zip_files_to_pathname($zipfiles, $destfilename);
+}
+
/////////////////////////////////////////////////////////////
/// Old functions not used anymore - candidates for removal
/////////////////////////////////////////////////////////////
diff --git a/lib/moodlelib.php b/lib/moodlelib.php
index 44c3afeac93..30b6c2e4b91 100644
--- a/lib/moodlelib.php
+++ b/lib/moodlelib.php
@@ -7227,176 +7227,6 @@ function cleardoubleslashes ($path) {
return preg_replace('/(\/|\\\){1,}/','/',$path);
}
-function zip_files ($originalfiles, $destination) {
-//Zip an array of files/dirs to a destination zip file
-//Both parameters must be FULL paths to the files/dirs
-
- global $CFG;
-
- //Extract everything from destination
- $path_parts = pathinfo(cleardoubleslashes($destination));
- $destpath = $path_parts["dirname"]; //The path of the zip file
- $destfilename = $path_parts["basename"]; //The name of the zip file
- $extension = $path_parts["extension"]; //The extension of the file
-
- //If no file, error
- if (empty($destfilename)) {
- return false;
- }
-
- //If no extension, add it
- if (empty($extension)) {
- $extension = 'zip';
- $destfilename = $destfilename.'.'.$extension;
- }
-
- //Check destination path exists
- if (!is_dir($destpath)) {
- return false;
- }
-
- //Check destination path is writable. TODO!!
-
- //Clean destination filename
- $destfilename = clean_filename($destfilename);
-
- //Now check and prepare every file
- $files = array();
- $origpath = NULL;
-
- foreach ($originalfiles as $file) { //Iterate over each file
- //Check for every file
- $tempfile = cleardoubleslashes($file); // no doubleslashes!
- //Calculate the base path for all files if it isn't set
- if ($origpath === NULL) {
- $origpath = rtrim(cleardoubleslashes(dirname($tempfile)), "/");
- }
- //See if the file is readable
- if (!is_readable($tempfile)) { //Is readable
- continue;
- }
- //See if the file/dir is in the same directory than the rest
- if (rtrim(cleardoubleslashes(dirname($tempfile)), "/") != $origpath) {
- continue;
- }
- //Add the file to the array
- $files[] = $tempfile;
- }
-
- //Everything is ready:
- // -$origpath is the path where ALL the files to be compressed reside (dir).
- // -$destpath is the destination path where the zip file will go (dir).
- // -$files is an array of files/dirs to compress (fullpath)
- // -$destfilename is the name of the zip file (without path)
-
- //print_object($files); //Debug
-
- if (empty($CFG->zip)) { // Use built-in php-based zip function
-
- include_once("$CFG->libdir/pclzip/pclzip.lib.php");
- //rewrite filenames because the old method with PCLZIP_OPT_REMOVE_PATH does not work under win32
- $zipfiles = array();
- $start = strlen($origpath)+1;
- foreach($files as $file) {
- $tf = array();
- $tf[PCLZIP_ATT_FILE_NAME] = $file;
- $tf[PCLZIP_ATT_FILE_NEW_FULL_NAME] = substr($file, $start);
- $zipfiles[] = $tf;
- }
- //create the archive
- $archive = new PclZip(cleardoubleslashes("$destpath/$destfilename"));
- if (($list = $archive->create($zipfiles) == 0)) {
- notice($archive->errorInfo(true));
- return false;
- }
-
- } else { // Use external zip program
-
- $filestozip = "";
- foreach ($files as $filetozip) {
- $filestozip .= escapeshellarg(basename($filetozip));
- $filestozip .= " ";
- }
- //Construct the command
- $separator = strtoupper(substr(PHP_OS, 0, 3)) === 'WIN' ? ' &' : ' ;';
- $command = 'cd '.escapeshellarg($origpath).$separator.
- escapeshellarg($CFG->zip).' -r '.
- escapeshellarg(cleardoubleslashes("$destpath/$destfilename")).' '.$filestozip;
- //All converted to backslashes in WIN
- if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
- $command = str_replace('/','\\',$command);
- }
- Exec($command);
- }
- return true;
-}
-
-/**
- * This function is used as callback in unzip_file() function
- * to clean illegal characters for given platform and to prevent directory traversal.
- * Produces the same result as info-zip unzip.
- */
-function unzip_cleanfilename ($p_event, &$p_header) {
- $p_header['filename'] = ereg_replace('[[:cntrl:]]', '', $p_header['filename']); //strip control chars first!
- $p_header['filename'] = ereg_replace('\.\.+', '', $p_header['filename']); //directory traversal protection
- if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
- $p_header['filename'] = ereg_replace('[:*"?<>|]', '_', $p_header['filename']); //replace illegal chars
- $p_header['filename'] = ereg_replace('^([a-zA-Z])_', '\1:', $p_header['filename']); //repair drive letter
- } else {
- //Add filtering for other systems here
- // BSD: none (tested)
- // Linux: ??
- // MacosX: ??
- }
- $p_header['filename'] = cleardoubleslashes($p_header['filename']); //normalize the slashes/backslashes
- return 1;
-}
-
-/**
- * This function shows the results of the unzip execution
- * depending of the value of the $CFG->zip, results will be
- * text or an array of files.
- */
-function unzip_show_status ($list,$removepath) {
- global $CFG;
-
- if (empty($CFG->unzip)) { // Use built-in php-based zip function
- $strname = get_string("name");
- $strsize = get_string("size");
- $strmodified = get_string("modified");
- $strstatus = get_string("status");
- echo "";
- echo "";
- echo "";
- echo "";
- echo "
";
- foreach ($list as $item) {
- echo "";
- $item['filename'] = str_replace(cleardoubleslashes($removepath).'/', "", $item['filename']);
- print_cell("left", s($item['filename']));
- if (! $item['folder']) {
- print_cell("right", display_size($item['size']));
- } else {
- echo " | ";
- }
- $filedate = userdate($item['mtime'], get_string("strftimedatetime"));
- print_cell("right", $filedate);
- print_cell("right", $item['status']);
- echo "
";
- }
- echo "
";
-
- } else { // Use external zip program
- print_simple_box_start("center");
- echo "";
- foreach ($list as $item) {
- echo s(str_replace(cleardoubleslashes($removepath.'/'), '', $item)).'
';
- }
- echo "
";
- print_simple_box_end();
- }
-}
-
/**
* Is current ip in give list?
* @param string $list
diff --git a/version.php b/version.php
index e23105522ca..140b17fbebc 100644
--- a/version.php
+++ b/version.php
@@ -6,7 +6,7 @@
// This is compared against the values stored in the database to determine
// whether upgrades should be performed (see lib/db/*.php)
- $version = 2008080400; // YYYYMMDD = date of the last version bump
+ $version = 2008080401; // YYYYMMDD = date of the last version bump
// XX = daily increments
$release = '2.0 dev (Build: 20080804)'; // Human-friendly version name