Rework everything
This commit is contained in:
27
www/.php/auth.inc
Normal file
27
www/.php/auth.inc
Normal file
@ -0,0 +1,27 @@
|
||||
<?php
|
||||
require "credentials.inc";
|
||||
|
||||
function authenticate(): void {
|
||||
global $CREDENTIALS;
|
||||
if (!isset($_SEVER['PHP_AUTH_USER']) || !isset($_SEVER['PHP_AUTH_PW']) ||
|
||||
!array_key_exists($_SERVER['PHP_AUTH_USER'], $CREDENTIALS) ||
|
||||
$_SERVER['PHP_AUTH_PW'] !== $CREDENTIALS[$_SERVER['PHP_AUTH_USER']])
|
||||
{
|
||||
header('Status: 401');
|
||||
header('WWW-Authenticate: Basic realm="Elwig"');
|
||||
exit("401 Unauthorized :(\n");
|
||||
}
|
||||
}
|
||||
|
||||
function authenticate_client(string $client): void {
|
||||
global $CLIENT_CREDENTIALS;
|
||||
$credentials = $CLIENT_CREDENTIALS[$client];
|
||||
if (!isset($_SERVER['PHP_AUTH_USER']) || !isset($_SERVER['PHP_AUTH_PW']) ||
|
||||
!array_key_exists($_SERVER['PHP_AUTH_USER'], $credentials) ||
|
||||
$_SERVER['PHP_AUTH_PW'] !== $credentials[$_SERVER['PHP_AUTH_USER']])
|
||||
{
|
||||
header('Status: 401');
|
||||
header('WWW-Authenticate: Basic realm="Elwig"');
|
||||
exit("401 Unauthorized :(\n");
|
||||
}
|
||||
}
|
16
www/.php/credentials.sample.inc
Normal file
16
www/.php/credentials.sample.inc
Normal file
@ -0,0 +1,16 @@
|
||||
<?php
|
||||
global $GITEA_TOKEN;
|
||||
global $CREDENTIALS;
|
||||
global $CLIENT_CREDENTIALS;
|
||||
|
||||
$GITEA_TOKEN = 'token';
|
||||
|
||||
$CREDENTIALS = [
|
||||
'username' => 'password',
|
||||
];
|
||||
|
||||
$CLIENT_CREDENTIALS = [
|
||||
'name' => [
|
||||
'username' => 'password',
|
||||
],
|
||||
];
|
@ -1,9 +1,10 @@
|
||||
<?php
|
||||
require "format.inc";
|
||||
include "credentials.inc";
|
||||
$TITLE = 'Mandanten';
|
||||
$CREDENTIALS ??= [];
|
||||
$clients = array_keys($CREDENTIALS);
|
||||
require ".php/format.inc";
|
||||
require ".php/auth.inc";
|
||||
require ".php/credentials.inc";
|
||||
global $CLIENT_CREDENTIALS;
|
||||
|
||||
$clients = array_keys($CLIENT_CREDENTIALS);
|
||||
|
||||
$format = get_fmt();
|
||||
|
||||
@ -97,20 +98,30 @@ if ($path == '') {
|
||||
}
|
||||
echo "\n]}\n";
|
||||
} else if ($format === 'html') {
|
||||
header('Content-Type: text/html; charset=UTF-8');
|
||||
require "header.inc"; ?>
|
||||
<h1>Mandanten</h1>
|
||||
<table>
|
||||
<thead><tr><th>Name</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>Mandanten - 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>Mandanten</h1>
|
||||
<table>
|
||||
<thead><tr><th>Name</th></tr></thead>
|
||||
<tbody>
|
||||
<?php foreach ($clients as $c) {
|
||||
echo " <tr><td><a href='clients/$c'>$c</a></td></tr>\n";
|
||||
echo " <tr><td><a href='clients/$c'>$c</a></td></tr>\n";
|
||||
} ?>
|
||||
</tbody>
|
||||
</table>
|
||||
<p><a href="clients?format=json">JSON-Format</a></p>
|
||||
<?php require "footer.inc";
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
<p><a href="clients?format=json">JSON-Format</a></p>
|
||||
</body>
|
||||
</html>
|
||||
<?php }
|
||||
exit();
|
||||
}
|
||||
|
||||
@ -120,13 +131,8 @@ foreach ($clients as $c) {
|
||||
|
||||
header('Content-Type: text/plain; charset=UTF-8');
|
||||
|
||||
if (!isset($_SERVER['PHP_AUTH_USER']) || !isset($_SERVER['PHP_AUTH_PW']) ||
|
||||
!array_key_exists($_SERVER['PHP_AUTH_USER'], $CREDENTIALS[$c]) || $_SERVER['PHP_AUTH_PW'] !== $CREDENTIALS[$c][$_SERVER['PHP_AUTH_USER']])
|
||||
{
|
||||
header('Status: 401');
|
||||
header('WWW-Authenticate: Basic realm="Elwig"');
|
||||
exit("401 Unauthorized :(\n");
|
||||
} elseif ($path === "/$c") {
|
||||
authenticate_client($c);
|
||||
if ($path === "/$c") {
|
||||
header("Location: $c/");
|
||||
header('Status: 303');
|
||||
exit("303 See Other :)\n");
|
||||
|
@ -1,7 +0,0 @@
|
||||
<?php
|
||||
global $CREDENTIALS;
|
||||
$CREDENTIALS = [
|
||||
'name' => [
|
||||
'username' => 'password',
|
||||
],
|
||||
];
|
Before Width: | Height: | Size: 229 KiB After Width: | Height: | Size: 229 KiB |
@ -1,4 +1,6 @@
|
||||
<?php
|
||||
require "../.php/credentials.inc";
|
||||
global $GITEA_TOKEN;
|
||||
|
||||
if ($_SERVER['PHP_AUTH_USER'] !== 'elwig' || $_SERVER['PHP_AUTH_PW'] !== 'ganzGeheim123!') {
|
||||
header('Status: 401');
|
||||
@ -6,9 +8,8 @@ if ($_SERVER['PHP_AUTH_USER'] !== 'elwig' || $_SERVER['PHP_AUTH_PW'] !== 'ganzGe
|
||||
exit("401 Unauthorized :(\n");
|
||||
}
|
||||
|
||||
$token = "[REDACTED]";
|
||||
$repo = "winzer/elwig-misc.git";
|
||||
$url = "https://token:$token@git.necronda.net/$repo";
|
||||
$url = "https://token:$GITEA_TOKEN@git.necronda.net/$repo";
|
||||
$schema_version = $_GET['v'];
|
||||
|
||||
shell_exec("cd .repos; git clone $url; cd elwig-misc; git checkout main; git pull -f --rebase");
|
||||
|
@ -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 }
|
||||
|
@ -1,2 +0,0 @@
|
||||
</body>
|
||||
</html>
|
@ -1,10 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="de">
|
||||
<head>
|
||||
<base href="/elwig/"/>
|
||||
<title><?php if (!empty($TITLE)) echo "$TITLE - "; ?>Elwig - Elektronische Winzergenossenschaftsverwaltung</title>
|
||||
<meta charset="UTF-8"/>
|
||||
<link rel="icon" sizes="16x16 20x20 24x24 30x30 32x32 36x36 40x40 48x48 60x60 64x64 72x72 80x80 96x96 128x128 256x256" href="res/elwig.ico"/>
|
||||
<link rel="stylesheet" href="res/style.css"/>
|
||||
</head>
|
||||
<body>
|
@ -1,7 +0,0 @@
|
||||
<?php require "header.inc"; ?>
|
||||
<h1>Elwig</h1>
|
||||
<h2>Elektronische Winzergenossenschaftsverwaltung</h2>
|
||||
<a href="https://git.necronda.net/winzer">Source</a><br/>
|
||||
<a href="files/">Downloads</a><br/>
|
||||
<a href="clients">Mandanten</a>
|
||||
<?php require "footer.inc"; ?>
|
31
www/index.xhtml
Normal file
31
www/index.xhtml
Normal file
@ -0,0 +1,31 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" lang="de-AT">
|
||||
<head>
|
||||
<meta charset="UTF-8"/>
|
||||
<title>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>
|
||||
<header>
|
||||
<nav>
|
||||
<ul>
|
||||
<li><a href="/"><img src="/res/elwig.png" alt="Elwig Logo"/></a></li>
|
||||
<li><a href="/files/">Downloads</a></li>
|
||||
<li><a href="https://git.necronda.net/winzer/">Quellcode</a></li>
|
||||
</ul>
|
||||
</nav>
|
||||
</header>
|
||||
|
||||
<main>
|
||||
<h1>Elwig</h1>
|
||||
<h2>Elektronische Winzergenossenschaftsverwaltung</h2>
|
||||
<a href="/clients">Mandanten</a>
|
||||
</main>
|
||||
|
||||
<footer>
|
||||
<a href="/" class="img"><img src="/res/elwig.png" alt="Elwig"/></a>
|
||||
<p class="copyright">Copyright © 2024 Lorenz Stechauner</p>
|
||||
</footer>
|
||||
</body>
|
||||
</html>
|
@ -1,6 +1,48 @@
|
||||
|
||||
html {
|
||||
:root {
|
||||
font-family: 'Arial', sans-serif;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
body {
|
||||
margin: 3em 0 0 0;
|
||||
}
|
||||
|
||||
header {
|
||||
position: fixed;
|
||||
top: 0;
|
||||
width: 100%;
|
||||
height: 3em;
|
||||
border-bottom: 1px solid #C0C0C0;
|
||||
background-color: #FFFFFF;
|
||||
}
|
||||
|
||||
header img {
|
||||
height: 2.5em;
|
||||
margin: 0.25em;
|
||||
}
|
||||
|
||||
nav {
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
nav ul {
|
||||
display: flex;
|
||||
list-style-type: none;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
nav li {
|
||||
|
||||
}
|
||||
|
||||
nav li a {
|
||||
text-decoration: none;
|
||||
padding: 1em;
|
||||
}
|
||||
|
||||
table td {
|
||||
|
Reference in New Issue
Block a user