X-Git-Url: https://delta.frontaccounting.com/gitweb/?a=blobdiff_plain;ds=sidebyside;f=admin%2Fbackups.php;h=76c595a4a36fdb67dbb96f619924e8d1ea6bb250;hb=a52f867bce2f8c73315f7b4a217aa43d5212416a;hp=e653757977360e8a2af23eaf32c78617f572773f;hpb=0b374a9cb65ebe32dbc17eac566e1d0ba92cb3ce;p=fa-stable.git
diff --git a/admin/backups.php b/admin/backups.php
index e6537579..76c595a4 100644
--- a/admin/backups.php
+++ b/admin/backups.php
@@ -18,7 +18,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);
@@ -70,7 +70,6 @@ echo "
- $msg |
" . _("Backup scripts") . " |
@@ -109,94 +108,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'];
if( 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;
- }
+ 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))
{
if( restore_backup($filename, $conn) )
- $msg = _("Uploaded file has been restored.");
+ display_notification(_("Uploaded file has been restored."));
else
- $msg = _("Database restore failed.");
+ 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='')
@@ -255,7 +235,7 @@ function download_file($filename)
{
if (empty($filename) || !file_exists($filename))
{
- return FALSE;
+ return false;
}
$saveasname = basename($filename);
header('Content-type: application/octet-stream');