diff --git a/lib/functions.php b/lib/functions.php index 69c4b3384..5d1bda6e3 100644 --- a/lib/functions.php +++ b/lib/functions.php @@ -72,22 +72,7 @@ function delete($files) */ function directory($path) { - if (is_dir($path) && is_writable($path)) { - return true; - } elseif (!is_dir($path)) { - // Filesystem Symfony - $fs = new Symfony\Component\Filesystem\Filesystem(); - - // Tentativo di creazione - try { - $fs->mkdir($path); - - return true; - } catch (Symfony\Component\Filesystem\Exception\IOException $e) { - } - } - - return false; + return Util\FileSystem::directory($path); } /** @@ -410,6 +395,7 @@ function operationLog($operation, array $ids = [], array $options = []) * * @return string */ -function clean($string, $permitted = '') { - return preg_replace('/[^A-Za-z0-9'.$permitted.']/', '', $string); // Removes special chars. +function clean($string, $permitted = '') +{ + return preg_replace('/[^A-Za-z0-9'.$permitted.']/', '', $string); // Removes special chars. } diff --git a/modules/backups/actions.php b/modules/backups/actions.php index 3f23064d9..3242b7575 100644 --- a/modules/backups/actions.php +++ b/modules/backups/actions.php @@ -36,6 +36,13 @@ switch (filter('op')) { 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; + + case 'size': + $file = filter('file'); + + echo Util\FileSystem::size($backup_dir.'/'.$file); + break; } diff --git a/modules/backups/edit.php b/modules/backups/edit.php index e2b6723d6..8ad551948 100644 --- a/modules/backups/edit.php +++ b/modules/backups/edit.php @@ -3,6 +3,7 @@ include_once __DIR__.'/../../core.php'; $backup_dir = Backup::getDirectory(); +$backups = Backup::getList(); echo '
'.tr('Il backup è molto importante 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').'.
'; @@ -35,26 +36,10 @@ if (!empty($backup_dir)) { $message = tr('Sembra che tu non abbia ancora specificato un percorso per il backup').'.'; } -echo ' -'.$message.'
-'.tr('Dimensione totale: _SPAZIO_', [
- '_SPAZIO_' => format_size(foldersize($backup_dir)),
- ]).'
'.tr('Numero di backup: _NUM_', [
- '_NUM_' => count(Backup::getList()),
- ]).'
- '.tr('Puoi modificare il percorso di backup dal tuo file _FILE_', [
- '_FILE_' => 'config.inc.php',
- ]).'
'.$message.'
+'.tr('Dimensione totale: _SPAZIO_', [ + '_SPAZIO_' => '', + ]).'
+'.tr('Numero di backup: _NUM_', [ + '_NUM_' => count($backups), + ]).'
+'.tr('Puoi modificare il percorso di backup dal tuo file _FILE_', [ + '_FILE_' => 'config.inc.php', + ]).'
+
'.tr('Nome del file').': '.$name.'
- '.tr('Dimensione').': '.format_size(filesize($backup)).'
+ '.tr('Dimensione').':
'.tr('Nome del file').': '.$name.'
- '.tr('Dimensione').': '.format_size(filesize($backup)).'
+ '.tr('Dimensione').':