1
0
mirror of https://github.com/monstra-cms/monstra.git synced 2025-08-05 04:37:51 +02:00

Restore Site from Backup #228

This commit is contained in:
metal_gvc
2014-02-09 21:48:07 +02:00
parent 44c274cf8c
commit 8380ec5b7d
2 changed files with 26 additions and 1 deletions

View File

@@ -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'))

View File

@@ -47,7 +47,7 @@ $().ready(function(){$('[name=create_backup]').click(function(){$(this).button('
<td>
<div class="pull-right">
<?php echo Html::anchor(__('Restore', 'backup'),
'',
'index.php?id=backup&restore='.$backup.'&token='.Security::token(),
array('class' => 'btn btn-primary'));
?>
<?php echo Html::anchor(__('Delete', 'backup'),