commit1
This commit is contained in:
@@ -2,6 +2,9 @@ FROM php:8.2-apache
|
||||
LABEL authors="matthieulmr"
|
||||
|
||||
COPY . /var/www/html
|
||||
|
||||
RUN chown -R www-data:www-data /var/www/html
|
||||
|
||||
WORKDIR /var/www/html
|
||||
|
||||
RUN docker-php-ext-install pdo pdo_mysql
|
||||
|
||||
14
README.md
Normal file
14
README.md
Normal file
@@ -0,0 +1,14 @@
|
||||
Pour accéder au site :
|
||||
Lancez les conteneurs depuis la racine du projet avec la commande suivante (Dans un terminal qui accepte le bash par exemple GIT bash) :
|
||||
|
||||
./launch-dockers.sh
|
||||
|
||||
Une fois les conteneurs démarrés, le site sera accessible dans votre navigateur à l'adresse :
|
||||
|
||||
http://localhost:8080/
|
||||
|
||||
|
||||
Acces au compte admin :
|
||||
|
||||
Utilisateur : Admin
|
||||
Mdp : Ciccina28
|
||||
@@ -1,7 +1,6 @@
|
||||
<?php
|
||||
global $pdo, $pdo;
|
||||
require '../include/db.php';
|
||||
require '../include/authenticator.php';
|
||||
require '../include/auth.php';
|
||||
requireLogin();
|
||||
|
||||
$errors = [];
|
||||
@@ -26,6 +25,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
<!doctype html>
|
||||
<html lang="fr">
|
||||
<head>
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
<?php
|
||||
global $pdo;
|
||||
require '../include/db.php';
|
||||
require '../include/authenticator.php';
|
||||
require '../include/auth.php';
|
||||
requireLogin();
|
||||
$stmt = $pdo->query('SELECT * FROM articles ORDER BY date_creation DESC');
|
||||
$articles = $stmt->fetchAll();
|
||||
?>
|
||||
|
||||
<!DOCTYPE html>
|
||||
<html lang="fr">
|
||||
<head><meta charset="UTF-8"><title>Admin - Tableau de bord</title></head>
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
<?php
|
||||
global $pdo;
|
||||
require '../include/db.php';
|
||||
require '../include/authenticator.php';
|
||||
require '../include/auth.php';
|
||||
requireLogin();
|
||||
|
||||
$id = isset($_GET['id']) ? (int)$_GET['id'] : 0;
|
||||
@@ -27,6 +26,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||
exit;
|
||||
}
|
||||
?>
|
||||
|
||||
<!doctype html>
|
||||
<html lang="fr">
|
||||
<head>
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
<?php
|
||||
global $pdo;
|
||||
require '../include/db.php';
|
||||
require '../include/authenticator.php';
|
||||
require '../include/auth.php';
|
||||
|
||||
$error = '';
|
||||
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||
@@ -13,6 +12,7 @@ $error = 'Identifiants incorrects';
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
<!DOCTYPE html>
|
||||
<html lang="fr">
|
||||
<head><meta charset="UTF-8"><title>Connexion</title></head>
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
<?php
|
||||
global $pdo;
|
||||
require 'include/db.php';
|
||||
$id = isset($_GET['id']) ? (int)$_GET['id'] : 0;
|
||||
$stmt = $pdo->prepare('SELECT * FROM articles WHERE id = ?');
|
||||
@@ -7,6 +6,7 @@ $stmt->execute([$id]);
|
||||
$article = $stmt->fetch();
|
||||
if (!$article) { http_response_code(404); die('<h1>404 - Article introuvable</h1>'); }
|
||||
?>
|
||||
|
||||
<!DOCTYPE html>
|
||||
<html lang="fr">
|
||||
<head><meta charset="UTF-8"><title><?= htmlspecialchars($article['titre']) ?></title></head>
|
||||
|
||||
@@ -4,11 +4,11 @@ body {
|
||||
margin: 0;
|
||||
padding: 20px;
|
||||
background-color: #f4f4f4;
|
||||
color: #333;
|
||||
color: #ffffff;
|
||||
}
|
||||
|
||||
header {
|
||||
background: #333;
|
||||
background: #ffffff;
|
||||
color: #fff;
|
||||
padding: 10px 0;
|
||||
text-align: center;
|
||||
@@ -16,7 +16,7 @@ header {
|
||||
}
|
||||
|
||||
h1 {
|
||||
color: #444;
|
||||
color: #ffffff;
|
||||
border-bottom: 2px solid #ccc;
|
||||
padding-bottom: 10px;
|
||||
margin-top: 0;
|
||||
@@ -28,7 +28,7 @@ article {
|
||||
margin-bottom: 15px;
|
||||
border: 1px solid #ddd;
|
||||
border-radius: 5px;
|
||||
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
|
||||
box-shadow: 0 2px 4px rgba(253, 249, 249, 0.05);
|
||||
}
|
||||
|
||||
article h2 a {
|
||||
@@ -40,7 +40,6 @@ article h2 a:hover {
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
/* Style spécifique pour l'Admin */
|
||||
table {
|
||||
width: 100%;
|
||||
border-collapse: collapse;
|
||||
@@ -57,7 +56,6 @@ table th {
|
||||
background-color: #e2e2e2;
|
||||
}
|
||||
|
||||
/* Style pour les messages d'erreur */
|
||||
.error {
|
||||
color: red;
|
||||
font-weight: bold;
|
||||
|
||||
@@ -17,4 +17,4 @@ date_creation DATETIME DEFAULT CURRENT_TIMESTAMP
|
||||
);
|
||||
|
||||
|
||||
INSERT INTO utilisateur (login, password) VALUES ('admin', '$2y$10$OVqu798zF7FF36HER0nZ9uOJ5tuuTR.kwPK2GTiqlPPYzR2szGzB6');
|
||||
INSERT INTO utilisateur (login, password) VALUES ('Admin', '$2y$12$Rtdu4PVCMi0hvY43vxAIN.1K7TmNxYwaE/idie5B3C1K45TKdobzq');
|
||||
32
include/auth.php
Normal file
32
include/auth.php
Normal 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;
|
||||
}
|
||||
}
|
||||
?>
|
||||
@@ -11,3 +11,4 @@ try {
|
||||
} catch (PDOException $e) {
|
||||
die('Erreur de connexion : ' . $e->getMessage());
|
||||
}
|
||||
?>
|
||||
@@ -1,9 +1,9 @@
|
||||
<?php
|
||||
global $pdo;
|
||||
require 'include/db.php';
|
||||
$stmt = $pdo->query('SELECT * FROM articles ORDER BY date_creation DESC LIMIT 10');
|
||||
$articles = $stmt->fetchAll();
|
||||
?>
|
||||
|
||||
<!DOCTYPE html>
|
||||
<html lang="fr">
|
||||
<head>
|
||||
|
||||
0
launch-dockers.sh
Normal file → Executable file
0
launch-dockers.sh
Normal file → Executable file
Reference in New Issue
Block a user