X-Git-Url: https://delta.frontaccounting.com/gitweb/?a=blobdiff_plain;f=admin%2Fbackups.php;h=155d9334d8fd0cdb992c18f1d9ddc64470df1317;hb=fe1f5b5e9c57ff544939158bab7334cc77ce2169;hp=9796a492ce5c442ba79cd9dc5b71678aa9284b6c;hpb=8ec550e70dfd4b89e5f3a00f27e1d4768d2a0daf;p=fa-stable.git
diff --git a/admin/backups.php b/admin/backups.php
index 9796a492..155d9334 100644
--- a/admin/backups.php
+++ b/admin/backups.php
@@ -1,5 +1,14 @@
.
+***********************************************************************/
$page_security = 15;
$path_to_root="..";
@@ -18,7 +27,7 @@ if ($valid_paths != "")
}
$db_name = $_SESSION["wa_current_user"]->company;
-$msg = handle_form($db_connections[$db_name]);
+handle_form($db_connections[$db_name]);
page(_("Backup and Restore Database"), false, false, '', '', true);
@@ -31,11 +40,13 @@ $compr = get_compr_combo();
echo "
- $msg |
" . _("Backup scripts") . " |
@@ -109,92 +120,75 @@ end_page();
function handle_form($conn)
{
- global $path_to_root;
- //Generate Only
- if (isset($_GET['c']))
+if(isset($_GET['c']))
+ switch($_GET['c'])
{
- if ($_GET['c']=='g')
- {
+ case 'g': //Generate Only
$filename = generate_backup($conn, $_GET['comp'], $_GET['comm']);
header("Location: backups.php?c=gs&fn=" . urlencode($filename));
- return "";
- }
- //Generate and download
- if ($_GET['c']=='gd')
- {
+ break;
+
+ case 'gd': //Generate and download
$filename = generate_backup($conn);
header("Location: backups.php?c=ds&fn=" . urlencode($filename));
- return "";
- }
- //Download the file
- if ($_GET['c']=='d')
- {
+ break;
+
+ case 'd': //Download the file
download_file(BACKUP_PATH . $_GET['fn']);
exit;
- }
- //Delete the file
- if ($_GET['c']=='df')
- {
+
+ case 'df': //Delete the file
$filename = $_GET['fn'];
@unlink(BACKUP_PATH . $filename);
header("Location: backups.php?c=dff&fn=" . urlencode($filename));
- return "";
- }
- if ($_GET['c']=='dff')
- {
- $msg = _("File successfully deleted.")." ";
+ break;
+
+ case 'dff':
+ $msg = _("File successfully deleted.")." ";
$msg .= _("Filename") . " = " . $_GET['fn'];
- return $msg;
- }
- //Write JS script to open download window
- if ($_GET['c']=='ds')
- {
+ display_notification($msg);
+ break;
+
+ case 'ds': //Write JS script to open download window
$filename = urlencode($_GET['fn']);
- $msg = _("Backup is being downloaded...");
- $msg .= "";
- return $msg;
- }
- //Print backup success message
- if ($_GET['c']=='gs')
- {
- $msg = _("Backup successfully generated.")." ";
+ display_notification(_("Backup is being downloaded..."));
+
+ add_js_source("");
+ break;
+
+ case 'gs': //Print backup success message
+ $msg = _("Backup successfully generated."). ' ';
$msg .= _("Filename") . " = " . $_GET['fn'];
- return $msg;
- }
- //Restore backup
- if ($_GET['c']=='r')
- {
+ display_notification($msg);
+ break;
+
+ case 'r': //Restore backup
$filename=$_GET['fn'];
- restore_backup(BACKUP_PATH . $filename, $conn);
- header("Location: backups.php?c=rs&fn=" . urlencode($filename));
- return "";
- }
- //Print restore success message
- if ($_GET['c']=='rs')
- {
- $msg = _("Restore backup completed.")." ";
- return $msg;
- }
+ if( restore_backup(BACKUP_PATH . $filename, $conn) )
+ header("Location: backups.php?c=rs&fn=" . urlencode($filename));
+ break;
- if ($_GET['c']=='u')
- {
+ case 'rs': //Print restore success message
+ display_notification(_("Restore backup completed."));
+ break;
+
+ case 'u':
$filename = $_FILES['uploadfile']['tmp_name'];
if (is_uploaded_file ($filename))
{
- restore_backup($filename, $conn);
- $msg = _("Uploaded file has been restored.");
+ if( restore_backup($filename, $conn) )
+ display_notification(_("Uploaded file has been restored."));
+ else
+ display_error(_("Database restore failed."));
}
else
{
- $msg = _("Backup was not uploaded into the system.");
+ display_error(_("Backup was not uploaded into the system."));
}
- return $msg;
}
- }
- return "";
}
function generate_backup($conn, $ext='no', $comm='')
@@ -253,7 +247,7 @@ function download_file($filename)
{
if (empty($filename) || !file_exists($filename))
{
- return FALSE;
+ return false;
}
$saveasname = basename($filename);
header('Content-type: application/octet-stream');