first commit

This commit is contained in:
2025-11-02 18:08:53 +01:00
commit cb045fb9e1
23 changed files with 1363 additions and 0 deletions

32
include/authenticator.php Normal file
View File

@@ -0,0 +1,32 @@
<?php
session_start();
function isLogged(): bool
{
return isset($_SESSION['user']);
}
function checkLogin(PDO $pdo, $login, $password): bool
{
$stmt = $pdo->prepare('SELECT * FROM utilisateur WHERE login = ?');
$stmt->execute([$login]);
$user = $stmt->fetch();
if ($user && password_verify($password, $user['password'])) {
$_SESSION['user'] = $user['login'];
return true;
}
return false;
}
function requireLogin() {
if (!isLogged()) {
header('Location: login.php');
exit;
}
}
?>