commit 797205e7c5c95dbe69235a0993ee92da5e12c883 Author: Lorenz Stechauner Date: Sat Nov 25 20:09:22 2023 +0100 Initial commit diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..5c25283 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +credentials.* +!*.sample.* diff --git a/README.md b/README.md new file mode 100644 index 0000000..7c22631 --- /dev/null +++ b/README.md @@ -0,0 +1,2 @@ + +# Elwig REST API diff --git a/www/clients.php b/www/clients.php new file mode 100644 index 0000000..589e8d0 --- /dev/null +++ b/www/clients.php @@ -0,0 +1,138 @@ + [ + 'username' => 'password', + ], +]; diff --git a/www/files/index.php b/www/files/index.php new file mode 100644 index 0000000..d9bd3af --- /dev/null +++ b/www/files/index.php @@ -0,0 +1,69 @@ + [$size, $mtime, $ctime]) { + if (!$first) echo ",\n"; + $p1 = strrpos($name, '-') + 1; + $p2 = strrpos($name, '.'); + $vers = substr($name, $p1, $p2 - $p1); + $url = "https://www.necronda.net/elwig/files/$name"; + $mod = date(DATE_ATOM, $mtime); + $cre = date(DATE_ATOM, $ctime); + echo " {\"version\": \"$vers\", \"name\": \"$name\", \"url\": \"$url\", \"size\": $size, \"created\": \"$cre\", \"modified\": \"$mod\"}"; + $first = false; + } + echo "\n]}\n"; +} else if ($format === 'text') { + header('Content-Type: text/plain; charset=UTF-8'); + foreach ($files as $name => [$size, $mtime, $ctime]) { + echo "$name\t" . number_format($size / 1024 / 1024, 1) . " MB\n"; + } +} else if ($format === 'html') { + header('Content-Type: text/html; charset=UTF-8'); +?> + + + + Downloads - Elwig - Elektronische Winzergenossenschaftsverwaltung + + + + + +

Downloads

+ + + + + + + + + [$size, $mtime, $ctime]) { + echo " \n"; +} +?> + +
NameGröße
$name" . number_format($size / 1024 / 1024, 1) . " MB
+

JSON-Format

+ + +\nHTML
\nJSON
\nText\n\n"; + exit(); + } + return $fmt; +} + +function _get_fmt(): string { + if (!empty($_GET['format'])) return $_GET['format']; + + $fmts = []; + foreach (explode(',', $_SERVER['HTTP_ACCEPT']) as $acc) { + $acc = explode(';', trim($acc)); + $q = 1; + if (sizeof($acc) > 1) { + $qv = trim($acc[1]); + if (str_starts_with($qv, 'q=')) { + $q = (double)substr($qv, 2); + } + } + $fmts[trim($acc[0])] = $q; + } + arsort($fmts, SORT_NUMERIC); + array_filter($fmts, function($k) { + return str_contains($k, '/json') || $k === 'text/html' || $k === 'text/plain' || str_contains($k, 'text/*'); + }); + + $type = sizeof($fmts) > 0 ? array_key_first($fmts) : null; + if (str_contains($type, '/json')) { + return 'json'; + } else if ($type === 'text/html') { + return 'html'; + } else { + return 'text'; + } +} diff --git a/www/index.html b/www/index.html new file mode 100644 index 0000000..f3344b1 --- /dev/null +++ b/www/index.html @@ -0,0 +1,15 @@ + + + + Elwig - Elektronische Winzergenossenschaftsverwaltung + + + + + +

Elwig

+

Elektronische Winzergenossenschaftsverwaltung

+ Source + Downloads + + diff --git a/www/res/elwig.ico b/www/res/elwig.ico new file mode 100644 index 0000000..985b599 Binary files /dev/null and b/www/res/elwig.ico differ diff --git a/www/res/elwig.png b/www/res/elwig.png new file mode 100644 index 0000000..f2764a2 Binary files /dev/null and b/www/res/elwig.png differ diff --git a/www/res/style.css b/www/res/style.css new file mode 100644 index 0000000..096cbe0 --- /dev/null +++ b/www/res/style.css @@ -0,0 +1,5 @@ + +html { + font-family: 'Arial', sans-serif; +} +