format_bytes has moved
This commit is contained in:
parent
d9986c5434
commit
b8fd51c750
|
@ -1,5 +1,5 @@
|
|||
Options -Indexes -Multiviews
|
||||
DirectoryIndex disabled
|
||||
DirectoryIndex index.php
|
||||
|
||||
RewriteEngine On
|
||||
RewriteBase /
|
||||
|
|
16
www/_inc.php
16
www/_inc.php
|
@ -61,3 +61,19 @@ function html_foot(): void
|
|||
</body>
|
||||
</html>';
|
||||
}
|
||||
|
||||
function format_bytes(int $bytes, string $unit = 'B'): string
|
||||
{
|
||||
if ($bytes >= 1024*1024*1024) {
|
||||
return round($bytes / (1024*1024*1024), 1) . ' G' . $unit;
|
||||
}
|
||||
elseif ($bytes >= 1024*1024) {
|
||||
return round($bytes / (1024*1024), 1) . ' M' . $unit;
|
||||
}
|
||||
elseif ($bytes >= 1024) {
|
||||
return round($bytes / 1024, 1) . ' K' . $unit;
|
||||
}
|
||||
else {
|
||||
return $bytes . ' ' . $unit;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,9 +19,9 @@ if (!$user) {
|
|||
|
||||
$quota = $users->quota($user);
|
||||
$server = new Server;
|
||||
$free = $server->format_bytes($quota->free);
|
||||
$used = $server->format_bytes($quota->used);
|
||||
$total = $server->format_bytes($quota->total);
|
||||
$free = format_bytes($quota->free);
|
||||
$used = format_bytes($quota->used);
|
||||
$total = format_bytes($quota->total);
|
||||
$www_url = WWW_URL;
|
||||
|
||||
html_head('My files');
|
||||
|
@ -32,6 +32,7 @@ echo <<<EOF
|
|||
<dd><a href="{$user->dav_url}"><tt>{$user->dav_url}</tt></a> (click to manage your files from your browser)</dd>
|
||||
<dt>NextCloud URL</dt>
|
||||
<dd><tt>{$www_url}</tt></dd>
|
||||
<dd class="help">Use this URL to setup a NextCloud or ownCloud client to access your files.</dd>
|
||||
<dt>Quota</dt>
|
||||
<dd>Used {$used} out of {$total} (free: {$free})</dd>
|
||||
</dl>
|
||||
|
|
Loading…
Reference in a new issue