diff --git a/admin/ajouter.php b/admin/ajouter.php index 2db105d..4ff8268 100644 --- a/admin/ajouter.php +++ b/admin/ajouter.php @@ -1,8 +1,8 @@
- Annuler de l'anulation + Annuler de l'anulation diff --git a/admin/dashboard.php b/admin/dashboard.php index 9168ac8..89e69cc 100644 --- a/admin/dashboard.php +++ b/admin/dashboard.php @@ -1,6 +1,6 @@ query('SELECT * FROM articles ORDER BY date_creation DESC'); $articles = $stmt->fetchAll(); @@ -23,7 +23,7 @@ $articles = $stmt->fetchAll(); echo htmlspecialchars($_SESSION['user_login'] ?? 'Invité'); ?> - | Se déconnecter + | Se déconnecter

@@ -55,7 +55,7 @@ $articles = $stmt->fetchAll(); - Modifier + Modifier | Supprimer diff --git a/admin/login.php b/admin/login.php index f7fbeb0..6692966 100644 --- a/admin/login.php +++ b/admin/login.php @@ -2,33 +2,39 @@ require '../include/db.php'; require '../include/auth.php'; - -// Traite le formulaire de connexion : redirige si identifiants corrects, sinon affiche une erreur $error = ''; -f ($_SERVER['REQUEST_METHOD'] === 'POST') { -if (checikLogin($pdo, $_POST['login'], $_POST['password'])) { - header('Location: board.php'); - exit; -} else { - $error = 'Identifiants incorrects'; -} + +if ($_SERVER['REQUEST_METHOD'] === 'POST') { + $login = isset($_POST['login']) ? $_POST['login'] : ''; + $password = isset($_POST['password']) ? $_POST['password'] : ''; + + if (checkLogin($pdo, $login, $password)) { + header('Location: board.php'); + exit; + } else { + $error = 'Identifiants incorrects'; + } } ?> - Connexion - + + Connexion +

Connexion

+


-

+ + +

