2017-08-04 16:28:16 +02:00
< ? php
include_once __DIR__ . '/../../core.php' ;
2018-03-22 17:20:33 +01:00
echo '<p>' . tr ( 'Il backup è <b>molto importante</b> perché permette di creare una copia della propria installazione e relativi dati per poterla poi ripristinare in seguito a errori, cancellazioni accidentali o guasti hardware' ) . '.</p>' ;
2017-09-11 17:49:03 +02:00
if ( ! extension_loaded ( 'zip' )) {
echo "
< div class = 'alert alert-warning' >
2018-03-22 17:20:33 +01:00
< i class = 'fa fa-times' ></ i > " .tr('Estensione ZIP non supportata!').'
'.tr(' Il backup verrà eseguito , ma non in formato ZIP . Sarà quindi scaricabile solo tramite FTP o con copia - incolla ').' .
2017-09-11 17:49:03 +02:00
</ div > ' ;
}
2018-03-22 17:20:33 +01:00
if ( starts_with ( $backup_dir , $docroot )) {
echo '
< div class = " alert alert-warning " >
< i class = " fa fa-warning " ></ i > '.tr(' Per motivi di sicurezza si consiglia di modificare il percorso della cartella di backup al di fuori della cartella di OSM , possibilmente in una unità esterna ').' .
</ div > ' ;
}
if ( ! is_writable ( $backup_dir )) {
echo '
< div class = " alert alert-warning " >
< i class = " fa fa-warning " ></ i > '.tr(' La cartella di backup presente nella configurazione non è utilizzabile dal gestionale ').' .
'.tr(' Verificare che la cartella abbia i permessi di scrittura abilitati ').' .
</ div > ' ;
}
2017-09-11 17:49:03 +02:00
echo '
< div class = " callout callout-success " >
< p > ' ;
2017-08-04 16:28:16 +02:00
if ( ! empty ( $backup_dir )) {
2017-09-04 12:02:29 +02:00
echo tr ( 'Il percorso di backup è attualmente in' ) . ': <b>' . slashes ( $backup_dir ) . '</b>' ;
2017-08-04 16:28:16 +02:00
} else {
2017-09-04 12:02:29 +02:00
echo tr ( 'Sembra che tu non abbia ancora specificato un percorso per il backup' ) . '.' ;
2017-08-04 16:28:16 +02:00
}
2017-09-11 17:49:03 +02:00
2017-08-04 16:28:16 +02:00
echo '
2017-09-11 17:49:03 +02:00
</ p >
< p >< small > '.tr(' Puoi modificare il percorso di backup dal tuo file _FILE_ ' , [
'_FILE_' => '<b>config.inc.php</b>' ,
]) . '</small></p>' ;
2017-08-04 16:28:16 +02:00
echo '
2017-09-11 17:49:03 +02:00
</ div >
2017-08-04 16:28:16 +02:00
2017-09-11 17:49:03 +02:00
<!-- PULSANTI -->
2018-03-22 17:20:33 +01:00
<!-- div class = " row " >
2017-09-11 17:49:03 +02:00
< div class = " col-md-12 text-right " >
< button type = " button " class = " btn btn-primary pull-right " onclick = " continue_backup() " >< i class = " fa fa-database " ></ i > '.tr(' Crea backup ').' ...</ button >
</ div >
2018-03-22 17:20:33 +01:00
</ div --> ' ;
2017-09-12 17:59:30 +02:00
2017-08-04 16:28:16 +02:00
//Lettura file di backup
if ( file_exists ( $backup_dir )) {
$backups_zip = [];
$backups_file = [];
2018-03-03 15:03:28 +01:00
$backups = Backup :: getList ();
foreach ( $backups as $backup ) {
if ( ends_with ( $backup , '.zip' )) {
$backups_zip [] = $backup ;
} else {
$backups_file [] = $backup ;
2017-08-04 16:28:16 +02:00
}
}
if ( empty ( $backups_zip ) && empty ( $backups_file )) {
echo '
2017-09-11 17:49:03 +02:00
< div class = " alert alert-warning " >
< i class = " fa fa-warning " ></ i > '.tr(' Non è ancora stato trovato alcun backup ! ').'
'.tr(' Se hai già inserito dei dati su OSM crealo il prima possibile ... ').'
</ div > ' ;
2017-08-04 16:28:16 +02:00
} else {
2017-09-11 17:49:03 +02:00
echo '
< div class = " row " >
< div class = " col-xs-12 col-md-6 " >
< h3 > '.tr(' Backup compressi ').' </ h3 > ' ;
2017-08-04 16:28:16 +02:00
if ( ! empty ( $backups_zip )) {
foreach ( $backups_zip as $backup ) {
$name = basename ( $backup );
2018-03-03 15:03:28 +01:00
$info = Backup :: readName ( $backup );
2018-03-19 15:30:16 +01:00
$data = $info [ 'YYYY' ] . '-' . $info [ 'm' ] . '-' . $info [ 'd' ];
2018-03-03 15:03:28 +01:00
$ora = $info [ 'H' ] . ':' . $info [ 'i' ] . ':' . $info [ 's' ];
2017-09-07 18:58:41 +02:00
2017-08-04 16:28:16 +02:00
echo '
2017-09-11 17:49:03 +02:00
< div class = " callout callout-info " >
< h4 > '.tr(' Backup del _DATE_ alle _TIME_ ' , [
2018-03-03 15:03:28 +01:00
'_DATE_' => Translator :: dateToLocale ( $data ),
'_TIME_' => Translator :: timeToLocale ( $ora ),
2017-09-11 17:49:03 +02:00
]) . ' </ h4 >
< p >< small >
'.tr(' Nome del file ').' : '.$name.' < br >
'.tr(' Dimensione ').' : '.Translator::numberToLocale(filesize($backup) / 1024 / 1024).' MB
</ small ></ p >
2018-03-22 17:20:33 +01:00
< a class = " btn btn-primary " href = " '. $rootdir .'/modules/backup/actions.php?op=getfile&file='. $name .' " target = " _blank " >< i class = " fa fa-download " ></ i > '.tr(' Scarica ').' </ a >
2017-09-11 17:49:03 +02:00
< a class = " btn btn-danger ask pull-right " title = " '.tr('Elimina backup').' " data - backto = " record-list " data - op = " del " data - file = " '. $name .' " >
< i class = " fa fa-trash " ></ i >
</ a >
</ div > ' ;
2017-08-04 16:28:16 +02:00
}
2017-09-11 17:49:03 +02:00
} else {
echo '
< div class = " alert alert-warning " >
< i class = " fa fa-warning " ></ i > '.tr(' Non è stato trovato alcun backup di questa tipologia ! ').'
</ div > ' ;
2017-08-04 16:28:16 +02:00
}
2017-09-11 17:49:03 +02:00
echo '
</ div >
< div class = " col-xs-12 col-md-6 " >
< h3 > '.tr(' Backup non compressi ').' </ h3 > ' ;
2017-08-04 16:28:16 +02:00
// Backup non compressi e quindi non scaricabili
if ( ! empty ( $backups_file )) {
foreach ( $backups_file as $backup ) {
$name = basename ( $backup );
2018-03-03 15:03:28 +01:00
$info = Backup :: readName ( $backup );
2018-03-19 15:30:16 +01:00
$data = $info [ 'YYYY' ] . '-' . $info [ 'm' ] . '-' . $info [ 'd' ];
2018-03-03 15:03:28 +01:00
$ora = $info [ 'H' ] . ':' . $info [ 'i' ] . ':' . $info [ 's' ];
2017-09-08 13:24:48 +02:00
2017-08-04 16:28:16 +02:00
echo '
2017-09-11 17:49:03 +02:00
< div class = " callout callout-warning " >
< h4 > '.tr(' Backup del _DATE_ alle _TIME_ ' , [
2018-03-03 15:03:28 +01:00
'_DATE_' => Translator :: dateToLocale ( $data ),
'_TIME_' => Translator :: timeToLocale ( $ora ),
2017-09-11 17:49:03 +02:00
]) . ' </ h4 >
< p >< small >
'.tr(' Nome del file ').' : '.$name.' < br >
'.tr(' Dimensione ').' : '.Translator::numberToLocale(filesize($backup) / 1024 / 1024).' MB
</ small ></ p >
< a class = " btn btn-sm btn-warning disabled " href = " javascript:; " >< i class = " fa fa-times " ></ i > '.tr(' Non scaricabile ').' </ a >
< a class = " btn btn-danger ask pull-right " title = " '.tr('Elimina backup').' " data - backto = " record-list " data - op = " del " data - file = " '. $name .' " >
< i class = " fa fa-trash " ></ i >
</ a >
</ div > ' ;
2017-08-04 16:28:16 +02:00
}
2017-09-11 17:49:03 +02:00
} else {
echo '
< div class = " alert alert-warning " >
< i class = " fa fa-warning " ></ i > '.tr(' Non è stato trovato alcun backup di questa tipologia ! ').'
</ div > ' ;
2017-08-04 16:28:16 +02:00
}
2017-09-11 17:49:03 +02:00
echo '
</ div >
</ div > ' ;
2017-08-04 16:28:16 +02:00
}
} else {
echo '
2017-09-11 17:49:03 +02:00
< div class = " alert alert-danger " > '.tr(' La cartella di backup non esiste ! ').' '.tr(' Non è possibile eseguire i backup ! ').' </ div > ' ;
2017-08-04 16:28:16 +02:00
}
2017-09-11 17:49:03 +02:00
if ( ! empty ( $backup_dir )) {
2017-08-04 16:28:16 +02:00
echo '
2018-03-22 17:20:33 +01:00
< button type = " button " class = " btn btn-primary pull-right " onclick = " continue_backup() " >< i class = " fa fa-database " ></ i > '.tr(' Crea backup ').' ...</ button >< div class = " clearfix " ></ div >
2017-09-11 17:49:03 +02:00
< script >
function continue_backup (){
swal ({
title : " '.tr('Nuovo backup').' " ,
text : " '.tr('Sei sicuro di voler creare un nuovo backup?').' " ,
type : " warning " ,
showCancelButton : true ,
confirmButtonClass : " btn btn-lg btn-success " ,
confirmButtonText : " '.tr('Crea').' " ,
}) . then (
function (){
location . href = globals . rootdir + " /editor.php?id_module='. $id_module .'&op=backup " ;
}, function (){});
}
</ script > ' ;
2017-08-04 16:28:16 +02:00
}