Files
elwig-access/www/index.php
2025-05-03 16:59:51 +02:00

101 lines
3.4 KiB
PHP

<?php
require ".php/credentials.inc";
global $CLIENT_ACCESS;
global $COMBINED_ACCESS;
$info = explode('/', $_SERVER['PATH_INFO']);
$client = null;
foreach ($CLIENT_ACCESS as $name => $data) {
if ($name === $info[1] && (sizeof($info) === 2 || $info[2] === '')) {
$client = $data;
$client['id'] = $name;
}
}
foreach ($COMBINED_ACCESS as $name => $data) {
if ($name === $info[1] && (sizeof($info) === 2 || $info[2] === '')) {
$client = $data;
$client['id'] = $name;
}
}
if ($client === null) {
header('Status: 200');
header('Content-Length: 0');
exit();
} else if ($_SERVER['PATH_INFO'] !== "/$client[id]/") {
header('Status: 308');
header("Location: /$client[id]/");
exit();
}
if ($client['api']) {
$data = "window.ELWIG_API = \"$client[api]\";";
} else {
$data = "window.CLIENTS = {";
$first = true;
foreach ($client['clients'] as $id) {
$c = $CLIENT_ACCESS[$id];
if (!$first) $data .= ", ";
$data .= "\"$id\": {\"name\": \"$c[name]\", \"short\": \"$c[short]\", \"api\": \"$c[api]\"}";
$first = false;
}
$data .= "};";
}
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">
<head>
<meta charset="UTF-8"/>
<title><?php echo $client['name']; ?> - Elwig</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"/>
<meta name="viewport" content="width=device-width,initial-scale=1.0"/>
<script>window.CLIENT = "<?php echo $info[1]; ?>"; <?php echo $data; ?></script>
<script src="/res/access.js" type="application/javascript"/>
<script src="<?php echo $client['api'] ? "/res/access-single.js" : "/res/access-multiple.js"; ?>" type="application/javascript"/>
</head>
<body class="header-footer">
<header>
<nav>
<div>
<a href="https://elwig.at/"><img src="/res/elwig.png" alt="Elwig Logo"/></a>
</div>
<ul>
<?php if (isset($client['clients'])) {
foreach ($client['clients'] as $id) {
$c = $CLIENT_ACCESS[$id];
echo " <li><a href=\"#/$id\">$c[short]</a></li>\n";
}
} else { ?>
<li><a href="#/">Übersicht</a></li>
<li><a href="#/mitglied">Mitglied</a></li>
<li><a href="#/lieferungen">Lieferungen</a></li>
<li><a href="#/anmeldungen">Anmeldungen</a></li>
<?php } ?>
</ul>
<div>
<?php if (!isset($client['clients'])) { ?>
<a href="#/mitglied" id="user">
<div id="usertext"></div>
<img src="/res/avatar.png" alt="Avatar" style="border-radius: 50%; height: 2.25em; margin: 0.5em;"/>
</a>
<?php } ?>
</div>
</nav>
</header>
<main id="access"/>
<footer>
<a href="https://elwig.at/"><img src="/res/elwig.png" alt="Elwig"/></a>
<p>
<strong>Impressum</strong><br/>
Lorenz Stechauner, Thomas Hilscher<br/>
Österreich (Austria)<br/>
</p>
<p>
<strong>Kontakt</strong><br/>
E-Mail: <a href="mailto:contact@necronda.net">contact@necronda.net</a><br/>
</p>
</footer>
</body>
</html>