commit 9c91a13c305587c85dd6c695f89b998400d11da1 Author: Lorenz Stechauner Date: Sat May 3 15:50:00 2025 +0200 Initial commit diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..541957b --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +.idea +credentials.* +!*.sample.* diff --git a/README.md b/README.md new file mode 100644 index 0000000..6adb9c0 --- /dev/null +++ b/README.md @@ -0,0 +1,7 @@ + +# Elwig Access Frontend + +The web frontend for accessing Elwig online. + +https://access.elwig.at/ + diff --git a/www/.php/credentials.sample.inc b/www/.php/credentials.sample.inc new file mode 100644 index 0000000..d91308d --- /dev/null +++ b/www/.php/credentials.sample.inc @@ -0,0 +1,18 @@ + [ + 'name' => 'Winzergenossenschaft Ort', + 'short' => 'Ort', + 'api' => 'https://example.com/elwig/api/v1', + ], +]; + +$COMBINED_ACCESS = [ + 'HOLDING' => [ + 'name' => 'Name', + 'clients' => ['WGX'], + ], +]; diff --git a/www/favicon.ico b/www/favicon.ico new file mode 100644 index 0000000..985b599 Binary files /dev/null and b/www/favicon.ico differ diff --git a/www/index.php b/www/index.php new file mode 100644 index 0000000..0e77a82 --- /dev/null +++ b/www/index.php @@ -0,0 +1,100 @@ + $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: 404'); + 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 "\n"; ?> + + + + <?php echo $client['name']; ?> - Elwig + + + + +