X-Git-Url: https://delta.frontaccounting.com/gitweb/?a=blobdiff_plain;ds=sidebyside;f=admin%2Fbackups.php;h=8dfec9a138cb81723b12331aea12656578ff37cd;hb=032543e8bebfaf5ed19f8a8bad793893af497862;hp=3286f48c8600d4678a30fe211996e054a9c1002a;hpb=1273d798e494986d5d35b885ccbd0ccaaa0c2695;p=fa-stable.git
diff --git a/admin/backups.php b/admin/backups.php
index 3286f48c..8dfec9a1 100644
--- a/admin/backups.php
+++ b/admin/backups.php
@@ -1,5 +1,14 @@
.
+***********************************************************************/
$page_security = 15;
$path_to_root="..";
@@ -9,7 +18,7 @@ include_once($path_to_root . "/admin/db/maintenance_db.inc");
$valid_paths = valid_paths();
//$valid_paths = '';
-if ($valid_paths != "")
+if ($valid_paths != "")
{
page(_("Backup and Restore Database - Error"));
display_error (_("Backup paths have not been set correctly.") ." " . _("Please contact System Administrator.") . "
" .$valid_paths);
@@ -18,9 +27,9 @@ 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"));
+page(_("Backup and Restore Database"), false, false, '', '', true);
//-------------------------------------------------------------------------------
start_form(true, true);
@@ -45,7 +54,7 @@ echo "
if (ext != 'sql') {
alert('" . _('This extension can not be be viewed: ') . "' + ext)
return
- }
+ }
window.open('" . BACKUP_PATH . "'+pFilename, '', 'toolbar=no,scrollbars=yes')
}
function deleteBackup() {
@@ -57,6 +66,7 @@ echo "
function downloadBackup() {
pFilename = document.forms[0].cmb_backups.options[document.forms[0].cmb_backups.selectedIndex].value
document.location.replace('backups.php?c=ds&fn='+pFilename)
+ Behaviour.apply();
}
function uploadBackup() {
if (document.forms[0].uploadfile.value=='') {
@@ -69,33 +79,32 @@ echo "
- $msg |
- " . _("Backup scripts") . " |
+ " . _("Backup scripts") . " |
- $cmb |
+ $cmb |
|
- " . _("Comments") . " (" . _("Create Backup") . ") |
+ " . _("Comments") . " (" . _("Create Backup") . ") |
- |
+ |
";
@@ -106,117 +115,101 @@ end_form();
end_page();
-function handle_form($conn)
+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))
+ if (is_uploaded_file ($filename))
{
- restore_backup($filename, $conn);
- $msg = _("Uploaded file has been restored.");
- }
- else
+ 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='')
+function generate_backup($conn, $ext='no', $comm='')
{
if ($conn['tbpref'] != "")
$filename = $conn['dbname'] . "_" . $conn['tbpref'] . date("Ymd_Hi") . ".sql";
- else
+ else
$filename = $conn['dbname'] . "_" . date("Ymd_Hi") . ".sql";
-
- $filename = db_export($conn, $filename, $ext, $comm);
-
+
+ $filename = db_export($conn, $filename, $ext, $comm);
+
return $filename;
}
-function restore_backup($filename, $conn)
+function restore_backup($filename, $conn)
{
return db_import($filename, $conn);
-}
+}
-function get_backup_file_combo()
+function get_backup_file_combo()
{
global $path_to_root;
$ar_files = array();
-
+ default_focus('cmb_backups');
$dh = opendir(BACKUP_PATH);
while (($file = readdir($dh)) !== false)
$ar_files[] = $file;
@@ -225,33 +218,33 @@ function get_backup_file_combo()
rsort($ar_files);
$opt_files = "";
foreach ($ar_files as $file)
- if (strpos($file, ".sql") || strpos($file, ".sql"))
+ if (strpos($file, ".sql") || strpos($file, ".sql"))
$opt_files .= "";
- return "";
+ return "";
}
-function get_compr_combo()
+function get_compr_combo()
{
$ar_comps = array();
-
+
$ar_comps[] = _("No");
- if (function_exists("gzcompress"))
+ if (function_exists("gzcompress"))
$ar_comps[] = "zip";
- if (function_exists("gzopen"))
+ if (function_exists("gzopen"))
$ar_comps[] = "gzip";
$opt_comps = "";
foreach ($ar_comps as $file)
$opt_comps .= "";
return "";
-}
-
-function download_file($filename)
+}
+
+function download_file($filename)
{
- if (empty($filename) || !file_exists($filename))
+ if (empty($filename) || !file_exists($filename))
{
- return FALSE;
+ return false;
}
$saveasname = basename($filename);
header('Content-type: application/octet-stream');
@@ -261,12 +254,12 @@ function download_file($filename)
return true;
}
-function valid_paths()
+function valid_paths()
{
global $path_to_root;
-
+
$st = "";
- if (!file_exists(BACKUP_PATH))
+ if (!file_exists(BACKUP_PATH))
$st .= " - " . _("cannot find backup directory") . " - " . BACKUP_PATH . "
";
return $st;
}