2022-08-30 05:01:39 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace KaraDAV;
|
|
|
|
|
2022-09-03 03:09:52 +00:00
|
|
|
if (!empty($_SERVER['PATH_INFO'])) {
|
|
|
|
require __DIR__ . '/_router.php';
|
|
|
|
exit;
|
|
|
|
}
|
|
|
|
|
2022-08-30 05:01:39 +00:00
|
|
|
require_once __DIR__ . '/_inc.php';
|
|
|
|
|
2022-08-31 06:06:27 +00:00
|
|
|
$users = new Users;
|
|
|
|
$user = $users->current();
|
2022-08-30 05:01:39 +00:00
|
|
|
|
2022-10-24 17:06:00 +00:00
|
|
|
if (isset($_GET['logout'])) {
|
|
|
|
$users->logout();
|
|
|
|
$user = null;
|
|
|
|
}
|
|
|
|
|
2022-08-31 06:06:27 +00:00
|
|
|
if (!$user) {
|
|
|
|
header(sprintf('Location: %slogin.php', WWW_URL));
|
|
|
|
exit;
|
|
|
|
}
|
2022-08-30 05:01:39 +00:00
|
|
|
|
2022-08-31 06:06:27 +00:00
|
|
|
$quota = $users->quota($user);
|
|
|
|
$server = new Server;
|
2022-10-10 13:20:41 +00:00
|
|
|
$free = format_bytes($quota->free);
|
|
|
|
$used = format_bytes($quota->used);
|
|
|
|
$total = format_bytes($quota->total);
|
2022-10-24 17:06:00 +00:00
|
|
|
$percent = floor(($quota->used / $quota->total)*100) . '%';
|
2022-08-31 06:06:27 +00:00
|
|
|
$www_url = WWW_URL;
|
2022-10-24 17:06:00 +00:00
|
|
|
$username = htmlspecialchars($user->login);
|
2022-08-30 05:01:39 +00:00
|
|
|
|
2022-09-03 03:09:52 +00:00
|
|
|
html_head('My files');
|
|
|
|
|
|
|
|
echo <<<EOF
|
2022-10-24 17:06:00 +00:00
|
|
|
<h2 class="myfiles"><a class="btn" href="{$user->dav_url}">Manage my files</a></h2>
|
|
|
|
<h3>Hello, {$username} !</h3>
|
2022-08-31 06:06:27 +00:00
|
|
|
<dl>
|
2022-10-24 17:06:00 +00:00
|
|
|
<dd><h3>{$percent} used, {$free} free</h3></dd>
|
|
|
|
<dd><progress max="{$quota->total}" value="{$quota->used}"></progress>
|
|
|
|
<dd>Used {$used} out of a total of {$total}.</dd>
|
2022-08-31 06:06:27 +00:00
|
|
|
<dt>WebDAV URL</dt>
|
2022-10-24 17:06:00 +00:00
|
|
|
<dd><h3><a href="{$user->dav_url}"><tt>{$user->dav_url}</tt></a></h3>
|
2022-08-31 06:06:27 +00:00
|
|
|
<dt>NextCloud URL</dt>
|
|
|
|
<dd><tt>{$www_url}</tt></dd>
|
2022-10-10 13:20:41 +00:00
|
|
|
<dd class="help">Use this URL to setup a NextCloud or ownCloud client to access your files.</dd>
|
2022-08-31 06:06:27 +00:00
|
|
|
</dl>
|
2022-10-24 17:06:00 +00:00
|
|
|
<p><a class="btn sm" href="?logout">Logout</a></p>
|
2022-09-03 03:09:52 +00:00
|
|
|
EOF;
|
|
|
|
|
2022-10-24 17:06:00 +00:00
|
|
|
if ($user->is_admin) {
|
|
|
|
echo '<p><a class="btn sm" href="users.php">Manager users</a></p>';
|
|
|
|
}
|
|
|
|
|
2022-09-03 03:09:52 +00:00
|
|
|
html_foot();
|