diff --git a/api/list_images.php b/api/list_images.php index d790a4e..0d91473 100644 --- a/api/list_images.php +++ b/api/list_images.php @@ -1,5 +1,7 @@ 0, + 'path' => '/', + 'httponly' => true, + 'samesite' => 'Lax', + 'secure' => $secure, + ]); + + session_start(); +} + +function dreamgirl_is_logged_in(): bool { + dreamgirl_session_start(); + return isset($_SESSION['dreamgirl_user']) && $_SESSION['dreamgirl_user'] === 'admin'; +} + +function dreamgirl_check_credentials(string $username, string $password): bool { + if ($username !== 'admin') return false; + + // sha256("admin5004!") + $expectedSha256 = 'adcda104b73b73f8cddf5c8047a6bc0e5e1388265ed4bf0f31f704c13cbc11b7'; + $gotSha256 = hash('sha256', $password); + + return hash_equals($expectedSha256, $gotSha256); +} + +function dreamgirl_require_login_page(): void { + if (dreamgirl_is_logged_in()) return; + header('Location: /login.php'); + exit; +} + +function dreamgirl_require_login_json(): void { + if (dreamgirl_is_logged_in()) return; + http_response_code(401); + header('Content-Type: application/json; charset=utf-8'); + echo json_encode(['ok' => false, 'error' => 'Unauthorized'], JSON_UNESCAPED_UNICODE); + exit; +} + diff --git a/favicon.ico b/favicon.ico index 766b1a6..e5133a2 100644 Binary files a/favicon.ico and b/favicon.ico differ diff --git a/index.html b/index.html index fe3e95f..29c12a3 100644 --- a/index.html +++ b/index.html @@ -1,92 +1,15 @@ -
- - - - - - - - - - - - - - - - - - - - - stop - -