mirror of
https://github.com/monstra-cms/monstra.git
synced 2025-08-10 07:06:53 +02:00
Add Monstra from HG Commit 683dcb70c4cc
This commit is contained in:
60
plugins/box/backup/backup.admin.php
Normal file
60
plugins/box/backup/backup.admin.php
Normal file
@@ -0,0 +1,60 @@
|
||||
<?php
|
||||
|
||||
|
||||
class BackupAdmin extends Backend {
|
||||
|
||||
|
||||
/**
|
||||
* Backup admin
|
||||
*/
|
||||
public static function main() {
|
||||
|
||||
$backups_path = ROOT . DS . 'backups';
|
||||
|
||||
$backups_list = array();
|
||||
|
||||
// Create backup
|
||||
// -------------------------------------
|
||||
if (Request::post('create_backup')) {
|
||||
|
||||
@set_time_limit(0);
|
||||
@ini_set("memory_limit", "512M");
|
||||
|
||||
$zip = Zip::factory();
|
||||
|
||||
// Add storage folder
|
||||
$zip->readDir(STORAGE . DS, false);
|
||||
|
||||
// Add public folder
|
||||
if (Request::post('add_public_folder')) $zip->readDir(ROOT . DS . 'public' . DS, false);
|
||||
|
||||
// Add plugins folder
|
||||
if (Request::post('add_plugins_folder')) $zip->readDir(PLUGINS . DS, false);
|
||||
|
||||
$zip->archive($backups_path . DS . Date::format(time(), "Y-m-d-H-i-s").'.zip');
|
||||
}
|
||||
|
||||
// Delete backup
|
||||
// -------------------------------------
|
||||
if (Request::get('sub_id') == 'backup') {
|
||||
if (Request::get('delete_file')) {
|
||||
File::delete($backups_path . DS . Request::get('delete_file'));
|
||||
Request::redirect(Option::get('siteurl').'admin/index.php?id=backup');
|
||||
}
|
||||
}
|
||||
|
||||
// Download backup
|
||||
// -------------------------------------
|
||||
if (Request::get('download')) {
|
||||
File::download('../backups/'.Request::get('download'));
|
||||
}
|
||||
|
||||
// Get backup list
|
||||
$backups_list = File::scan($backups_path, '.zip');
|
||||
|
||||
// Display view
|
||||
View::factory('box/backup/views/backend/index')
|
||||
->assign('backups_list', $backups_list)
|
||||
->display();
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user