X-Git-Url: https://delta.frontaccounting.com/gitweb/?a=blobdiff_plain;f=admin%2Fbackups.php;h=9796a492ce5c442ba79cd9dc5b71678aa9284b6c;hb=f1a6302759ae11aab99e3e4b4d37f2d3e1e1c368;hp=dd73be6d899ef0d73ba8974255dfdb95e1bd5eb6;hpb=da8311619dd73feae101d246a1957b972e00cbd2;p=fa-stable.git
diff --git a/admin/backups.php b/admin/backups.php
index dd73be6d..9796a492 100644
--- a/admin/backups.php
+++ b/admin/backups.php
@@ -9,7 +9,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);
@@ -20,7 +20,7 @@ if ($valid_paths != "")
$db_name = $_SESSION["wa_current_user"]->company;
$msg = handle_form($db_connections[$db_name]);
-page(_("Backup and Restore Database"));
+page(_("Backup and Restore Database"), false, false, '', '', true);
//-------------------------------------------------------------------------------
start_form(true, true);
@@ -45,8 +45,8 @@ echo "
if (ext != 'sql') {
alert('" . _('This extension can not be be viewed: ') . "' + ext)
return
- }
- window.open('" . $path_to_root . BACKUP_PATH . "'+pFilename, '', 'toolbar=no,scrollbars=yes')
+ }
+ window.open('" . BACKUP_PATH . "'+pFilename, '', 'toolbar=no,scrollbars=yes')
}
function deleteBackup() {
pFilename = document.forms[0].cmb_backups.options[document.forms[0].cmb_backups.selectedIndex].value
@@ -57,6 +57,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=='') {
@@ -71,31 +72,31 @@ echo "
$msg |
- " . _("Backup scripts") . " |
+ " . _("Backup scripts") . " |
- $cmb |
+ $cmb |
|
- " . _("Comments") . " (" . _("Create Backup") . ") |
+ " . _("Comments") . " (" . _("Create Backup") . ") |
- |
+ |
";
@@ -106,118 +107,119 @@ end_form();
end_page();
-function handle_form($conn)
+function handle_form($conn)
{
global $path_to_root;
//Generate Only
if (isset($_GET['c']))
{
- if ($_GET['c']=='g')
+ if ($_GET['c']=='g')
{
$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')
+ if ($_GET['c']=='gd')
{
$filename = generate_backup($conn);
header("Location: backups.php?c=ds&fn=" . urlencode($filename));
return "";
}
//Download the file
- if ($_GET['c']=='d')
+ if ($_GET['c']=='d')
{
- download_file($path_to_root . BACKUP_PATH . $_GET['fn']);
+ download_file(BACKUP_PATH . $_GET['fn']);
exit;
}
//Delete the file
- if ($_GET['c']=='df')
+ if ($_GET['c']=='df')
{
$filename = $_GET['fn'];
- @unlink($path_to_root . BACKUP_PATH . $filename);
+ @unlink(BACKUP_PATH . $filename);
header("Location: backups.php?c=dff&fn=" . urlencode($filename));
return "";
}
- if ($_GET['c']=='dff')
+ if ($_GET['c']=='dff')
{
$msg = _("File successfully deleted.")." ";
$msg .= _("Filename") . " = " . $_GET['fn'];
return $msg;
}
//Write JS script to open download window
- if ($_GET['c']=='ds')
+ if ($_GET['c']=='ds')
{
$filename = urlencode($_GET['fn']);
$msg = _("Backup is being downloaded...");
$msg .= "";
return $msg;
}
//Print backup success message
- if ($_GET['c']=='gs')
+ if ($_GET['c']=='gs')
{
$msg = _("Backup successfully generated.")." ";
$msg .= _("Filename") . " = " . $_GET['fn'];
return $msg;
}
//Restore backup
- if ($_GET['c']=='r')
+ if ($_GET['c']=='r')
{
$filename=$_GET['fn'];
- restore_backup($path_to_root . BACKUP_PATH . $filename, $conn);
+ restore_backup(BACKUP_PATH . $filename, $conn);
header("Location: backups.php?c=rs&fn=" . urlencode($filename));
return "";
}
//Print restore success message
- if ($_GET['c']=='rs')
+ if ($_GET['c']=='rs')
{
$msg = _("Restore backup completed.")." ";
return $msg;
}
- if ($_GET['c']=='u')
+ if ($_GET['c']=='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
+ }
+ else
{
$msg = _("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();
-
- $dh = opendir($path_to_root . BACKUP_PATH);
+ default_focus('cmb_backups');
+ $dh = opendir(BACKUP_PATH);
while (($file = readdir($dh)) !== false)
$ar_files[] = $file;
closedir($dh);
@@ -225,31 +227,31 @@ 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;
}
@@ -261,13 +263,13 @@ function download_file($filename)
return true;
}
-function valid_paths()
+function valid_paths()
{
global $path_to_root;
-
+
$st = "";
- if (!file_exists($path_to_root . BACKUP_PATH))
- $st .= " - " . _("cannot find backup directory") . " - " . $path_to_root . BACKUP_PATH . "
";
+ if (!file_exists(BACKUP_PATH))
+ $st .= " - " . _("cannot find backup directory") . " - " . BACKUP_PATH . "
";
return $st;
}