Refactored file system

Changed the file system to a more ordered state and updated links in
files accordingly. Also the reffering to files is now uniform
This commit is contained in:
sraffauf
2026-01-21 17:58:15 +01:00
parent a3b261e9ae
commit 77fd4e836b
15 changed files with 99 additions and 52 deletions

32
php/login.php Normal file
View File

@@ -0,0 +1,32 @@
<?php
session_start();
$username = $_POST['username'] ?? '';
$password = $_POST['password'] ?? '';
$usersFile = __DIR__ . "../data/users.json";
if (!file_exists($usersFile)) {
die("Benutzerdaten fehlen!");
}
$users = json_decode(file_get_contents($usersFile), true);
$loginOk = false;
if (is_array($users)) {
foreach ($users as $user) {
if ($user['username'] === $username && $user['password'] === $password) {
$loginOk = true;
break;
}
}
}
if ($loginOk) {
$_SESSION['loggedIn'] = true;
$_SESSION['username'] = $username;
header("Location: ./admin.php");
exit;
} else {
header("Location: ../pages/login.html?error=1");
exit;
}