commit 9f268216d816deb5cbef6331d3b033f215d8fd4a Author: s4msk0 Date: Sun Nov 2 21:27:45 2025 +0100 first commit diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..13566b8 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,8 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Editor-based HTTP Client requests +/httpRequests/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml diff --git a/.idea/CMS.iml b/.idea/CMS.iml new file mode 100644 index 0000000..c956989 --- /dev/null +++ b/.idea/CMS.iml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/inspectionProfiles/Project_Default.xml b/.idea/inspectionProfiles/Project_Default.xml new file mode 100644 index 0000000..5cb71ef --- /dev/null +++ b/.idea/inspectionProfiles/Project_Default.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..c896007 --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/php.xml b/.idea/php.xml new file mode 100644 index 0000000..f324872 --- /dev/null +++ b/.idea/php.xml @@ -0,0 +1,19 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..94a25f7 --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..e69de29 diff --git a/admin/ajouter.php b/admin/ajouter.php new file mode 100644 index 0000000..2db105d --- /dev/null +++ b/admin/ajouter.php @@ -0,0 +1,68 @@ +prepare('INSERT INTO articles (titre, contenu, date_creation) VALUES (:titre, :contenu, :date)'); + $stmt->execute([ + ':titre' => $titre, + ':contenu' => $contenu, + ':date' => date('Y-m-d H:i:s'), + ]); + + + header('Location: board.php'); + exit; + } +} +?> + + + + + + Ajouter un article + + + + +

Ajouter un article

+ + + +

+ + + +
+
+ +
+ + + Annuler de l'anulation +
+ + + \ No newline at end of file diff --git a/admin/dashboard.php b/admin/dashboard.php new file mode 100644 index 0000000..9168ac8 --- /dev/null +++ b/admin/dashboard.php @@ -0,0 +1,69 @@ +query('SELECT * FROM articles ORDER BY date_creation DESC'); +$articles = $stmt->fetchAll(); +?> + + + + + + Tableau de Bord + + + + +
+

Tableau de Bord de bordination

+

+ Connecté en tant que + + + | Se déconnecter +

+ +
+ +
+ +
+ +

Gestion des articles

+ Ajouter un nouvel article + +
+ +

Vos articles publiés

+ + + + + + + + + + + + + + + + + + + + +
IDTitreDate de créationActions
+ Modifier + | + Supprimer +
+
+ + + diff --git a/admin/login.php b/admin/login.php new file mode 100644 index 0000000..f7fbeb0 --- /dev/null +++ b/admin/login.php @@ -0,0 +1,34 @@ + + + + + + Connexion + + + +

Connexion

+
+
+
+ +
+

+ + + diff --git a/admin/logout.php b/admin/logout.php new file mode 100644 index 0000000..abd5ac2 --- /dev/null +++ b/admin/logout.php @@ -0,0 +1,27 @@ + diff --git a/admin/modifier.php b/admin/modifier.php new file mode 100644 index 0000000..cd543da --- /dev/null +++ b/admin/modifier.php @@ -0,0 +1,88 @@ +prepare('SELECT * FROM articles WHERE id = :id'); +$stmt->execute([':id' => $id]); +$article = $stmt->fetch(); + +// Article est pas valide on retourne au tableau +if (!$article) { + header('Location: board.php'); + exit; +} + + +$errors = []; +$titre = $article['titre']; +$contenu = $article['contenu']; + + +if ($_SERVER['REQUEST_METHOD'] === 'POST') { + $titre = trim($_POST['titre'] ?? ''); + $contenu = trim($_POST['contenu'] ?? ''); + + + if ($titre === '' || $contenu === '') { + $errors[] = 'Tous les champs sont obligatoires.'; + } else { + + $u = $pdo->prepare('UPDATE articles SET titre = :titre, contenu = :contenu WHERE id = :id'); + $u->execute([ + ':titre' => $titre, + ':contenu' => $contenu, + ':id' => $id + ]); + + + header('Location: board.php'); + exit; + } +} +?> + + + + + + Modifier l'article + + + + +

Modifier l'article

+ + + +

