From 1a5e01566382f7541d0bfad5aeff894ccf9770ef Mon Sep 17 00:00:00 2001 From: yanishimidi Date: Sun, 2 Nov 2025 22:39:12 +0100 Subject: [PATCH] =?UTF-8?q?Nouvelle=20version=20compl=C3=A8te=20(remplacem?= =?UTF-8?q?ent=20total)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .DS_Store | Bin 0 -> 6148 bytes README.md | 12 +++++++++++ dump.sql | 23 ++++++++++++++++++++ includes/.DS_Store | Bin 0 -> 6148 bytes includes/db.php | 18 ++++++++++++++++ includes/footer.php | 6 ++++++ includes/header.php | 17 +++++++++++++++ public/.DS_Store | Bin 0 -> 6148 bytes public/add.php | 34 ++++++++++++++++++++++++++++++ public/admin.php | 22 +++++++++++++++++++ public/article.php | 30 ++++++++++++++++++++++++++ public/edit.php | 50 ++++++++++++++++++++++++++++++++++++++++++++ public/login.php | 34 ++++++++++++++++++++++++++++++ public/logout.php | 7 +++++++ 14 files changed, 253 insertions(+) create mode 100644 .DS_Store create mode 100644 README.md create mode 100644 dump.sql create mode 100644 includes/.DS_Store create mode 100644 includes/db.php create mode 100644 includes/footer.php create mode 100644 includes/header.php create mode 100644 public/.DS_Store create mode 100644 public/add.php create mode 100644 public/admin.php create mode 100644 public/article.php create mode 100644 public/edit.php create mode 100644 public/login.php create mode 100644 public/logout.php diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..fae641e385ed6e603494e7a545428b5707d23161 GIT binary patch literal 6148 zcmeHK%Wl&^6ur}i)}gAD1xQ`6u*5bhX&OKk8#lNT2*DyouxL?;?zx`Kx$%sLh*&cV_J}G(WT6NwT}4%3 z!Y|5_t?3aF%;Yn6DW%sGJ&bsFiERdq0!D%VO#!t51e8&q5}JE|{fPVcvGB7Szz092 z$)9ggNHKLOLR3IKO2zwr&Zm!HwSLFOK97f;FzyXxKp6BuIe8w&0UtGa76++}^_0UZ zTjh3TXFR@JZ&dBujr~d09v{?eRlBi&XEG^U*Kgjs*J{6t`Z0emS4s@~nzU_=Gx&hU zk`B@7p4a95WJW6D^ttQmwOiFEZ@>IF{(4x<3;v3ioc(#uH{KwQczlX^#CkT6>5P2j zFQo25?oQx;G?%*^cSZ7+TT?;Ka{l>zec$#z>wGP6&U1AUryx(cXDsBXOf5R1Lvrac za2Ic9kk1r*hfLMyGKKCXP5-y8txLukx>3L=u=)y!{lP{N=xCfOlv@WXc?AHLFf0vi z@kt?KY>ke_sX};QOoakfDAQLArou69Yo4QVs!)X!lQZKvdS<3?C``_daa+=fISNf} z6fg?p61z5@T+$NT!&(@{IiL=&5d5I!S@TLl72r7LX h%Z50LcTl9kXNv~V(KuCz5t#W9kTRIcDDY1e_yxVu{=fhL literal 0 HcmV?d00001 diff --git a/README.md b/README.md new file mode 100644 index 0000000..ba4f2e9 --- /dev/null +++ b/README.md @@ -0,0 +1,12 @@ + CMS Simplifié + + Présentation + +Ce mini-projet a été réalisé dans le cadre du module Développement Web (BTS CIEL – 2ᵉ année). +Il s'agit d'un mini système de gestion de contenu** qui permet de gérer des articles de manière simple. + +Le site est organisé en deux parties : +- Zone publique*: les visiteurs peuvent consulter les articles sans se connecter. +- Zone administration: un administrateur peut se connecter pour ajouter, modifier ou supprimer des articles. + +L’objectif principal est de pratiquer le développement web dynamique avec PHP pur et MySQL, en mettant en œuvre toutes les étapes du cycle CRUD (Create, Read, Update, Delete), la gestion des sessions et la sécurisation des données. diff --git a/dump.sql b/dump.sql new file mode 100644 index 0000000..b476a87 --- /dev/null +++ b/dump.sql @@ -0,0 +1,23 @@ +CREATE DATABASE IF NOT EXISTS cms_simplifie CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci; +USE cms_simplifie; + +CREATE TABLE IF NOT EXISTS utilisateur ( + id INT AUTO_INCREMENT PRIMARY KEY, + login VARCHAR(50) NOT NULL UNIQUE, + password VARCHAR(255) NOT NULL +); + +INSERT INTO utilisateur (login, password) VALUES +('admin', '$2y$10$kD5oX7ZbC0mC6h/0qTz7ue1v5HPxqj8k3y3m5ZtQ7lY9UeH8tFjQG'); + +CREATE TABLE IF NOT EXISTS articles ( + id INT AUTO_INCREMENT PRIMARY KEY, + titre VARCHAR(255) NOT NULL, + contenu TEXT NOT NULL, + date_creation DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP +); + +INSERT INTO articles (titre, contenu) VALUES +('Premier article', 'Ceci est le contenu du premier article de test.'), +('Deuxième article', 'Contenu du deuxième article pour tester le CMS.'), +('Troisième article', 'Encore un exemple d’article pour remplir la base.'); diff --git a/includes/.DS_Store b/includes/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..6df77134a3052e6208150605bff36de465786349 GIT binary patch literal 6148 zcmeHLJ5B>Z47DLb5i}_&=LAS}l%psV)La0TfKo)-D1v@YzzK7g@SbgumTXE8LUuHM zUXMMVebUY+BBJxR<+aF6M5bs&r7Ka-_& zawQuX&Yz^r(Qfu8HvMyXksiNSd6w;wocDvA6`~(e<#^8STaFb=l?)^U$v`rY4Ez8C z*t03q3&+&SKr)aFd@;cFp`a0KU~{yk1In%dzzN(Yuz74|P6@1m%@I8i^;DpzYFshY z)8Q`>R|A`)r;A!;j1!eVFE47<;V%|0S{+j-1IfUU0p5KfGw%Pl_+&;e`4*BY8At~H zD+4-N+%Nb?SM03^@5#Nkpgo{b7}sb(U=I!fc;Gs6X`S9*Xd|u$Hb;&^zoi57AYg=~ JN(O#`fe%7RHgW&} literal 0 HcmV?d00001 diff --git a/includes/db.php b/includes/db.php new file mode 100644 index 0000000..08404a4 --- /dev/null +++ b/includes/db.php @@ -0,0 +1,18 @@ + PDO::ERRMODE_EXCEPTION, + PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC, +]; + +try { + $pdo = new PDO($dsn, $user, $pass, $options); +} catch (\PDOException $e) { + die("Erreur de connexion : " . $e->getMessage()); +} diff --git a/includes/footer.php b/includes/footer.php new file mode 100644 index 0000000..a002e0b --- /dev/null +++ b/includes/footer.php @@ -0,0 +1,6 @@ + +
+

