From 8380ec5b7dffdf7e2f06b36b263c5f5fc55b0068 Mon Sep 17 00:00:00 2001 From: metal_gvc Date: Sun, 9 Feb 2014 21:48:07 +0200 Subject: [PATCH] Restore Site from Backup #228 --- plugins/box/backup/backup.admin.php | 25 +++++++++++++++++++ .../box/backup/views/backend/index.view.php | 2 +- 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/plugins/box/backup/backup.admin.php b/plugins/box/backup/backup.admin.php index ab021e7..b70d56b 100755 --- a/plugins/box/backup/backup.admin.php +++ b/plugins/box/backup/backup.admin.php @@ -69,6 +69,31 @@ class BackupAdmin extends Backend } else { die('Request was denied because it contained an invalid security token. Please refresh the page and try again.'); } } + // Restore backup + // ------------------------------------- + if (Request::get('restore')) { + + if (Security::check(Request::get('token'))) { + + $tmp_dir = sys_get_temp_dir() . uniqid('monstra_'); + + if (Dir::create($tmp_dir)) { + $file_locations = Zip::factory()->extract($backups_path . DS . Request::get('restore'), $tmp_dir); + if (!empty($file_locations)) { + Dir::copy($tmp_dir, ROOT . DS); + Notification::set('success', __('Backup was restored', 'system')); + } else { + Notification::set('error', __('Unzip error', 'system')); + } + } else { + Notification::set('error', __('Backup was not restored', 'system')); + } + + Request::redirect(Option::get('siteurl').'/admin/index.php?id=backup'); + + } else { die('Request was denied because it contained an invalid security token. Please refresh the page and try again.'); } + } + // Display view View::factory('box/backup/views/backend/index') ->assign('backups_list', File::scan($backups_path, '.zip')) diff --git a/plugins/box/backup/views/backend/index.view.php b/plugins/box/backup/views/backend/index.view.php index ff70882..52ea138 100755 --- a/plugins/box/backup/views/backend/index.view.php +++ b/plugins/box/backup/views/backend/index.view.php @@ -47,7 +47,7 @@ $().ready(function(){$('[name=create_backup]').click(function(){$(this).button('
'btn btn-primary')); ?>