2017-08-04 16:28:16 +02:00
< ? php
include_once __DIR__ . '/../../core.php' ;
2018-09-20 12:05:22 +02:00
$backup_dir = Backup :: getDirectory ();
2017-08-04 16:28:16 +02:00
switch ( filter ( 'op' )) {
case 'getfile' :
2019-05-29 05:19:15 +02:00
$number = filter ( 'number' );
$number = intval ( $number );
2017-08-04 16:28:16 +02:00
2019-05-29 05:19:15 +02:00
$backups = Backup :: getList ();
$backup = $backups [ $number ];
$filename = basename ( $backup );
download ( $backup , $filename );
2017-08-04 16:28:16 +02:00
break ;
case 'del' :
2019-05-29 05:19:15 +02:00
$number = filter ( 'number' );
$number = intval ( $number );
$backups = Backup :: getList ();
$backup = $backups [ $number ];
$filename = basename ( $backup );
2017-09-11 17:49:03 +02:00
2019-05-29 05:19:15 +02:00
delete ( $backup );
2017-08-04 16:28:16 +02:00
2019-05-29 05:19:15 +02:00
if ( ! file_exists ( $backup )) {
2018-07-19 17:29:21 +02:00
flash () -> info ( tr ( 'Backup _FILE_ eliminato!' , [
2019-05-29 05:19:15 +02:00
'_FILE_' => '"' . $filename . '"' ,
2018-07-07 13:56:22 +02:00
]));
2017-08-04 16:28:16 +02:00
} else {
2018-07-19 17:29:21 +02:00
flash () -> error ( tr ( " Errore durante l'eliminazione del backup _FILE_! " , [
2019-05-29 05:19:15 +02:00
'_FILE_' => '"' . $filename . '"' ,
2018-07-07 13:56:22 +02:00
]));
2017-08-04 16:28:16 +02:00
}
break ;
case 'backup' :
2018-03-03 15:03:28 +01:00
if ( Backup :: create ()) {
2018-07-19 17:29:21 +02:00
flash () -> info ( tr ( 'Nuovo backup creato correttamente!' ));
2017-09-12 17:59:30 +02:00
} 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!' )));
2017-08-04 16:28:16 +02:00
}
2019-02-09 14:44:30 +01:00
break ;
case 'size' :
2019-05-29 05:19:15 +02:00
$number = filter ( 'number' );
$number = intval ( $number );
2019-02-09 14:44:30 +01:00
2019-05-29 05:19:15 +02:00
$backups = Backup :: getList ();
$backup = $backups [ $number ];
$filename = basename ( $backup );
echo Util\FileSystem :: size ( $backup );
2019-02-09 14:44:30 +01:00
2017-08-04 16:28:16 +02:00
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 ;
}
2019-05-29 05:19:15 +02:00
if ( filter ( 'number' ) == null ) {
$path = $_FILES [ 'blob' ][ 'tmp_name' ];
2018-09-19 16:02:15 +02:00
} else {
2019-05-29 05:19:15 +02:00
$number = filter ( 'number' );
$number = intval ( $number );
$backups = Backup :: getList ();
$path = $backups [ $number ];
2018-09-19 16:02:15 +02:00
}
2019-05-29 05:19:15 +02:00
Backup :: restore ( $path , is_file ( $path ));
2018-10-02 18:39:12 +02:00
flash () -> info ( tr ( 'Backup ripristinato correttamente!' ));
2018-09-19 16:02:15 +02:00
}