.
*/
include_once __DIR__.'/../../core.php';
switch (filter('op')) {
case 'getfile':
$number = filter('number');
$number = intval($number);
$backups = Backup::getList();
$backup = $backups[$number];
$filename = basename($backup);
download($backup, $filename);
break;
case 'del':
$number = filter('number');
$number = intval($number);
$backups = Backup::getList();
$backup = $backups[$number];
$filename = basename($backup);
delete($backup);
if (!file_exists($backup)) {
flash()->info(tr('Backup _FILE_ eliminato!', [
'_FILE_' => '"'.$filename.'"',
]));
} else {
flash()->error(tr("Errore durante l'eliminazione del backup _FILE_!", [
'_FILE_' => '"'.$filename.'"',
]));
}
break;
case 'backup':
$ignores = ['dirs' => [], 'files' => []];
if (filter('exclude') == 'exclude_attachments'){
$ignores = ['dirs' => ['files']];
}else if (filter('exclude') == 'only_database'){
$ignores = ['dirs' => ['vendor','update','templates','src','plugins','modules','logs','locale','lib','include','files','config','assets','api'], 'files' => ['*.php','*.md','*.json','*.js','*.xml','.*']];
}
try {
$result = Backup::create($ignores);
if ($result) {
flash()->info(tr('Nuovo backup creato correttamente!'));
} else {
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!')));
}
} catch (Exception $e) {
flash()->error(tr('Errore durante la creazione del backup!').' '.$e->getMessage());
}
break;
case 'size':
$number = filter('number');
$number = intval($number);
$backups = Backup::getList();
$backup = $backups[$number] ?: $backup_dir;
echo Util\FileSystem::size($backup);
break;
}
if (filter('op') == 'restore') {
if (!extension_loaded('zip')) {
flash()->error(tr('Estensione zip non supportata!').'
'.tr('Verifica e attivala sul tuo file _FILE_', [
'_FILE_' => 'php.ini',
]));
return;
}
if (filter('number') == null) {
$path = $_FILES['blob']['tmp_name'];
} else {
$number = filter('number');
$number = intval($number);
$backups = Backup::getList();
$path = $backups[$number];
}
Backup::restore($path, is_file($path));
$database->beginTransaction();
}