Initial commit

This commit is contained in:
2025-05-03 16:15:32 +02:00
commit 918ca9cb2c
10 changed files with 527 additions and 0 deletions

22
www/.php/auth.inc Normal file
View File

@ -0,0 +1,22 @@
<?php
require "credentials.inc";
function http_401_unauthorized(): void {
header('Status: 401');
header('WWW-Authenticate: Basic realm="Elwig"');
header('Content-Type: text/plain; charset=UTF-8');
header('Content-Length: 17');
exit("401 Unauthorized\n");
}
function authenticate(string $client): void {
global $CREDENTIALS;
$credentials = $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();
}
}