© 2025 Mini CMS. Tous droits réservés.

+
+ + diff --git a/includes/header.php b/includes/header.php new file mode 100644 index 0000000..b73249e --- /dev/null +++ b/includes/header.php @@ -0,0 +1,17 @@ + + + + + Mini CMS + + + +
+

Mini CMS

+ +
+
diff --git a/public/.DS_Store b/public/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..93df429f81e3f7e467788cc9158d17e52fedcacc GIT binary patch literal 6148 zcmeHKOHRW;47E!I3Egzb25C-E2~H5IvS7^xpbaWWfmEp7XU`qD0{7w)@cdELCe0QB zvMbMHEMFHxK!BA#x_3!*U*WpKekj^=>LxOm3~9ytcG&at9LTHRFjVqSH!Bk&s) zkb8GR_f+CHp`H6z&oLs8#T9(=rG_3+uG!D@L@zyzj}~JD#w)GCSWra|hgp2yVr9rI z!CCj@zqRsn%w5y6|9|l(7?(RcIdw)&o4!?a_wPF#Oc53egaV`w@eUj(GCC!m%+l zI0-?aZ0!MZ^mim9)fBxSm#Z@Q}3j8YtcsRSAO|d1f xt)0zDtxfPdxR~TMhFc0cT8fb?rT7f4hIo<=uyAY)5rM^rfXWa}DDa~Sd;_qkUef>o literal 0 HcmV?d00001 diff --git a/public/add.php b/public/add.php new file mode 100644 index 0000000..51d0b63 --- /dev/null +++ b/public/add.php @@ -0,0 +1,34 @@ +prepare("INSERT INTO articles (titre, contenu, date_creation) VALUES (?, ?, NOW())"); + $stmt->execute([$titre, $contenu]); + echo "