+ - diff --git a/admin/modifier.php b/admin/modifier.php index cd543da..420bc62 100644 --- a/admin/modifier.php +++ b/admin/modifier.php @@ -3,8 +3,8 @@ global $pdo; -require '../include/db.php'; require '../include/auth.php'; +require '../include/db.php'; requireLogin(); @@ -12,7 +12,7 @@ $id = isset($_GET['id']) ? (int)$_GET['id'] : 0; // Id est pas valide on retourne au tableau if ($id <= 0) { - header('Location: board.php'); + header('Location: dashboard.php'); exit; } @@ -23,7 +23,7 @@ $article = $stmt->fetch(); // Article est pas valide on retourne au tableau if (!$article) { - header('Location: board.php'); + header('Location: dashboard.php'); exit; } @@ -50,7 +50,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') { ]); - header('Location: board.php'); + header('Location: dashboard.php'); exit; } } @@ -81,7 +81,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
- Annuler + Annuler diff --git a/admin/styleajouter.css b/admin/styleajouter.css index 81f1a5b..854ab6e 100644 --- a/admin/styleajouter.css +++ b/admin/styleajouter.css @@ -1,83 +1,89 @@ +/* Styles globaux */ body { - font-family: Arial, sans-serif; + font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; line-height: 1.6; margin: 0; padding: 20px; - background-color: #f4f4f9; + background: linear-gradient(to right, #f4f4f9, #e2e8f0); /* léger dégradé */ color: #333; } - +/* Titres */ h1 { - color: #1e3d59; - border-bottom: 2px solid #aac4e0; - padding-bottom: 10px; + color: #1a202c; + border-bottom: 3px solid #63b3ed; + padding-bottom: 12px; margin-top: 0; + font-weight: 600; } - +/* Formulaire */ form { background-color: #fff; - padding: 20px; - border: 1px solid #d0dbe5; - border-radius: 6px; + padding: 25px; + border-radius: 10px; + box-shadow: 0 4px 12px rgba(0,0,0,0.1); max-width: 600px; margin-top: 20px; } - +/* Labels et champs */ label { display: block; - margin-bottom: 15px; - font-weight: bold; + margin-bottom: 10px; + font-weight: 600; } input[type="text"], +input[type="password"], textarea { width: 100%; - padding: 8px; - border: 1px solid #bfc9d6; - border-radius: 4px; + padding: 10px; + border: 1px solid #cbd5e0; + border-radius: 6px; 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; +/* Boutons */ +button { + background-color: #3182ce; + color: #fff; + padding: 12px 20px; + border: none; + border-radius: 6px; + cursor: pointer; + font-size: 1rem; + transition: background-color 0.3s ease; } +button:hover { + background-color: #2b6cb0; +} +/* Liens */ a { margin-left: 10px; - color: #2a73cc; + color: #3182ce; text-decoration: none; + font-weight: 500; } a:hover { text-decoration: underline; } - +/* Messages d'erreur */ .error { - color: #721c24; - background-color: #f8d7da; - border: 1px solid #f5c6cb; + color: #c53030; + background-color: #fed7d7; + border: 1px solid #f56565; padding: 10px; - border-radius: 5px; + border-radius: 6px; margin-bottom: 15px; } - +/* Responsive */ @media (max-width: 640px) { body { padding: 10px; @@ -85,4 +91,4 @@ a:hover { form { padding: 15px; } -} \ No newline at end of file +} diff --git a/admin/styleboard.css b/admin/styleboard.css index 3931627..eeb5c63 100644 --- a/admin/styleboard.css +++ b/admin/styleboard.css @@ -1,97 +1,116 @@ +/* Styles globaux */ body { - font-family: Arial, sans-serif; + font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; line-height: 1.6; margin: 0; padding: 20px; - background-color: #ececec; /* gris clair pour le fond */ + background: linear-gradient(to right, #f0f2f5, #e2e8f0); color: #333; } /* En-tête */ header { - background-color: #555; /* gris foncé */ + background-color: #2d3748; /* gris foncé plus doux */ color: #fff; - padding: 15px; - border-radius: 6px; - margin-bottom: 20px; + padding: 20px; + border-radius: 10px; + text-align: center; + margin-bottom: 25px; + box-shadow: 0 4px 12px rgba(0,0,0,0.1); } header h1 { margin: 0; - font-size: 1.8rem; + font-size: 2rem; + font-weight: 600; } header p { - margin: 5px 0 0 0; + margin: 8px 0 0 0; } header a { - color: #cfcfcf; + color: #a0aec0; text-decoration: none; + font-weight: 500; } header a:hover { - text-decoration: underline; color: #fff; + text-decoration: underline; } /* Titres */ h2, h3 { - color: #333; - margin-top: 20px; + color: #1a202c; + margin-top: 25px; + font-weight: 600; } /* Lien Ajouter un article */ a { - color: #555; + color: #3182ce; text-decoration: none; - font-weight: bold; + font-weight: 500; } a:hover { text-decoration: underline; } -/* Permet de cree des tableau */ +/* Tableau */ table { width: 100%; border-collapse: collapse; - margin-top: 15px; - background-color: #fff; /* fond blanc pour contraster */ - border-radius: 6px; + margin-top: 20px; + background-color: #fff; + border-radius: 10px; overflow: hidden; - box-shadow: 0 2px 4px rgba(0,0,0,0.1); + box-shadow: 0 4px 12px rgba(0,0,0,0.1); } table th, table td { - padding: 10px; - border: 1px solid #ccc; + padding: 12px; + border: 1px solid #e2e8f0; text-align: left; + font-size: 0.95rem; } table th { - background-color: #bbb; /* gris moyen pour l'entête */ + background-color: #4a5568; /* gris foncé pour header */ color: #fff; + font-weight: 600; } -/* Lignes de tableau */ +/* Lignes alternées */ table tr:nth-child(even) { - background-color: #f2f2f2; + background-color: #f7fafc; } /* Actions */ table a { - color: #2a73cc; + color: #3182ce; + font-weight: 500; } table a:hover { - color: #195aa7; + color: #2b6cb0; text-decoration: underline; } /* Séparateurs */ hr { border: 0; - border-top: 1px solid #ccc; - margin: 20px 0; -} \ No newline at end of file + border-top: 1px solid #cbd5e0; + margin: 25px 0; +} + +/* Responsive */ +@media (max-width: 640px) { + body { + padding: 10px; + } + table th, table td { + padding: 8px; + } +} diff --git a/admin/stylelog.css b/admin/stylelog.css index 5b65d31..4a26299 100644 --- a/admin/stylelog.css +++ b/admin/stylelog.css @@ -1,67 +1,83 @@ /* Styles globaux */ body { - font-family: Arial, sans-serif; + font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; line-height: 1.6; margin: 0; padding: 20px; - background-color: #f4f4f9; /* fond clair */ + background: linear-gradient(to right, #f0f2f5, #e2e8f0); color: #333; + display: flex; + justify-content: center; + align-items: center; + min-height: 100vh; +} + +/* Container centré */ +form { + background-color: #fff; + padding: 30px 25px; + border-radius: 12px; + box-shadow: 0 6px 20px rgba(0,0,0,0.1); + width: 100%; + max-width: 400px; + box-sizing: border-box; } /* 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; + color: #1a202c; + border-bottom: 3px solid #63b3ed; + padding-bottom: 12px; + margin-bottom: 20px; + font-weight: 600; + text-align: center; } /* Labels et inputs */ label { display: block; - margin-bottom: 15px; - font-weight: bold; + margin-bottom: 8px; + font-weight: 600; } input[type="text"], -textarea { +input[type="password"] { width: 100%; - padding: 8px; - border: 1px solid #bfc9d6; - border-radius: 4px; + padding: 10px; + border: 1px solid #cbd5e0; + border-radius: 6px; box-sizing: border-box; + font-size: 1rem; + margin-bottom: 15px; } /* Bouton */ button { - background-color: #2a73cc; + width: 100%; + background-color: #3182ce; color: #fff; - padding: 10px 15px; + padding: 12px; border: none; - border-radius: 4px; + border-radius: 6px; cursor: pointer; font-size: 1rem; + font-weight: 600; + transition: background-color 0.3s ease; } button:hover { - background-color: #195aa7; + background-color: #2b6cb0; } -/* Lien annuler */ +/* Lien annuler / autres liens */ a { - margin-left: 10px; - color: #2a73cc; + display: inline-block; + margin-top: 10px; + color: #3182ce; text-decoration: none; + font-weight: 500; + text-align: center; + width: 100%; } a:hover { @@ -70,20 +86,22 @@ a:hover { /* Messages d'erreur */ .error { - color: #721c24; - background: #f8d7da; - border: 1px solid #f5c6cb; + color: #c53030; + background-color: #fed7d7; + border: 1px solid #f56565; padding: 10px; - border-radius: 5px; + border-radius: 6px; margin-bottom: 15px; + text-align: center; } /* Responsive */ -@media (max-width: 640px) { +@media (max-width: 480px) { body { padding: 10px; } + form { - padding: 15px; + padding: 20px; } -} \ No newline at end of file +} diff --git a/admin/stylemodif.css b/admin/stylemodif.css index 9410835..5088aef 100644 --- a/admin/stylemodif.css +++ b/admin/stylemodif.css @@ -1,35 +1,42 @@ /* Styles globaux */ body { - font-family: Arial, sans-serif; + font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; line-height: 1.6; margin: 0; padding: 20px; - background-color: #ececec; /* gris clair */ + background: linear-gradient(to right, #f0f2f5, #e2e8f0); color: #333; + display: flex; + justify-content: center; + align-items: flex-start; + min-height: 100vh; } /* Header */ header { - background-color: #555; /* gris foncé */ + background-color: #2d3748; /* gris foncé plus doux */ color: #fff; - padding: 15px; - border-radius: 6px; + padding: 20px; + border-radius: 10px; text-align: center; - margin-bottom: 20px; + margin-bottom: 25px; + box-shadow: 0 4px 12px rgba(0,0,0,0.1); } header h1 { margin: 0; - font-size: 1.8rem; + font-size: 2rem; + font-weight: 600; } header p { - margin: 5px 0 0 0; + margin: 8px 0 0 0; } header a { - color: #cfcfcf; + color: #a0aec0; text-decoration: none; + font-weight: 500; } header a:hover { @@ -39,54 +46,68 @@ header a:hover { /* Titres */ h1, h2, h3 { - color: #333; - margin-top: 20px; + color: #1a202c; + margin-top: 25px; + font-weight: 600; + text-align: center; } /* Formulaire de modification */ form { background-color: #fff; - padding: 20px; - border: 1px solid #ccc; - border-radius: 6px; - max-width: 600px; + padding: 30px 25px; + border-radius: 12px; + box-shadow: 0 6px 20px rgba(0,0,0,0.1); + max-width: 500px; + width: 100%; + box-sizing: border-box; margin-top: 20px; } +/* Labels et inputs */ label { display: block; - margin-bottom: 15px; - font-weight: bold; + margin-bottom: 8px; + font-weight: 600; } input[type="text"], textarea { width: 100%; - padding: 8px; - border: 1px solid #bfc9d6; - border-radius: 4px; + padding: 10px; + border: 1px solid #cbd5e0; + border-radius: 6px; box-sizing: border-box; + font-size: 1rem; + margin-bottom: 15px; } /* Boutons */ button { - background-color: #555; /* gris foncé uniforme */ + width: 100%; + background-color: #3182ce; color: #fff; - padding: 10px 15px; + padding: 12px; border: none; - border-radius: 4px; + border-radius: 6px; cursor: pointer; + font-size: 1rem; + font-weight: 600; + transition: background-color 0.3s ease; } button:hover { - background-color: #333; + background-color: #2b6cb0; } /* Liens annuler */ a { - color: #555; + display: block; + text-align: center; + margin-top: 15px; + color: #3182ce; text-decoration: none; - margin-left: 10px; + font-weight: 500; } a:hover { @@ -95,19 +116,29 @@ a:hover { /* Messages d'erreur */ .error { - color: #721c24; - background-color: #f8d7da; - border: 1px solid #f5c6cb; + color: #c53030; + background-color: #fed7d7; + border: 1px solid #f56565; padding: 10px; - border-radius: 5px; + border-radius: 6px; margin-bottom: 15px; + text-align: center; } /* Séparateurs */ hr { border: 0; - border-top: 1px solid #ccc; - margin: 20px 0; + border-top: 1px solid #cbd5e0; + margin: 25px 0; +} + +/* Responsive */ +@media (max-width: 480px) { + body { + padding: 10px; + } + + form { + padding: 20px; + } } -Propulsé par Gitea -Version: 1. \ No newline at end of file diff --git a/admin/stylesup.css b/admin/stylesup.css index 9c43fde..7dba742 100644 --- a/admin/stylesup.css +++ b/admin/stylesup.css @@ -1,35 +1,42 @@ /* Styles globaux */ body { - font-family: Arial, sans-serif; + font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; line-height: 1.6; margin: 0; padding: 20px; - background-color: #ececec; /* gris clair */ + background: linear-gradient(to right, #f0f2f5, #e2e8f0); color: #333; + display: flex; + justify-content: center; + align-items: flex-start; + min-height: 100vh; } /* Header */ header { - background-color: #555; /* gris foncé */ + background-color: #2d3748; /* gris foncé doux */ color: #fff; - padding: 15px; - border-radius: 6px; + padding: 20px; + border-radius: 10px; text-align: center; - margin-bottom: 20px; + margin-bottom: 25px; + box-shadow: 0 4px 12px rgba(0,0,0,0.1); } header h1 { margin: 0; - font-size: 1.8rem; + font-size: 2rem; + font-weight: 600; } header p { - margin: 5px 0 0 0; + margin: 8px 0 0 0; } header a { - color: #cfcfcf; + color: #a0aec0; text-decoration: none; + font-weight: 500; } header a:hover { @@ -39,53 +46,47 @@ header a:hover { /* Titres */ h1, h2, h3 { - color: #333; - margin-top: 20px; + color: #1a202c; + margin-top: 25px; + font-weight: 600; + text-align: center; } -/* Formulaire de modification */ +/* Formulaire de confirmation de suppression */ 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 { + padding: 30px 25px; + border-radius: 12px; + box-shadow: 0 6px 20px rgba(0,0,0,0.1); + max-width: 400px; width: 100%; - padding: 8px; - border: 1px solid #bfc9d6; - border-radius: 4px; box-sizing: border-box; + margin-top: 20px; + text-align: center; } -/* Boutons */ button { - background-color: #555; /* gris foncé uniforme */ + background-color: #e53e3e; /* rouge pour danger */ color: #fff; - padding: 10px 15px; + padding: 12px 20px; border: none; - border-radius: 4px; + border-radius: 6px; cursor: pointer; + font-size: 1rem; + font-weight: 600; + margin: 0 10px; + transition: background-color 0.3s ease; } button:hover { - background-color: #333; + background-color: #c53030; } -/* Liens annuler */ a { - color: #555; + display: inline-block; text-decoration: none; + color: #3182ce; + font-weight: 500; margin-left: 10px; } @@ -95,17 +96,34 @@ a:hover { /* Messages d'erreur */ .error { - color: #721c24; - background-color: #f8d7da; - border: 1px solid #f5c6cb; + color: #c53030; + background-color: #fed7d7; + border: 1px solid #f56565; padding: 10px; - border-radius: 5px; + border-radius: 6px; margin-bottom: 15px; + text-align: center; } /* Séparateurs */ hr { border: 0; - border-top: 1px solid #ccc; - margin: 20px 0; + border-top: 1px solid #cbd5e0; + margin: 25px 0; +} + +/* Responsive */ +@media (max-width: 480px) { + body { + padding: 10px; + } + + form { + padding: 20px; + } + + button { + width: 100%; + margin: 10px 0; + } } diff --git a/admin/supprimer.php b/admin/supprimer.php index 7025d42..9ae9ffa 100644 --- a/admin/supprimer.php +++ b/admin/supprimer.php @@ -57,7 +57,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
- Annuler + Annuler
diff --git a/assets/stylecms.css b/assets/stylecms.css index dc962b8..36f3540 100644 --- a/assets/stylecms.css +++ b/assets/stylecms.css @@ -1,34 +1,42 @@ +/* Styles globaux */ body { - font-family: Arial, sans-serif; + font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; line-height: 1.6; margin: 0; padding: 20px; - background-color: #ececec; /* gris clair */ + background: linear-gradient(to right, #f0f2f5, #e2e8f0); color: #333; + display: flex; + flex-direction: column; + align-items: center; + min-height: 100vh; } /* Header */ header { - background-color: #555; /* gris foncé */ + background-color: #2d3748; /* gris foncé doux */ color: #fff; - padding: 15px; - border-radius: 6px; + padding: 20px; + border-radius: 10px; text-align: center; - margin-bottom: 20px; + margin-bottom: 25px; + box-shadow: 0 4px 12px rgba(0,0,0,0.1); } header h1 { margin: 0; - font-size: 1.8rem; + font-size: 2rem; + font-weight: 600; } header p { - margin: 5px 0 0 0; + margin: 8px 0 0 0; } header a { - color: #cfcfcf; + color: #a0aec0; text-decoration: none; + font-weight: 500; } header a:hover { @@ -38,27 +46,32 @@ header a:hover { /* Titres */ h1, h2, h3 { - color: #333; - margin-top: 20px; + color: #1a202c; + margin-top: 25px; + font-weight: 600; + text-align: center; } /* 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); + margin-bottom: 20px; + border-radius: 10px; + box-shadow: 0 4px 12px rgba(0,0,0,0.05); + width: 100%; + max-width: 700px; + box-sizing: border-box; } article h2 a { - color: #555; + color: #2d3748; text-decoration: none; + font-size: 1.2rem; } article h2 a:hover { - color: #333; + color: #1a202c; text-decoration: underline; } @@ -68,77 +81,82 @@ table { border-collapse: collapse; margin-top: 20px; background-color: #fff; - border-radius: 6px; + border-radius: 10px; overflow: hidden; - box-shadow: 0 2px 4px rgba(0,0,0,0.1); + box-shadow: 0 4px 12px rgba(0,0,0,0.05); } table th, table td { - padding: 10px; - border: 1px solid #ccc; + padding: 12px 15px; + border: 1px solid #e2e8f0; text-align: left; } table th { - background-color: #bbb; /* gris moyen pour entête */ + background-color: #4a5568; /* gris moyen foncé */ color: #fff; } table tr:nth-child(even) { - background-color: #f2f2f2; + background-color: #edf2f7; } table a { - color: #555; + color: #3182ce; + text-decoration: none; } table a:hover { - color: #333; + color: #2c5282; text-decoration: underline; } /* Formulaires */ form { background-color: #fff; - padding: 20px; - border: 1px solid #ccc; - border-radius: 6px; + padding: 25px 20px; + border-radius: 10px; + box-shadow: 0 4px 12px rgba(0,0,0,0.05); max-width: 600px; + width: 100%; margin-top: 20px; } label { display: block; margin-bottom: 15px; - font-weight: bold; + font-weight: 600; } input[type="text"], textarea { width: 100%; - padding: 8px; - border: 1px solid #bfc9d6; - border-radius: 4px; + padding: 10px; + border: 1px solid #cbd5e0; + border-radius: 6px; box-sizing: border-box; } /* Boutons */ button { - background-color: #555; /* gris foncé uniforme */ + background-color: #2b6cb0; /* bleu uniforme */ color: #fff; - padding: 10px 15px; + padding: 12px 20px; border: none; - border-radius: 4px; + border-radius: 6px; cursor: pointer; + font-weight: 600; + margin-top: 10px; + transition: background-color 0.3s ease; } button:hover { - background-color: #333; + background-color: #2c5282; } -/* Liens annuler */ +/* Liens */ a { - color: #555; + color: #3182ce; text-decoration: none; margin-left: 10px; } @@ -149,17 +167,35 @@ a:hover { /* Messages d'erreur */ .error { - color: #721c24; - background-color: #f8d7da; - border: 1px solid #f5c6cb; - padding: 10px; - border-radius: 5px; + color: #c53030; + background-color: #fed7d7; + border: 1px solid #f56565; + padding: 12px; + border-radius: 6px; margin-bottom: 15px; + text-align: center; } /* Séparateurs */ hr { border: 0; - border-top: 1px solid #ccc; - margin: 20px 0; -} \ No newline at end of file + border-top: 1px solid #cbd5e0; + margin: 25px 0; +} + +/* Responsive */ +@media (max-width: 480px) { + body { + padding: 10px; + } + + form, article, table { + width: 100%; + padding: 15px; + } + + button { + width: 100%; + margin: 10px 0; + } +} diff --git a/bdd/init.sql b/bdd/init.sql index 388560e..3e7379b 100644 --- a/bdd/init.sql +++ b/bdd/init.sql @@ -1,16 +1,16 @@ +-- Création de la base de données si elle n'existe pas CREATE DATABASE IF NOT EXISTS my_sql_CMS CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; - USE my_sql_CMS; --- Cree une classe utilisateur +-- Table des utilisateurs CREATE TABLE utilisateur ( id INT AUTO_INCREMENT PRIMARY KEY, login VARCHAR(50) UNIQUE NOT NULL, password VARCHAR(255) NOT NULL ); --- Cree une classe article +-- Table des articles CREATE TABLE articles ( id INT AUTO_INCREMENT PRIMARY KEY, titre VARCHAR(255) NOT NULL, @@ -18,6 +18,6 @@ CREATE TABLE articles ( date_creation DATETIME DEFAULT CURRENT_TIMESTAMP ); --- Insert une valeur dans utilisateur +-- Utilisateur de test (login: Samy, mot de passe hashé) INSERT INTO utilisateur (login, password) -VALUES ('Fahym', '$2y$10$r8k200T71R2bLOFFQlZ1CuRuWg1Ah64UT/77BLTjN737ywZEWtKLu'); \ No newline at end of file +VALUES ('Samy', '$2b$12$sIZ8j1yq/w36QcHwYY29COy.UE8Iu8yLJep36l.zXQgxLFGHgrmOa'); diff --git a/include/auth.php b/include/auth.php new file mode 100644 index 0000000..90ee767 --- /dev/null +++ b/include/auth.php @@ -0,0 +1,33 @@ +prepare('SELECT * FROM utilisateur WHERE login = ?'); + $stmt->execute([$login]); + $user = $stmt->fetch(); + + // Vérifie le mot de passe hashé + if ($user && password_verify($password, $user['password'])) { + $_SESSION['user'] = $user['login']; // Stocke le login en session + return true; + } + + return false; +} + +// Redirige vers la page de connexion si l'utilisateur n'est pas connecté +function requireLogin(): void { + if (!isLogged()) { + header('Location: connexion.php'); + exit; + } +} +?> diff --git a/include/db.php b/include/db.php new file mode 100644 index 0000000..4907b30 --- /dev/null +++ b/include/db.php @@ -0,0 +1,21 @@ +setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); + +} catch (PDOException $e) { + // Affiche l'erreur si la connexion échoue + echo "Erreur de connexion à la base de données : " . $e->getMessage(); + exit(); +} +?> diff --git a/includes/config.php b/includes/config.php deleted file mode 100644 index ca1fefc..0000000 --- a/includes/config.php +++ /dev/null @@ -1,33 +0,0 @@ -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 deleted file mode 100644 index ac43539..0000000 --- a/includes/functions.php +++ /dev/null @@ -1,22 +0,0 @@ -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/public/Dockerfile b/public/Dockerfile index 1b79aed..d8e26f9 100644 --- a/public/Dockerfile +++ b/public/Dockerfile @@ -1,8 +1,9 @@ -FROM mysql +FROM php:8.2-apache LABEL authors="Samy" -ENV MYSQL_ROOT_PASSWORD='123soleil' +COPY . /var/www/html +WORKDIR /var/www/html -COPY ./init.sql /docker-entrypoint-initdb.d/ +RUN docker-php-ext-install pdo pdo_mysql -EXPOSE 3306 \ No newline at end of file +EXPOSE 8 \ No newline at end of file diff --git a/public/index.php b/public/index.php index ed2d91f..44076dd 100644 --- a/public/index.php +++ b/public/index.php @@ -43,7 +43,7 @@ $articles = $result->fetchAll(); diff --git a/public/public.php b/public/public.php index 2bf19fd..581022f 100644 --- a/public/public.php +++ b/public/public.php @@ -1,19 +1,17 @@ prepare($sql); -$req->execute([$id]); -$article = $req->fetch(); +// Récupération de l'ID depuis l'URL, par défaut 0 si absent +$id = isset($_GET['id']) ? (int)$_GET['id'] : 0; +// Préparation et exécution de la requête SQL +$stmt = $pdo->prepare('SELECT * FROM articles WHERE id = ?'); +$stmt->execute([$id]); +$article = $stmt->fetch(); + +// Si l'article n'existe pas, afficher un message 404 if (!$article) { echo "

404 - Article introuvable

"; exit(); @@ -24,13 +22,14 @@ if (!$article) { - <?php echo htmlspecialchars($article['titre']); ?> + <?= htmlspecialchars($article['titre']) ?> -

+

-

+ +

← Retour à l'accueil