2019-06-03 11:48:03 +02:00
|
|
|
<?php
|
2019-06-04 20:45:40 +02:00
|
|
|
|
2019-06-03 11:48:03 +02:00
|
|
|
use Util\FileSystem;
|
2019-06-04 20:45:40 +02:00
|
|
|
|
2019-06-03 11:48:03 +02:00
|
|
|
switch ($resource) {
|
|
|
|
case 'folder_size':
|
|
|
|
|
|
|
|
$dirs = $_GET['dirs'];
|
|
|
|
|
|
|
|
if (empty($dirs)) {
|
|
|
|
$backup_dir = App::getConfig()['backup_dir'];
|
|
|
|
$dirs = [
|
|
|
|
$backup_dir => tr('Backup'),
|
|
|
|
'files' => tr('Allegati'),
|
|
|
|
'logs' => tr('Logs'),
|
|
|
|
];
|
2019-06-04 20:45:40 +02:00
|
|
|
} else {
|
|
|
|
$array = explode(',', $dirs);
|
2019-06-03 11:48:03 +02:00
|
|
|
foreach ($array as $key => $value) {
|
|
|
|
$dirs = [
|
2019-06-04 20:45:40 +02:00
|
|
|
$value => $key,
|
2019-06-03 11:48:03 +02:00
|
|
|
];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
$tot_byte_size = 0;
|
|
|
|
foreach ($dirs as $dir => $description) {
|
|
|
|
$size = FileSystem::folderSize($dir);
|
2019-06-04 20:45:40 +02:00
|
|
|
|
2019-06-03 11:48:03 +02:00
|
|
|
$results[] = [
|
|
|
|
'description' => $description,
|
|
|
|
'size' => $size,
|
|
|
|
'formattedSize' => FileSystem::formatBytes($size),
|
|
|
|
];
|
|
|
|
|
|
|
|
$tot_byte_size += $size;
|
|
|
|
}
|
|
|
|
|
2019-06-04 20:45:40 +02:00
|
|
|
$results[count($dirs)]['totalbyte'] = $tot_byte_size;
|
|
|
|
|
2019-06-03 11:48:03 +02:00
|
|
|
$response = $results;
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return [
|
|
|
|
'folder_size',
|
2019-06-04 20:45:40 +02:00
|
|
|
];
|