Rework everything
This commit is contained in:
@ -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");
|
||||
|
Reference in New Issue
Block a user