+ + +> +
+
+
+ + Annuler +
+ + + \ No newline at end of file diff --git a/admin/styleajouter.css b/admin/styleajouter.css new file mode 100644 index 0000000..81f1a5b --- /dev/null +++ b/admin/styleajouter.css @@ -0,0 +1,88 @@ +body { + font-family: Arial, sans-serif; + line-height: 1.6; + margin: 0; + padding: 20px; + background-color: #f4f4f9; + color: #333; +} + + +h1 { + color: #1e3d59; + border-bottom: 2px solid #aac4e0; + padding-bottom: 10px; + margin-top: 0; +} + + +form { + background-color: #fff; + padding: 20px; + border: 1px solid #d0dbe5; + border-radius: 6px; + max-width: 600px; + margin-top: 20px; +} + + +label { + display: block; + margin-bottom: 15px; + font-weight: bold; +} + +input[type="text"], +textarea { + width: 100%; + padding: 8px; + border: 1px solid #bfc9d6; + border-radius: 4px; + box-sizing: border-box; +} + + +button { + background-color: #2a73cc; + color: #fff; + padding: 10px 15px; + border: none; + border-radius: 4px; + cursor: pointer; + font-size: 1rem; +} + +button:hover { + background-color: #195aa7; +} + + +a { + margin-left: 10px; + color: #2a73cc; + text-decoration: none; +} + +a:hover { + text-decoration: underline; +} + + +.error { + color: #721c24; + background-color: #f8d7da; + border: 1px solid #f5c6cb; + padding: 10px; + border-radius: 5px; + margin-bottom: 15px; +} + + +@media (max-width: 640px) { + body { + padding: 10px; + } + form { + padding: 15px; + } +} \ No newline at end of file diff --git a/admin/styleboard.css b/admin/styleboard.css new file mode 100644 index 0000000..3931627 --- /dev/null +++ b/admin/styleboard.css @@ -0,0 +1,97 @@ +body { + font-family: Arial, sans-serif; + line-height: 1.6; + margin: 0; + padding: 20px; + background-color: #ececec; /* gris clair pour le fond */ + color: #333; +} + +/* En-tête */ +header { + background-color: #555; /* gris foncé */ + color: #fff; + padding: 15px; + border-radius: 6px; + margin-bottom: 20px; +} + +header h1 { + margin: 0; + font-size: 1.8rem; +} + +header p { + margin: 5px 0 0 0; +} + +header a { + color: #cfcfcf; + text-decoration: none; +} + +header a:hover { + text-decoration: underline; + color: #fff; +} + +/* Titres */ +h2, h3 { + color: #333; + margin-top: 20px; +} + +/* Lien Ajouter un article */ +a { + color: #555; + text-decoration: none; + font-weight: bold; +} + +a:hover { + text-decoration: underline; +} + +/* Permet de cree des tableau */ +table { + width: 100%; + border-collapse: collapse; + margin-top: 15px; + background-color: #fff; /* fond blanc pour contraster */ + border-radius: 6px; + overflow: hidden; + box-shadow: 0 2px 4px rgba(0,0,0,0.1); +} + +table th, table td { + padding: 10px; + border: 1px solid #ccc; + text-align: left; +} + +table th { + background-color: #bbb; /* gris moyen pour l'entête */ + color: #fff; +} + +/* Lignes de tableau */ +table tr:nth-child(even) { + background-color: #f2f2f2; +} + +/* Actions */ +table a { + color: #2a73cc; +} + +table a:hover { + color: #195aa7; + text-decoration: underline; +} + +/* Séparateurs */ +hr { + border: 0; + border-top: 1px solid #ccc; + margin: 20px 0; +} \ No newline at end of file diff --git a/admin/stylelog.css b/admin/stylelog.css new file mode 100644 index 0000000..5b65d31 --- /dev/null +++ b/admin/stylelog.css @@ -0,0 +1,89 @@ +/* Styles globaux */ +body { + font-family: Arial, sans-serif; + line-height: 1.6; + margin: 0; + padding: 20px; + background-color: #f4f4f9; /* fond clair */ + color: #333; +} + +/* Titres */ +h1 { + color: #1e3d59; /* bleu foncé */ + border-bottom: 2px solid #aac4e0; + padding-bottom: 10px; + margin-top: 0; +} + +/* Formulaire */ +form { + background: #fff; + padding: 20px; + border-radius: 6px; + border: 1px solid #d0dbe5; + max-width: 600px; + margin-top: 20px; +} + +/* Labels et inputs */ +label { + display: block; + margin-bottom: 15px; + font-weight: bold; +} + +input[type="text"], +textarea { + width: 100%; + padding: 8px; + border: 1px solid #bfc9d6; + border-radius: 4px; + box-sizing: border-box; +} + +/* Bouton */ +button { + background-color: #2a73cc; + color: #fff; + padding: 10px 15px; + border: none; + border-radius: 4px; + cursor: pointer; + font-size: 1rem; +} + +button:hover { + background-color: #195aa7; +} + +/* Lien annuler */ +a { + margin-left: 10px; + color: #2a73cc; + text-decoration: none; +} + +a:hover { + text-decoration: underline; +} + +/* Messages d'erreur */ +.error { + color: #721c24; + background: #f8d7da; + border: 1px solid #f5c6cb; + padding: 10px; + border-radius: 5px; + margin-bottom: 15px; +} + +/* Responsive */ +@media (max-width: 640px) { + body { + padding: 10px; + } + form { + padding: 15px; + } +} \ No newline at end of file diff --git a/admin/stylemodif.css b/admin/stylemodif.css new file mode 100644 index 0000000..9410835 --- /dev/null +++ b/admin/stylemodif.css @@ -0,0 +1,113 @@ +/* Styles globaux */ +body { + font-family: Arial, sans-serif; + line-height: 1.6; + margin: 0; + padding: 20px; + background-color: #ececec; /* gris clair */ + color: #333; +} + +/* Header */ +header { + background-color: #555; /* gris foncé */ + color: #fff; + padding: 15px; + border-radius: 6px; + text-align: center; + margin-bottom: 20px; +} + +header h1 { + margin: 0; + font-size: 1.8rem; +} + +header p { + margin: 5px 0 0 0; +} + +header a { + color: #cfcfcf; + text-decoration: none; +} + +header a:hover { + color: #fff; + text-decoration: underline; +} + +/* Titres */ +h1, h2, h3 { + color: #333; + margin-top: 20px; +} + +/* Formulaire de modification */ +form { + background-color: #fff; + padding: 20px; + border: 1px solid #ccc; + border-radius: 6px; + max-width: 600px; + margin-top: 20px; +} + +label { + display: block; + margin-bottom: 15px; + font-weight: bold; +} + +input[type="text"], +textarea { + width: 100%; + padding: 8px; + border: 1px solid #bfc9d6; + border-radius: 4px; + box-sizing: border-box; +} + +/* Boutons */ +button { + background-color: #555; /* gris foncé uniforme */ + color: #fff; + padding: 10px 15px; + border: none; + border-radius: 4px; + cursor: pointer; +} + +button:hover { + background-color: #333; +} + +/* Liens annuler */ +a { + color: #555; + text-decoration: none; + margin-left: 10px; +} + +a:hover { + text-decoration: underline; +} + +/* Messages d'erreur */ +.error { + color: #721c24; + background-color: #f8d7da; + border: 1px solid #f5c6cb; + padding: 10px; + border-radius: 5px; + margin-bottom: 15px; +} + +/* Séparateurs */ +hr { + border: 0; + border-top: 1px solid #ccc; + margin: 20px 0; +} +Propulsé par Gitea +Version: 1. \ No newline at end of file diff --git a/admin/stylesup.css b/admin/stylesup.css new file mode 100644 index 0000000..9c43fde --- /dev/null +++ b/admin/stylesup.css @@ -0,0 +1,111 @@ +/* Styles globaux */ +body { + font-family: Arial, sans-serif; + line-height: 1.6; + margin: 0; + padding: 20px; + background-color: #ececec; /* gris clair */ + color: #333; +} + +/* Header */ +header { + background-color: #555; /* gris foncé */ + color: #fff; + padding: 15px; + border-radius: 6px; + text-align: center; + margin-bottom: 20px; +} + +header h1 { + margin: 0; + font-size: 1.8rem; +} + +header p { + margin: 5px 0 0 0; +} + +header a { + color: #cfcfcf; + text-decoration: none; +} + +header a:hover { + color: #fff; + text-decoration: underline; +} + +/* Titres */ +h1, h2, h3 { + color: #333; + margin-top: 20px; +} + +/* Formulaire de modification */ +form { + background-color: #fff; + padding: 20px; + border: 1px solid #ccc; + border-radius: 6px; + max-width: 600px; + margin-top: 20px; +} + +label { + display: block; + margin-bottom: 15px; + font-weight: bold; +} + +input[type="text"], +textarea { + width: 100%; + padding: 8px; + border: 1px solid #bfc9d6; + border-radius: 4px; + box-sizing: border-box; +} + +/* Boutons */ +button { + background-color: #555; /* gris foncé uniforme */ + color: #fff; + padding: 10px 15px; + border: none; + border-radius: 4px; + cursor: pointer; +} + +button:hover { + background-color: #333; +} + +/* Liens annuler */ +a { + color: #555; + text-decoration: none; + margin-left: 10px; +} + +a:hover { + text-decoration: underline; +} + +/* Messages d'erreur */ +.error { + color: #721c24; + background-color: #f8d7da; + border: 1px solid #f5c6cb; + padding: 10px; + border-radius: 5px; + margin-bottom: 15px; +} + +/* Séparateurs */ +hr { + border: 0; + border-top: 1px solid #ccc; + margin: 20px 0; +} diff --git a/admin/supprimer.php b/admin/supprimer.php new file mode 100644 index 0000000..7025d42 --- /dev/null +++ b/admin/supprimer.php @@ -0,0 +1,64 @@ +prepare('SELECT id, titre FROM articles WHERE id = :id'); +$stmt->execute([':id' => $id]); +$article = $stmt->fetch(); + + +if (!$article) { + header('Location: board.php'); + exit; +} + + +if ($_SERVER['REQUEST_METHOD'] === 'POST') { + if (isset($_POST['confirm']) && $_POST['confirm'] === 'yes') { + + $d = $pdo->prepare('DELETE FROM articles WHERE id = :id'); + $d->execute([':id' => $id]); + } + + + header('Location: board.php'); + exit; +} +?> + + + + + + Supprimer l'article + + + + +

Supprimer l'article

+ + +

Êtes-vous sûr de vouloir supprimer : ?

+ + +
+ + Annuler +
+ + + diff --git a/assets/stylecms.css b/assets/stylecms.css new file mode 100644 index 0000000..dc962b8 --- /dev/null +++ b/assets/stylecms.css @@ -0,0 +1,165 @@ +body { + font-family: Arial, sans-serif; + line-height: 1.6; + margin: 0; + padding: 20px; + background-color: #ececec; /* gris clair */ + color: #333; +} + +/* Header */ +header { + background-color: #555; /* gris foncé */ + color: #fff; + padding: 15px; + border-radius: 6px; + text-align: center; + margin-bottom: 20px; +} + +header h1 { + margin: 0; + font-size: 1.8rem; +} + +header p { + margin: 5px 0 0 0; +} + +header a { + color: #cfcfcf; + text-decoration: none; +} + +header a:hover { + color: #fff; + text-decoration: underline; +} + +/* Titres */ +h1, h2, h3 { + color: #333; + margin-top: 20px; +} + +/* Articles */ +article { + background: #fff; + padding: 20px; + margin-bottom: 15px; + border: 1px solid #ccc; + border-radius: 6px; + box-shadow: 0 2px 4px rgba(0,0,0,0.08); +} + +article h2 a { + color: #555; + text-decoration: none; +} + +article h2 a:hover { + color: #333; + text-decoration: underline; +} + +/* Tables */ +table { + width: 100%; + border-collapse: collapse; + margin-top: 20px; + background-color: #fff; + border-radius: 6px; + overflow: hidden; + box-shadow: 0 2px 4px rgba(0,0,0,0.1); +} + +table th, table td { + padding: 10px; + border: 1px solid #ccc; + text-align: left; +} + +table th { + background-color: #bbb; /* gris moyen pour entête */ + color: #fff; +} + +table tr:nth-child(even) { + background-color: #f2f2f2; +} + +table a { + color: #555; +} + +table a:hover { + color: #333; + text-decoration: underline; +} + +/* Formulaires */ +form { + background-color: #fff; + padding: 20px; + border: 1px solid #ccc; + border-radius: 6px; + max-width: 600px; + margin-top: 20px; +} + +label { + display: block; + margin-bottom: 15px; + font-weight: bold; +} + +input[type="text"], +textarea { + width: 100%; + padding: 8px; + border: 1px solid #bfc9d6; + border-radius: 4px; + box-sizing: border-box; +} + +/* Boutons */ +button { + background-color: #555; /* gris foncé uniforme */ + color: #fff; + padding: 10px 15px; + border: none; + border-radius: 4px; + cursor: pointer; +} + +button:hover { + background-color: #333; +} + +/* Liens annuler */ +a { + color: #555; + text-decoration: none; + margin-left: 10px; +} + +a:hover { + text-decoration: underline; +} + +/* Messages d'erreur */ +.error { + color: #721c24; + background-color: #f8d7da; + border: 1px solid #f5c6cb; + padding: 10px; + border-radius: 5px; + margin-bottom: 15px; +} + +/* Séparateurs */ +hr { + border: 0; + border-top: 1px solid #ccc; + margin: 20px 0; +} \ No newline at end of file diff --git a/bdd/Dockerfile b/bdd/Dockerfile new file mode 100644 index 0000000..1b79aed --- /dev/null +++ b/bdd/Dockerfile @@ -0,0 +1,8 @@ +FROM mysql +LABEL authors="Samy" + +ENV MYSQL_ROOT_PASSWORD='123soleil' + +COPY ./init.sql /docker-entrypoint-initdb.d/ + +EXPOSE 3306 \ No newline at end of file diff --git a/bdd/init.sql b/bdd/init.sql new file mode 100644 index 0000000..388560e --- /dev/null +++ b/bdd/init.sql @@ -0,0 +1,23 @@ +CREATE DATABASE IF NOT EXISTS my_sql_CMS CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; + + +USE my_sql_CMS; + +-- Cree une classe utilisateur +CREATE TABLE utilisateur ( + id INT AUTO_INCREMENT PRIMARY KEY, + login VARCHAR(50) UNIQUE NOT NULL, + password VARCHAR(255) NOT NULL +); + +-- Cree une classe article +CREATE TABLE articles ( + id INT AUTO_INCREMENT PRIMARY KEY, + titre VARCHAR(255) NOT NULL, + contenu TEXT NOT NULL, + date_creation DATETIME DEFAULT CURRENT_TIMESTAMP +); + +-- Insert une valeur dans utilisateur +INSERT INTO utilisateur (login, password) +VALUES ('Fahym', '$2y$10$r8k200T71R2bLOFFQlZ1CuRuWg1Ah64UT/77BLTjN737ywZEWtKLu'); \ No newline at end of file diff --git a/includes/config.php b/includes/config.php new file mode 100644 index 0000000..ca1fefc --- /dev/null +++ b/includes/config.php @@ -0,0 +1,33 @@ +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: connexion.php'); + exit; + } +} +?> \ No newline at end of file diff --git a/includes/functions.php b/includes/functions.php new file mode 100644 index 0000000..ac43539 --- /dev/null +++ b/includes/functions.php @@ -0,0 +1,22 @@ +setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); + +} catch (PDOException $e) { + + echo "Erreur de connexion à la base de données : " . $e->getMessage(); + exit(); +} +?> \ No newline at end of file diff --git a/launch-dockers.sh b/launch-dockers.sh new file mode 100644 index 0000000..2212115 --- /dev/null +++ b/launch-dockers.sh @@ -0,0 +1,25 @@ +#!/bin/bash + +docker stop CMS_mysql + +docker stop CMS_php + +docker rm CMS_mysql + +docker rm CMS_php + +docker network rm CMS-bridge + +docker network create -d bridge CMS-bridge + +cd bdd + +docker build -t cms_mysql . + +docker run -d --name CMS_mysql -p 3306:3306 --network=CMS-bridge cms_mysql:latest + +cd .. + +docker build -t cms_php . + +docker run -d --name CMS_php -p 8080:80 --network=CMS-bridge cms_php:latest \ No newline at end of file diff --git a/public/Dockerfile b/public/Dockerfile new file mode 100644 index 0000000..1b79aed --- /dev/null +++ b/public/Dockerfile @@ -0,0 +1,8 @@ +FROM mysql +LABEL authors="Samy" + +ENV MYSQL_ROOT_PASSWORD='123soleil' + +COPY ./init.sql /docker-entrypoint-initdb.d/ + +EXPOSE 3306 \ No newline at end of file diff --git a/public/index.php b/public/index.php new file mode 100644 index 0000000..ed2d91f --- /dev/null +++ b/public/index.php @@ -0,0 +1,50 @@ +query($sql); +$articles = $result->fetchAll(); +?> + + + + + + + Accueil - Un CMS Quoi + + + + +
+ +
+ +
+

Articles Publiés

+ + Aucun article trouvé pour le moment.

"; + } else { + foreach ($articles as $a) { + echo ""; + } + } + ?> +
+ + + + + \ No newline at end of file diff --git a/public/public.php b/public/public.php new file mode 100644 index 0000000..2bf19fd --- /dev/null +++ b/public/public.php @@ -0,0 +1,38 @@ +prepare($sql); +$req->execute([$id]); +$article = $req->fetch(); + +if (!$article) { + echo "

404 - Article introuvable

"; + exit(); +} +?> + + + + + + <?php echo htmlspecialchars($article['titre']); ?> + + + +

+ +

+ +

← Retour à l'accueil

+ + +