//Check site
if (!$site = get_site()) {
- error("Site noto found!");
+ error("Site not found!");
}
//Check backup_version
- if ($CFG->backup_version) {
- if ($backup_version > $CFG->backup_version) { // upgrade
- $a->oldversion = $CFG->backup_version;
- $a->newversion = $backup_version;
- $strdatabasechecking = get_string("databasechecking", "", $a);
- $strdatabasesuccess = get_string("databasesuccess");
- print_header($strdatabasechecking, $strdatabasechecking, $strdatabasechecking);
- print_heading($strdatabasechecking);
- $db->debug=true;
- if (backup_upgrade($a->oldversion)) {
- $db->debug=false;
- if (set_config("backup_version", $a->newversion)) {
- notify($strdatabasesuccess, "green");
- notify("You are running Backup/Recovery version ".$backup_release,"black");
- print_continue("backup.php");
- die;
- } else {
- notify("Upgrade failed! (Could not update version in config table)");
- die;
- }
- } else {
- $db->debug=false;
- notify("Upgrade failed! See backup_version.php");
- die;
- }
- } else if ($backup_version < $CFG->backup_version) {
- notify("WARNING!!! The code you are using is OLDER than the version that made these databases!");
- }
- //Not exists. Starting installation
- } else {
- $strdatabaseupgrades = get_string("databaseupgrades");
- print_header($strdatabaseupgrades, $strdatabaseupgrades, $strdatabaseupgrades);
-
- if (set_config("backup_version", "2003010100")) {
- print_heading("You are currently going to install the needed structures to Backup/Recover");
- print_continue("backup.php");
- die;
- }
- }
+ upgrade_backup_db($backup_version,$backup_release,"backup.php");
//Get strings
$strcoursebackup = get_string("coursebackup");
print_simple_box_end();
} else {
print_heading(get_string("nocoursesyet"));
- print_continue("../$CFG->admin/index.php");
+ print_continue("$moodle_home/$CFG->admin/index.php");
}
print_footer();
exit;
$filelist = list_directories_and_files ($basedir);
if (empty($CFG->zip)) { // Use built-in php-based zip function
- $files = array();
- foreach ($filelist as $file) {
- //If directory, append "/"
- if (is_dir($basedir."/".$file)) {
- $file = $file."/";
- }
- //Include into array
- $files[] = $basedir."/".$file;
- }
- include_once($moodle_home."/lib/pclzip/pclzip.lib.php");
- $archive = new PclZip("$basedir/$name");
- if (($list = $archive->create($files,PCLZIP_OPT_REMOVE_PATH,$basedir)) == 0) {
- error($archive->errorInfo(true));
- $status = false;
- }
- //Debug zip contents
- //true->do it, false->don't do it. To debug if necessary.
- if (false) {
- echo "<br>";
- $list = $archive->listContent();
- for ($i=0; $i<sizeof($list); $i++) {
- for(reset($list[$i]); $key = key($list[$i]); next($list[$i])) {
- echo "File $i / [$key] = ".$list[$i][$key]."<br>";
- }
- echo "<br>";
- }
- }
- } else { // Use external zip program
- $files = "";
- foreach ($filelist as $file) {
- $files .= basename($file);
- $files .= " ";
- }
- $command = "cd $basedir ; $CFG->zip -r $name $files";
- $status = Exec($command);
+ $files = array();
+ foreach ($filelist as $file) {
+ //If directory, append "/"
+ if (is_dir($basedir."/".$file)) {
+ $file = $file."/";
}
+ //Include into array
+ $files[] = $basedir."/".$file;
+ }
+ include_once($moodle_home."/lib/pclzip/pclzip.lib.php");
+ $archive = new PclZip("$basedir/$name");
+ if (($list = $archive->create($files,PCLZIP_OPT_REMOVE_PATH,$basedir)) == 0) {
+ error($archive->errorInfo(true));
+ $status = false;
+ }
+ } else { // Use external zip program
+ $files = "";
+ foreach ($filelist as $file) {
+ $files .= basename($file);
+ $files .= " ";
+ }
+ $command = "cd $basedir ; $CFG->zip -r $name $files";
+ $status = Exec($command);
+ }
return $status;
///Ends copy file/dirs functions
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+ //This function upgrades, if necesary, the backup-restore tables
+ //It's called from backup.php and restore.php
+ function upgrade_backup_db($updgradeto,$backup_release,$continueto) {
+
+ global $CFG,$db;
+
+ //Check backup_version
+ if ($CFG->backup_version) {
+ if ($updgradeto > $CFG->backup_version) { // upgrade
+ $a->oldversion = $CFG->backup_version;
+ $a->newversion = $updgradeto;
+ $strdatabasechecking = get_string("databasechecking", "", $a);
+ $strdatabasesuccess = get_string("databasesuccess");
+ print_header($strdatabasechecking, $strdatabasechecking, $strdatabasechecking);
+ print_heading($strdatabasechecking);
+ $db->debug=true;
+ if (backup_upgrade($a->oldversion)) {
+ $db->debug=false;
+ if (set_config("backup_version", $a->newversion)) {
+ notify($strdatabasesuccess, "green");
+ notify("You are running Backup/Recovery version ".$backup_release,"black");
+ print_continue($continueto);
+ die;
+ } else {
+ notify("Upgrade failed! (Could not update version in config table)");
+ die;
+ }
+ } else {
+ $db->debug=false;
+ notify("Upgrade failed! See backup_version.php");
+ die;
+ }
+ } else if ($updgradeto < $CFG->backup_version) {
+ notify("WARNING!!! The code you are using is OLDER than the version that made these databases!");
+ }
+ //Not exists. Starting installation
+ } else {
+ $strdatabaseupgrades = get_string("databaseupgrades");
+ print_header($strdatabaseupgrades, $strdatabaseupgrades, $strdatabaseupgrades);
+
+ if (set_config("backup_version", "2003010100")) {
+ print_heading("You are currently going to install the needed structures to Backup/Recover");
+ print_continue($continue_to);
+ die;
+ }
+ }
+ }
?>