diff --git a/www/.php/auth.inc b/www/.php/auth.inc index b6936d6..63d0503 100644 --- a/www/.php/auth.inc +++ b/www/.php/auth.inc @@ -19,15 +19,3 @@ function authenticate(): void { http_401_unauthorized(); } } - -function authenticate_client(string $client): void { - global $CLIENT_CREDENTIALS; - $credentials = $CLIENT_CREDENTIALS[$client]; - if (!array_key_exists('PHP_AUTH_USER', $_SERVER) || - !array_key_exists('PHP_AUTH_PW', $_SERVER) || - !array_key_exists($_SERVER['PHP_AUTH_USER'], $credentials) || - $_SERVER['PHP_AUTH_PW'] !== $credentials[$_SERVER['PHP_AUTH_USER']]) - { - http_401_unauthorized(); - } -} diff --git a/www/.php/credentials.sample.inc b/www/.php/credentials.sample.inc index 9246a39..72650b5 100644 --- a/www/.php/credentials.sample.inc +++ b/www/.php/credentials.sample.inc @@ -1,16 +1,9 @@ 'password', ]; - -$CLIENT_CREDENTIALS = [ - 'name' => [ - 'username' => 'password', - ], -]; diff --git a/www/clients.php b/www/clients.php deleted file mode 100644 index 2c6597b..0000000 --- a/www/clients.php +++ /dev/null @@ -1,276 +0,0 @@ -\n"; - ?> - - - - Mandanten - Elwig - - - - - - -
-
-

Mandanten

-

Startseite

- - - -\n"; -} ?> - -
Name
$c
-

JSON-Format

-
-
- - -format(DateTimeInterface::RFC3339) . '"'; - $zwstid = "\"$parts[2]\""; - } - list($meta, $version, $files) = get_zip_meta($path); - $files ??= "null"; - $version ??= "null"; - echo " {\"name\": \"$file\", \"timestamp\": $datetime, \"zwstid\": $zwstid, \"meta\": $meta, \"files\": $files, " . - "\"version\": $version, \"url\": \"$url\", \"size\": $size, \"created\": \"$cre\", \"modified\": \"$mod\"}"; - $first = false; - } - echo "\n]}\n"; - exit(); - } - - $file = substr($path, strlen("/$c/")); - $path = ".data/clients/$c/$file"; - if (!preg_match_all('/[A-Za-z0-9_.-]+/', $file) && !($file === '*' && $_SERVER['REQUEST_METHOD'] === 'DELETE')) { - header('Status: 400'); - header('Content-Length: 16'); - exit("400 Bad Request\n"); - } else if ($_SERVER['REQUEST_METHOD'] === 'GET') { - $size = filesize($path); - if ($size === false) { - header('Status: 404'); - header('Content-Length: 14'); - exit("404 Not Found\n"); - } - $type = mime_content_type($path); - header("Content-Type: $type"); - header("Content-Disposition: attachment; filename=\"$file\""); - header("Content-Length: $size"); - readfile($path); - } else if ($_SERVER['REQUEST_METHOD'] === 'PUT') { - $upload = fopen("php://input", "r"); - $fp = fopen("/tmp/upload-$file", "wb+"); - if (!$upload || !$fp) { - fclose($fp); - fclose($upload); - header('Status: 500'); - header('Content-Length: 26'); - exit("500 Internal Server Error\n"); - } - - while ($data = fread($upload, 4096)) fwrite($fp, $data); - fclose($fp); - fclose($upload); - - if (!rename("/tmp/upload-$file", $path)) { - header('Status: 500'); - header('Content-Length: 26'); - exit("500 Internal Server Error\n"); - } - - header("Status: 201"); - header('Content-Length: 12'); - exit("201 Created\n"); - } else if ($_SERVER['REQUEST_METHOD'] === 'DELETE') { - if ($file === '*') { - foreach (scandir(".data/clients/$c/") as $f) { - if (str_starts_with($f, ".") || str_ends_with($f, ".php") || str_ends_with($f, ".inc")) continue; - if (unlink(".data/clients/$c/$f") === false) { - header("Status: 500"); - exit("500 Internal Server Error\n"); - } - echo "Deleted $f\n"; - } - } else if (!is_file($path)) { - header("Status: 404"); - header("Content-Length: 14"); - exit("404 Not Found\n"); - } else if (unlink($path) === false) { - header("Status: 500"); - exit("500 Internal Server Error\n"); - } - exit("200 OK\n"); - } else { - header("Status: 405"); - header("Allow: GET, PUT, DELETE"); - header("Content-Length: 23"); - exit("405 Method Not Allowed\n"); - } - - exit(); -} - -header("Status: 404"); -if ($format === 'text') { - header('Content-Type: text/plain; charset=UTF-8'); - header('Content-Length: 14'); - echo "404 Not Found\n"; -} else if ($format === 'json') { - header('Content-Type: application/json; charset=UTF-8'); - header('Content-Length: 39'); - echo "{\"errors\": [{\"message\": \"Not found\"}]}\n"; -} else { - header('Content-Type: text/html; charset=UTF-8'); - header('Content-Length: 0'); -} -exit(); diff --git a/www/index.php b/www/index.php index 548869a..ea907c4 100644 --- a/www/index.php +++ b/www/index.php @@ -34,10 +34,17 @@ switch ($_SERVER['PATH_INFO']) { header("Status: 303"); header("Location: https://access.elwig.at/"); break; + case '/clients': + header("Status: 303"); + header("Location: https://sync.elwig.at/"); + break; default: if (str_starts_with($_SERVER['PATH_INFO'], '/access/')) { header("Status: 308"); header("Location: https://access.elwig.at/" . substr($_SERVER['PATH_INFO'], 8)); + } else if (str_starts_with($_SERVER['PATH_INFO'], '/clients/')) { + header("Status: 308"); + header("Location: https://sync.elwig.at/" . substr($_SERVER['PATH_INFO'], 9)); } else { header("Status: 404"); } diff --git a/www/res/style.css b/www/res/style.css index bbbe071..be36a44 100644 --- a/www/res/style.css +++ b/www/res/style.css @@ -145,6 +145,15 @@ table a { color: var(--main-color); } +main section h3 { + text-align: center; + font-size: 2em; +} + +.center { + text-align: center; +} + /**** Index ****/ main span[id] { @@ -263,15 +272,6 @@ main section p { text-align: justify; } -.center { - text-align: center; -} - -main section h3 { - text-align: center; - font-size: 2em; -} - main .about { padding: 0 0 1em 0; } diff --git a/www/robots.txt b/www/robots.txt index 391d3a7..ec6aadf 100644 --- a/www/robots.txt +++ b/www/robots.txt @@ -1,4 +1,3 @@ # robots.txt for elwig.at User-Agent: * -Disallow: /clients/ Sitemap: https://elwig.at/sitemap.xml