diff --git a/phpgwapi/inc/class.db_backup.inc.php b/phpgwapi/inc/class.db_backup.inc.php index 47edca6541..7ab9bcf73d 100644 --- a/phpgwapi/inc/class.db_backup.inc.php +++ b/phpgwapi/inc/class.db_backup.inc.php @@ -183,7 +183,7 @@ class db_backup } /** - * Opens the backup-file using the highest availible compression + * Opens the backup-file using the highest available compression * * @param $name=false string/boolean filename to use, or false for the default one * @param $reading=false opening for reading ('rb') or writing ('wb') @@ -216,7 +216,7 @@ class db_backup { $this->backup_files = false; //echo ' -> (new ZipArchive) == NULL
'; // ! - return lang("Cant open $name, needs ZipArchive")."
"; + return lang("Cant open %1, needs ZipArchive", $name)."
\n"; } if(!($f = fopen($name, $mode))) { @@ -336,6 +336,9 @@ class db_backup * * @param resource $f file opened with fopen for reading * @param boolean $convert_to_system_charset=false convert the restored data to the selected system-charset + * @param string $filename='' gives the file name which is used in case of a zip archive. + * + * @returns An empty string or an error message in case of failure. */ function restore($f,$convert_to_system_charset=false,$filename='') { @@ -370,10 +373,11 @@ class db_backup $_f = NULL; if($type == 'zip') { + // has already been verified to be available in fopen_backup $zip = new ZipArchive; if(($zip->open($filename)) !== TRUE) { - return "Cant open '$filename' for reading
"; + return lang("Cant open '%1' for %2", $filename, lang("reading"))."
\n"; } self::remove_dir_content($dir); // removes the files-dir $zip->extractTo($dir); @@ -383,6 +387,7 @@ class db_backup if(!($f = fopen($name, 'rb'))) { return "Cant open $name for reading
"; + return lang("Cant open '%1' for %2", $filename, lang("reading"))."
\n"; } } $table = False; @@ -520,7 +525,11 @@ class db_backup unlink($name); rmdir($dir.'/database_backup'); } - $this->db->transaction_commit(); + if (!$this->db->transaction_commit()) + { + return lang('Restore failed'); + } + return ''; } /** @@ -647,7 +656,7 @@ class db_backup if($res !== TRUE) { //echo ' -> !$res
'; // ! - return "Cant open '$filename'
"; + return lang("Cant open '%1' for %2", $filename, lang("writing"))."
\n"; } $file_list = $this->get_file_list($dir); } @@ -694,7 +703,11 @@ class db_backup } if(!$zippresent) // save without files { - if ($this->backup_files) echo '
'."No file backup, needs ZipArchive or disabled
".'
'; + if ($this->backup_files) + { + echo '
'.lang("Cant open %1, needs ZipArchive", $name)."
\n".'
'; + } + fclose($f); if (file_exists($name)) unlink($name); return TRUE; diff --git a/setup/inc/class.setup_cmd_install.inc.php b/setup/inc/class.setup_cmd_install.inc.php index 2860787b90..51dd41cb5b 100644 --- a/setup/inc/class.setup_cmd_install.inc.php +++ b/setup/inc/class.setup_cmd_install.inc.php @@ -89,7 +89,7 @@ class setup_cmd_install extends setup_cmd { ob_start(); // restore echos the table structure } - $db_backup->restore($f,$this->charset); + $db_backup->restore($f,$this->charset,$this->backup); fclose($f); if (!$this->verbose) diff --git a/setup/index.php b/setup/index.php index 14c2ff63e2..cb68b723a5 100644 --- a/setup/index.php +++ b/setup/index.php @@ -313,7 +313,7 @@ switch($GLOBALS['egw_info']['setup']['stage']['db']) if (is_resource($f = $db_backup->fopen_backup($_FILES['uploaded']['tmp_name'],true))) { echo '

'.lang('restore started, this might take a few minutes ...')."

\n".str_repeat(' ',4096); - $db_backup->restore($f,$_POST['convert_charset']); + $db_backup->restore($f,$_POST['convert_charset'],$_FILES['uploaded']['tmp_name']); fclose($f); echo '

'.lang('restore finished')."

\n"; unlink($_FILES['uploaded']['tmp_name']);