1
0
mirror of https://github.com/devcode-it/openstamanager.git synced 2024-12-27 08:12:47 +01:00
openstamanager/modules/backups/actions.php

61 lines
1.6 KiB
PHP
Raw Normal View History

<?php
include_once __DIR__.'/../../core.php';
2018-09-20 12:05:22 +02:00
$backup_dir = Backup::getDirectory();
switch (filter('op')) {
case 'getfile':
$file = filter('file');
2018-11-02 13:18:32 +01:00
download($backup_dir.'/'.$file, $file);
break;
case 'del':
$file = filter('file');
2018-11-02 13:18:32 +01:00
delete($backup_dir.'/'.$file);
2018-11-02 13:18:32 +01:00
if (!file_exists($backup_dir.'/'.$file)) {
2018-07-19 17:29:21 +02:00
flash()->info(tr('Backup _FILE_ eliminato!', [
'_FILE_' => '"'.$file.'"',
]));
} else {
2018-07-19 17:29:21 +02:00
flash()->error(tr("Errore durante l'eliminazione del backup _FILE_!", [
'_FILE_' => '"'.$file.'"',
]));
}
break;
case 'backup':
if (Backup::create()) {
2018-07-19 17:29:21 +02:00
flash()->info(tr('Nuovo backup creato correttamente!'));
} else {
2019-01-02 14:15:16 +01:00
flash()->error(tr('Errore durante la creazione del backup!').' '.str_replace('_DIR_', '"'.$backup_dir.'"', tr('Verifica che la cartella _DIR_ abbia i permessi di scrittura!')));
}
break;
}
2018-09-19 16:02:15 +02:00
if (filter('op') == 'restore') {
if (!extension_loaded('zip')) {
flash()->error(tr('Estensione zip non supportata!').'<br>'.tr('Verifica e attivala sul tuo file _FILE_', [
'_FILE_' => '<b>php.ini</b>',
]));
return;
}
if (post('folder') == null) {
2018-09-19 16:51:37 +02:00
$path = $_FILES['blob']['tmp_name'] ?: $backup_dir.'/'.post('zip');
2018-09-19 16:02:15 +02:00
} else {
2018-09-19 16:51:37 +02:00
$path = $backup_dir.'/'.post('folder');
2018-09-19 16:02:15 +02:00
}
2018-09-19 16:51:37 +02:00
Backup::restore($path, post('folder') == null);
2018-10-02 18:39:12 +02:00
flash()->info(tr('Backup ripristinato correttamente!'));
2018-09-19 16:02:15 +02:00
}