Add disk_usage
This commit is contained in:
@@ -91,15 +91,18 @@ if ($path == '') {
|
||||
|
||||
if ($format === 'text') {
|
||||
header('Content-Type: text/plain; charset=UTF-8');
|
||||
foreach ($clients as $c)
|
||||
echo "$c\n";
|
||||
foreach ($clients as $c) {
|
||||
$size = intval(exec("du -s .data/$c"));
|
||||
echo "$c ($size kB)\n";
|
||||
}
|
||||
} else if ($format === 'json') {
|
||||
header('Content-Type: application/json; charset=UTF-8');
|
||||
echo "{\"data\": [";
|
||||
$first = true;
|
||||
foreach ($clients as $c) {
|
||||
if (!$first) echo ",";
|
||||
echo "\n {\"name\": \"$c\"}";
|
||||
$size = intval(exec("du -s .data/$c")) * 1024;
|
||||
echo "\n {\"name\": \"$c\", \"disk_usage\": $size}";
|
||||
$first = false;
|
||||
}
|
||||
echo "\n]}\n";
|
||||
@@ -122,10 +125,11 @@ if ($path == '') {
|
||||
<h3>Mandanten</h3>
|
||||
<p class="center"><a href="https://elwig.at/">Homepage</a></p>
|
||||
<table>
|
||||
<thead><tr><th>Name</th></tr></thead>
|
||||
<thead><tr><th>Name</th><th>Usage</th></tr></thead>
|
||||
<tbody>
|
||||
<?php foreach ($clients as $c) {
|
||||
echo " <tr><td><a href='$c'>$c</a></td></tr>\n";
|
||||
$size = intval(exec("du -s .data/$c"));
|
||||
echo " <tr><td><a href='$c'>$c</a></td><td class='right'>$size kB</td></tr>\n";
|
||||
} ?>
|
||||
</tbody>
|
||||
</table>
|
||||
@@ -159,7 +163,8 @@ foreach ($clients as $c) {
|
||||
}
|
||||
|
||||
header('Content-Type: application/json; charset=UTF-8');
|
||||
echo "{\"data\": [\n";
|
||||
$size = intval(exec("du -s .data/$c")) * 1024;
|
||||
echo "{\"disk_usage\": $size, \"data\": [\n";
|
||||
$first = true;
|
||||
foreach (scandir(".data/$c/") as $file) {
|
||||
if (str_starts_with($file, ".") || str_ends_with($file, ".php") || str_ends_with($file, ".inc")) continue;
|
||||
|
@@ -154,6 +154,10 @@ main section h3 {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.right {
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
main section p,
|
||||
main section table {
|
||||
max-width: 1000px;
|
||||
|
Reference in New Issue
Block a user