This commit is contained in:
2025-11-02 14:51:56 +01:00
parent f2b78086dd
commit 7e550de5f0
4 changed files with 28 additions and 51 deletions

6
.idea/vcs.xml generated Normal file
View File

@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$" vcs="Git" />
</component>
</project>

View File

@@ -1,5 +1,5 @@
<?php <?php
require '../include/authenticator.php'; require '../include/auth.php';
$_SESSION = []; $_SESSION = [];
@@ -14,4 +14,5 @@ if (!function_exists('logout_user')) {
} }
header('Location: ../index.php'); header('Location: ../index.php');
exit; exit;
?>

View File

@@ -1,7 +1,7 @@
<?php <?php
global $pdo; global $pdo;
require '../include/db.php'; require '../include/db.php';
require '../include/authenticator.php'; require '../include/auth.php';
requireLogin(); requireLogin();
$id = isset($_GET['id']) ? (int)$_GET['id'] : 0; $id = isset($_GET['id']) ? (int)$_GET['id'] : 0;
@@ -35,23 +35,24 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
} }
} }
?> ?>
<!doctype html> <!doctype html>
<html lang="fr"> <html lang="fr">
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8">
<title>Modifier l'article</title> <title>Modifier l'article</title>
<link rel="stylesheet" href="/assets/style.css"> <link rel="stylesheet" href="/assets/style.css">
</head> </head>
<body> <body>
<h1>Modifier l'article</h1> <h1>Modifier l'article</h1>
<?php foreach ($errors as $e): ?> <?php foreach ($errors as $e): ?>
<p class="error"><?= htmlspecialchars($e) ?></p> <p class="error"><?= htmlspecialchars($e) ?></p>
<?php endforeach; ?> <?php endforeach; ?>
<form method="post"> <form method="post">
<label>Titre<br><input type="text" name="titre" value="<?= htmlspecialchars($titre) ?>" required></label><br> <label>Titre<br><input type="text" name="titre" value="<?= htmlspecialchars($titre) ?>" required></label><br>
<label>Contenu<br><textarea name="contenu" rows="10" required><?= htmlspecialchars($contenu) ?></textarea></label><br> <label>Contenu<br><textarea name="contenu" rows="10" required><?= htmlspecialchars($contenu) ?></textarea></label><br>
<button type="submit">Enregistrer</button> <button type="submit">Enregistrer</button>
<a href="board.php">Annuler</a> <a href="board.php">Annuler</a>
</form> </form>
</body> </body>
</html> </html>

View File

@@ -1,31 +0,0 @@
<?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;
}
}