Article ajouté avec succès.

"; + } else { + echo "

Veuillez remplir tous les champs.

"; + } +} +?> + +

Ajouter un article

+
+
+

+
+

+ +
+ + diff --git a/public/admin.php b/public/admin.php new file mode 100644 index 0000000..0c2dca5 --- /dev/null +++ b/public/admin.php @@ -0,0 +1,22 @@ + + +

Tableau de bord

+

Bienvenue, !

+ + + + diff --git a/public/article.php b/public/article.php new file mode 100644 index 0000000..4e86105 --- /dev/null +++ b/public/article.php @@ -0,0 +1,30 @@ +Article introuvable (404)

"; + require_once '../includes/footer.php'; + exit; +} + +$stmt = $pdo->prepare("SELECT * FROM articles WHERE id = ?"); +$stmt->execute([$id]); +$article = $stmt->fetch(); + +if (!$article) { + echo "

Article introuvable (404)

"; + require_once '../includes/footer.php'; + exit; +} +?> +
+

+

+ Publié le +
+ + + diff --git a/public/edit.php b/public/edit.php new file mode 100644 index 0000000..6901385 --- /dev/null +++ b/public/edit.php @@ -0,0 +1,50 @@ +Article introuvable (404)

"; + require_once '../includes/footer.php'; + exit; +} + +$stmt = $pdo->prepare("SELECT * FROM articles WHERE id = ?"); +$stmt->execute([$id]); +$article = $stmt->fetch(); + +if (!$article) { + echo "

Article introuvable (404)

"; + require_once '../includes/footer.php'; + exit; +} + +if ($_SERVER['REQUEST_METHOD'] === 'POST') { + $titre = $_POST['titre'] ?? ''; + $contenu = $_POST['contenu'] ?? ''; + if ($titre && $contenu) { + $stmt = $pdo->prepare("UPDATE articles SET titre=?, contenu=? WHERE id=?"); + $stmt->execute([$titre, $contenu, $id]); + echo "

Article mis à jour avec succès.

"; + } else { + echo "

Veuillez remplir tous les champs.

"; + } +} +?> + +

Modifier l'article

+
+
+

+
+

+ +
+ + diff --git a/public/login.php b/public/login.php new file mode 100644 index 0000000..95567c1 --- /dev/null +++ b/public/login.php @@ -0,0 +1,34 @@ +prepare("SELECT * FROM utilisateur WHERE login = ?"); + $stmt->execute([$login]); + $user = $stmt->fetch(); + + if ($user && password_verify($password, $user['password'])) { + $_SESSION['user'] = $user['login']; + header("Location: admin.php"); + exit; + } else { + $error = "Identifiants incorrects"; + } +} +?> + +

Connexion administrateur

+$error

"; ?> +
+
+

+
+

+ +
+ + diff --git a/public/logout.php b/public/logout.php new file mode 100644 index 0000000..cbba24c --- /dev/null +++ b/public/logout.php @@ -0,0 +1,7 @@ +