travail
This commit is contained in:
6
.idea/vcs.xml
generated
Normal file
6
.idea/vcs.xml
generated
Normal 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>
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
require '../include/authenticator.php';
|
require '../include/auth.php';
|
||||||
|
|
||||||
$_SESSION = [];
|
$_SESSION = [];
|
||||||
|
|
||||||
@@ -15,3 +15,4 @@ if (!function_exists('logout_user')) {
|
|||||||
|
|
||||||
header('Location: ../index.php');
|
header('Location: ../index.php');
|
||||||
exit;
|
exit;
|
||||||
|
?>
|
||||||
@@ -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,14 +35,15 @@ 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>
|
||||||
@@ -53,5 +54,5 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
|||||||
<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>
|
||||||
@@ -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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user