]> git.mjollnir.org Git - moodle.git/commitdiff
Use of cleardoubleslashes() added to the backup and restore functions.
authorstronk7 <stronk7>
Sat, 9 Oct 2004 23:19:53 +0000 (23:19 +0000)
committerstronk7 <stronk7>
Sat, 9 Oct 2004 23:19:53 +0000 (23:19 +0000)
They will be changed to calls to new, central zip and unzip functions.
(coming soon)

Merged from MOODLE_14_STABLE

backup/backuplib.php
backup/restorelib.php

index 8015e9a12d53ca5e8cc197376b0b1a7d0a393456..6b580966cfd7a250c8cb55d81c4806ea33ac3ece 100644 (file)
@@ -1,4 +1,4 @@
-<?PHP //$Id$
+<?php //$Id$
     //This file contains all the function needed in the backup utility
     //except the mod-related funtions that are into every backuplib.php inside
     //every mod directory
         $status = true;
 
         //Base dir where everything happens
-        $basedir = $CFG->dataroot."/temp/backup/".$preferences->backup_unique_code;
+        $basedir = cleardoubleslashes($CFG->dataroot."/temp/backup/".$preferences->backup_unique_code);
         //Backup zip file name
         $name = $preferences->backup_name;
         //List base_dir files and directories
                 //}
                 //Include into array
                 //echo "<br />Adding file/dir ".$file;                       //Debug
-                $files[] = $basedir."/".$file;
+                $files[] = cleardoubleslashes($basedir."/".$file);
             }
             include_once("$CFG->dirroot/lib/pclzip/pclzip.lib.php");
             //include_once("$CFG->dirroot/lib/pclzip/pclerror.lib.php");   //Debug
             //include_once("$CFG->dirroot/lib/pclzip/pcltrace.lib.php");   //Debug
             //PclTraceOn(2);                                               //Debug
-            $archive = new PclZip("$basedir/$name");
-            if (($list = $archive->create($files,PCLZIP_OPT_REMOVE_PATH,$basedir)) == 0) {
+            $archive = new PclZip(cleardoubleslashes("$basedir/$name"));
+            if (($list = $archive->create($files,PCLZIP_OPT_REMOVE_PATH,rtrim(cleardoubleslashes($basedir), "/"))) == 0) {
                 error($archive->errorInfo(true));
                 $status = false;
             } 
index 6b5d485ef0b3866f4c8bb97ad6a676b8a7c89e10..e118b86c410d7c5a239a017c9b0262d804059d81 100644 (file)
@@ -14,8 +14,8 @@
             //include_once("$CFG->dirroot/lib/pclzip/pclerror.lib.php");    //Debug
             //include_once("$CFG->dirroot/lib/pclzip/pcltrace.lib.php");    //Debug
             //PclTraceOn(2);                                          //Debug
-            $archive = new PclZip($file);
-            if (!$list = $archive->extract(dirname($file))) {
+            $archive = new PclZip(cleardoubleslashes($file));
+            if (!$list = $archive->extract(PCLZIP_OPT_PATH, cleardoubleslashes(dirname($file)))) {
                 $status = false;
             }
             //PclTraceDisplay();                                       //Debug