Rework everything

This commit is contained in:
2024-05-11 21:21:54 +02:00
parent 2ddeaf1bfa
commit 01f240cd57
13 changed files with 176 additions and 71 deletions

View File

@ -1,13 +1,10 @@
<?php
require "../format.inc";
$TITLE = 'Downloads';
require "../.php/format.inc";
require "../.php/auth.inc";
if ($_SERVER['REQUEST_METHOD'] === 'PUT') {
if ($_SERVER['PHP_AUTH_USER'] !== 'elwig' || $_SERVER['PHP_AUTH_PW'] !== '[REDACTED]') {
header('Status: 401');
header('WWW-Authenticate: Basic realm="Elwig"');
exit("401 Unauthorized :(\n");
}
authenticate();
$name = substr($_SERVER['PATH_INFO'], 1);
if (str_contains($name, "..") || str_contains($name, "/")) {
header('Status: 403');
@ -110,16 +107,27 @@ if ($format === 'json') {
header('Location: ' . $entities[array_key_first($entities)][2]);
exit();
}
header('Content-Type: text/html; charset=UTF-8');
require "../header.inc"; ?>
<h1>Downloads</h1>
<table>
<thead><tr><th>Name</th><th>Größe</th><th>Änderungsdatum</th></tr></thead>
<tbody>
header('Content-Type: application/xhtml+xml; charset=UTF-8');
echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
?>
<html xmlns="http://www.w3.org/1999/xhtml" lang="de-AT">
<head>
<meta charset="UTF-8"/>
<title>Downloads - Elwig - Elektronische Winzergenossenschaftsverwaltung</title>
<link rel="icon" href="/favicon.ico" sizes="16x16 20x20 24x24 30x30 32x32 36x36 40x40 48x48 60x60 64x64 72x72 80x80 96x96 128x128 256x256"/>
<link rel="stylesheet" href="/res/style.css"/>
</head>
<body>
<h1>Downloads</h1>
<table>
<thead><tr><th>Name</th><th>Größe</th><th>Änderungsdatum</th></tr></thead>
<tbody>
<?php foreach ($entities as $name => [$prod, $vers, $url, $size, $mtime, $ctime, $mod, $cre]) {
echo " <tr><td><a href='files/$name'>$name</a></td><td>" . number_format($size / 1024 / 1024, 1) . " MB</td><td>" . date('d.m.Y, H:i', $mtime) . "</td></tr>\n";
echo " <tr><td><a href='files/$name'>$name</a></td><td>" . number_format($size / 1024 / 1024, 1) . " MB</td><td>" . date('d.m.Y, H:i', $mtime) . "</td></tr>\n";
} ?>
</tbody>
</table>
<p><a href="files?format=json">JSON-Format</a></p>
<?php require "../footer.inc"; }
</tbody>
</table>
<p><a href="files?format=json">JSON-Format</a></p>
</body>
</html>
<?php }