backup list and backup download (.sql)

This commit is contained in:
Ricsi
2017-02-23 23:32:02 +01:00
parent 7096af6df3
commit 9440072ee0
9 changed files with 217 additions and 1 deletions

View File

@@ -136,6 +136,26 @@ switch ($this->get_id()) {
case 'money_expense_category':
# ÚJ KIADÁS KATEGÓRIA
$smarty->display('money_expense_category_create.tpl');
break;
case 'backup':
# BACKUP
//létrehozzá, és hozzáfűzi az ID-t a dátumhoz
//visszatér a backup oldalra
//backup classből hívogat, statikusan
$new_bu_id = $sql->insert_into('backup', array('bu_date' => date('Y-m-d')));
$sql->update_table('backup', array('bu_name' => date('Ymd') . '_' . $new_bu_id), array('bu_id' => $new_bu_id));
//log
$dump_content = $sql->export_database();
$file_name = date('Ymd') . '_' . $new_bu_id . '.sql';
$path = 'backup/';
touch($path.$file_name);
file_put_contents($path.$file_name, $dump_content);
header("Location: /admin/settings/3");
break;
default:
# code...

View File

@@ -0,0 +1,35 @@
<?php
# BACKUP DOWNLOAD
if ($this->is_id()) {
$backup = new backup();
$backup->set_backup_data_by_id($this->get_id());
$filename = "\backup\/".$backup->get_bu_name() . "\.sql";
header('Content-Type: application/octet-stream');
header("Content-Transfer-Encoding: Binary");
//header("Content-disposition: attachment; filename='backup/".$backup->get_bu_name().".sql'");
//header("Content-disposition: attachment; filename=\"backup/".$backup->get_bu_name().".sql\"");
header("Content-disposition: attachment; filename=\"".$filename."\"");
//var_dump(is_file("backup/".$backup->get_bu_name() . ".sql"));
//header('Location: /admin/settings/3');
}
else {
# NEM LEHET
}
?>

View File

@@ -17,6 +17,22 @@ if ($this->is_id()) {
$new_setting = new setting_value();
$new_setting->set_setting_value_data_by_id($this->get_id());
if ($new_setting->get_setv_setting()->get_set_setting_type_st_id() == 1) {
//textarea
}
elseif ($new_setting->get_setv_setting()->get_set_setting_type_st_id() == 2) {
//biztonsági mentés
$backup_assoc_array = $sql->assoc_array("SELECT * FROM backup ORDER BY bu_date DESC, bu_id DESC limit 14;");
$backups = array();
foreach ($backup_assoc_array as $value) {
$new_backup = new backup();
$new_backup->set_backup_data_by_id($value['bu_id']);
$backups[] = $new_backup;
}
$smarty->assign('backups', $backups);
}
$smarty->assign("setting", $new_setting);