quelque amelioration

This commit is contained in:
2025-11-02 23:20:42 +01:00
parent 26c06eae90
commit 296b5c5a62
19 changed files with 461 additions and 328 deletions

View File

@@ -1,8 +1,8 @@
<?php <?php
require '../include/db.php';
require '../include/auth.php'; require '../include/auth.php';
require '../include/db.php';
requireLogin(); requireLogin();
@@ -61,7 +61,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
</label><br> </label><br>
<button type="submit">Publier de la publication</button> <button type="submit">Publier de la publication</button>
<a href="board.php">Annuler de l'anulation</a> <a href="dashboard.php">Annuler de l'anulation</a>
</form> </form>
</body> </body>

View File

@@ -1,6 +1,6 @@
<?php <?php
require '../include/db.php';
require '../include/auth.php'; require '../include/auth.php';
require '../include/db.php';
requireLogin(); requireLogin();
$stmt = $pdo->query('SELECT * FROM articles ORDER BY date_creation DESC'); $stmt = $pdo->query('SELECT * FROM articles ORDER BY date_creation DESC');
$articles = $stmt->fetchAll(); $articles = $stmt->fetchAll();
@@ -23,7 +23,7 @@ $articles = $stmt->fetchAll();
echo htmlspecialchars($_SESSION['user_login'] ?? 'Invité'); echo htmlspecialchars($_SESSION['user_login'] ?? 'Invité');
?> ?>
<!-- retourne a la page de deconnexion --> <!-- retourne a la page de deconnexion -->
| <a href="deconnexion.php">Se déconnecter</a> | <a href="logout.php">Se déconnecter</a>
</p> </p>
</header> </header>
@@ -55,7 +55,7 @@ $articles = $stmt->fetchAll();
<td><?php echo htmlspecialchars($article['titre']); ?></td> <td><?php echo htmlspecialchars($article['titre']); ?></td>
<td><?php echo $article['date_creation']; ?></td> <td><?php echo $article['date_creation']; ?></td>
<td> <td>
<a href="modification.php?id=<?php echo $article['id']; ?>">Modifier</a> <a href="modifier.php?id=<?php echo $article['id']; ?>">Modifier</a>
| |
<a href="supprimer.php?id=<?php echo $article['id']; ?>">Supprimer</a> <a href="supprimer.php?id=<?php echo $article['id']; ?>">Supprimer</a>
</td> </td>

View File

@@ -2,11 +2,13 @@
require '../include/db.php'; require '../include/db.php';
require '../include/auth.php'; require '../include/auth.php';
// Traite le formulaire de connexion : redirige si identifiants corrects, sinon affiche une erreur
$error = ''; $error = '';
f ($_SERVER['REQUEST_METHOD'] === 'POST') {
if (checikLogin($pdo, $_POST['login'], $_POST['password'])) { 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'); header('Location: board.php');
exit; exit;
} else { } else {
@@ -18,17 +20,21 @@ if (checikLogin($pdo, $_POST['login'], $_POST['password'])) {
<!DOCTYPE html> <!DOCTYPE html>
<html lang="fr"> <html lang="fr">
<head> <head>
<meta charset="UTF-8"><title>Connexion</title> <meta charset="UTF-8">
<link rel="stylesheet" href="styleco.css"> <title>Connexion</title>
<link rel="stylesheet" href="stylelog.css">
</head> </head>
<body> <body>
<h1>Connexion</h1> <h1>Connexion</h1>
<form method="post"> <form method="post">
<input type="text" name="login" placeholder="Login" required><br> <input type="text" name="login" placeholder="Login" required><br>
<input type="password" name="password" placeholder="Mot de passe" required><br> <input type="password" name="password" placeholder="Mot de passe" required><br>
<button type="submit">Se connecter</button> <button type="submit">Se connecter</button>
</form> </form>
<p style="color:red;"><?= $error ?></p>
<?php if ($error): ?>
<p style="color:red;"><?= htmlspecialchars($error) ?></p>
<?php endif; ?>
</body> </body>
</html> </html>

View File

@@ -3,8 +3,8 @@
global $pdo; global $pdo;
require '../include/db.php';
require '../include/auth.php'; require '../include/auth.php';
require '../include/db.php';
requireLogin(); requireLogin();
@@ -12,7 +12,7 @@ $id = isset($_GET['id']) ? (int)$_GET['id'] : 0;
// Id est pas valide on retourne au tableau // Id est pas valide on retourne au tableau
if ($id <= 0) { if ($id <= 0) {
header('Location: board.php'); header('Location: dashboard.php');
exit; exit;
} }
@@ -23,7 +23,7 @@ $article = $stmt->fetch();
// Article est pas valide on retourne au tableau // Article est pas valide on retourne au tableau
if (!$article) { if (!$article) {
header('Location: board.php'); header('Location: dashboard.php');
exit; exit;
} }
@@ -50,7 +50,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
]); ]);
header('Location: board.php'); header('Location: dashboard.php');
exit; exit;
} }
} }
@@ -81,7 +81,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
<textarea name="contenu" rows="10" required><?= htmlspecialchars($contenu) ?></textarea> <textarea name="contenu" rows="10" required><?= htmlspecialchars($contenu) ?></textarea>
</label><br> </label><br>
<button type="submit">Enregistrer</button> <button type="submit">Enregistrer</button>
<a href="board.php">Annuler</a> <a href="dashboard.php">Annuler</a>
</form> </form>
</body> </body>

View File

@@ -1,83 +1,89 @@
/* Styles globaux */
body { body {
font-family: Arial, sans-serif; font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
line-height: 1.6; line-height: 1.6;
margin: 0; margin: 0;
padding: 20px; padding: 20px;
background-color: #f4f4f9; background: linear-gradient(to right, #f4f4f9, #e2e8f0); /* léger dégradé */
color: #333; color: #333;
} }
/* Titres */
h1 { h1 {
color: #1e3d59; color: #1a202c;
border-bottom: 2px solid #aac4e0; border-bottom: 3px solid #63b3ed;
padding-bottom: 10px; padding-bottom: 12px;
margin-top: 0; margin-top: 0;
font-weight: 600;
} }
/* Formulaire */
form { form {
background-color: #fff; background-color: #fff;
padding: 20px; padding: 25px;
border: 1px solid #d0dbe5; border-radius: 10px;
border-radius: 6px; box-shadow: 0 4px 12px rgba(0,0,0,0.1);
max-width: 600px; max-width: 600px;
margin-top: 20px; margin-top: 20px;
} }
/* Labels et champs */
label { label {
display: block; display: block;
margin-bottom: 15px; margin-bottom: 10px;
font-weight: bold; font-weight: 600;
} }
input[type="text"], input[type="text"],
input[type="password"],
textarea { textarea {
width: 100%; width: 100%;
padding: 8px; padding: 10px;
border: 1px solid #bfc9d6; border: 1px solid #cbd5e0;
border-radius: 4px; border-radius: 6px;
box-sizing: border-box; box-sizing: border-box;
}
button {
background-color: #2a73cc;
color: #fff;
padding: 10px 15px;
border: none;
border-radius: 4px;
cursor: pointer;
font-size: 1rem; font-size: 1rem;
} }
button:hover { /* Boutons */
background-color: #195aa7; 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 { a {
margin-left: 10px; margin-left: 10px;
color: #2a73cc; color: #3182ce;
text-decoration: none; text-decoration: none;
font-weight: 500;
} }
a:hover { a:hover {
text-decoration: underline; text-decoration: underline;
} }
/* Messages d'erreur */
.error { .error {
color: #721c24; color: #c53030;
background-color: #f8d7da; background-color: #fed7d7;
border: 1px solid #f5c6cb; border: 1px solid #f56565;
padding: 10px; padding: 10px;
border-radius: 5px; border-radius: 6px;
margin-bottom: 15px; margin-bottom: 15px;
} }
/* Responsive */
@media (max-width: 640px) { @media (max-width: 640px) {
body { body {
padding: 10px; padding: 10px;

View File

@@ -1,97 +1,116 @@
/* Styles globaux */
body { body {
font-family: Arial, sans-serif; font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
line-height: 1.6; line-height: 1.6;
margin: 0; margin: 0;
padding: 20px; padding: 20px;
background-color: #ececec; /* gris clair pour le fond */ background: linear-gradient(to right, #f0f2f5, #e2e8f0);
color: #333; color: #333;
} }
/* En-tête */ /* En-tête */
header { header {
background-color: #555; /* gris foncé */ background-color: #2d3748; /* gris foncé plus doux */
color: #fff; color: #fff;
padding: 15px; padding: 20px;
border-radius: 6px; border-radius: 10px;
margin-bottom: 20px; text-align: center;
margin-bottom: 25px;
box-shadow: 0 4px 12px rgba(0,0,0,0.1);
} }
header h1 { header h1 {
margin: 0; margin: 0;
font-size: 1.8rem; font-size: 2rem;
font-weight: 600;
} }
header p { header p {
margin: 5px 0 0 0; margin: 8px 0 0 0;
} }
header a { header a {
color: #cfcfcf; color: #a0aec0;
text-decoration: none; text-decoration: none;
font-weight: 500;
} }
header a:hover { header a:hover {
text-decoration: underline;
color: #fff; color: #fff;
text-decoration: underline;
} }
/* Titres */ /* Titres */
h2, h3 { h2, h3 {
color: #333; color: #1a202c;
margin-top: 20px; margin-top: 25px;
font-weight: 600;
} }
/* Lien Ajouter un article */ /* Lien Ajouter un article */
a { a {
color: #555; color: #3182ce;
text-decoration: none; text-decoration: none;
font-weight: bold; font-weight: 500;
} }
a:hover { a:hover {
text-decoration: underline; text-decoration: underline;
} }
/* Permet de cree des tableau */ /* Tableau */
table { table {
width: 100%; width: 100%;
border-collapse: collapse; border-collapse: collapse;
margin-top: 15px; margin-top: 20px;
background-color: #fff; /* fond blanc pour contraster */ background-color: #fff;
border-radius: 6px; border-radius: 10px;
overflow: hidden; 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 { table th, table td {
padding: 10px; padding: 12px;
border: 1px solid #ccc; border: 1px solid #e2e8f0;
text-align: left; text-align: left;
font-size: 0.95rem;
} }
table th { table th {
background-color: #bbb; /* gris moyen pour l'entête */ background-color: #4a5568; /* gris foncé pour header */
color: #fff; color: #fff;
font-weight: 600;
} }
/* Lignes de tableau */ /* Lignes alternées */
table tr:nth-child(even) { table tr:nth-child(even) {
background-color: #f2f2f2; background-color: #f7fafc;
} }
/* Actions */ /* Actions */
table a { table a {
color: #2a73cc; color: #3182ce;
font-weight: 500;
} }
table a:hover { table a:hover {
color: #195aa7; color: #2b6cb0;
text-decoration: underline; text-decoration: underline;
} }
/* Séparateurs */ /* Séparateurs */
hr { hr {
border: 0; border: 0;
border-top: 1px solid #ccc; border-top: 1px solid #cbd5e0;
margin: 20px 0; margin: 25px 0;
}
/* Responsive */
@media (max-width: 640px) {
body {
padding: 10px;
}
table th, table td {
padding: 8px;
}
} }

View File

@@ -1,67 +1,83 @@
/* Styles globaux */ /* Styles globaux */
body { body {
font-family: Arial, sans-serif; font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
line-height: 1.6; line-height: 1.6;
margin: 0; margin: 0;
padding: 20px; padding: 20px;
background-color: #f4f4f9; /* fond clair */ background: linear-gradient(to right, #f0f2f5, #e2e8f0);
color: #333; 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 */ /* Titres */
h1 { h1 {
color: #1e3d59; /* bleu foncé */ color: #1a202c;
border-bottom: 2px solid #aac4e0; border-bottom: 3px solid #63b3ed;
padding-bottom: 10px; padding-bottom: 12px;
margin-top: 0; margin-bottom: 20px;
} font-weight: 600;
text-align: center;
/* Formulaire */
form {
background: #fff;
padding: 20px;
border-radius: 6px;
border: 1px solid #d0dbe5;
max-width: 600px;
margin-top: 20px;
} }
/* Labels et inputs */ /* Labels et inputs */
label { label {
display: block; display: block;
margin-bottom: 15px; margin-bottom: 8px;
font-weight: bold; font-weight: 600;
} }
input[type="text"], input[type="text"],
textarea { input[type="password"] {
width: 100%; width: 100%;
padding: 8px; padding: 10px;
border: 1px solid #bfc9d6; border: 1px solid #cbd5e0;
border-radius: 4px; border-radius: 6px;
box-sizing: border-box; box-sizing: border-box;
font-size: 1rem;
margin-bottom: 15px;
} }
/* Bouton */ /* Bouton */
button { button {
background-color: #2a73cc; width: 100%;
background-color: #3182ce;
color: #fff; color: #fff;
padding: 10px 15px; padding: 12px;
border: none; border: none;
border-radius: 4px; border-radius: 6px;
cursor: pointer; cursor: pointer;
font-size: 1rem; font-size: 1rem;
font-weight: 600;
transition: background-color 0.3s ease;
} }
button:hover { button:hover {
background-color: #195aa7; background-color: #2b6cb0;
} }
/* Lien annuler */ /* Lien annuler / autres liens */
a { a {
margin-left: 10px; display: inline-block;
color: #2a73cc; margin-top: 10px;
color: #3182ce;
text-decoration: none; text-decoration: none;
font-weight: 500;
text-align: center;
width: 100%;
} }
a:hover { a:hover {
@@ -70,20 +86,22 @@ a:hover {
/* Messages d'erreur */ /* Messages d'erreur */
.error { .error {
color: #721c24; color: #c53030;
background: #f8d7da; background-color: #fed7d7;
border: 1px solid #f5c6cb; border: 1px solid #f56565;
padding: 10px; padding: 10px;
border-radius: 5px; border-radius: 6px;
margin-bottom: 15px; margin-bottom: 15px;
text-align: center;
} }
/* Responsive */ /* Responsive */
@media (max-width: 640px) { @media (max-width: 480px) {
body { body {
padding: 10px; padding: 10px;
} }
form { form {
padding: 15px; padding: 20px;
} }
} }

View File

@@ -1,35 +1,42 @@
/* Styles globaux */ /* Styles globaux */
body { body {
font-family: Arial, sans-serif; font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
line-height: 1.6; line-height: 1.6;
margin: 0; margin: 0;
padding: 20px; padding: 20px;
background-color: #ececec; /* gris clair */ background: linear-gradient(to right, #f0f2f5, #e2e8f0);
color: #333; color: #333;
display: flex;
justify-content: center;
align-items: flex-start;
min-height: 100vh;
} }
/* Header */ /* Header */
header { header {
background-color: #555; /* gris foncé */ background-color: #2d3748; /* gris foncé plus doux */
color: #fff; color: #fff;
padding: 15px; padding: 20px;
border-radius: 6px; border-radius: 10px;
text-align: center; text-align: center;
margin-bottom: 20px; margin-bottom: 25px;
box-shadow: 0 4px 12px rgba(0,0,0,0.1);
} }
header h1 { header h1 {
margin: 0; margin: 0;
font-size: 1.8rem; font-size: 2rem;
font-weight: 600;
} }
header p { header p {
margin: 5px 0 0 0; margin: 8px 0 0 0;
} }
header a { header a {
color: #cfcfcf; color: #a0aec0;
text-decoration: none; text-decoration: none;
font-weight: 500;
} }
header a:hover { header a:hover {
@@ -39,54 +46,68 @@ header a:hover {
/* Titres */ /* Titres */
h1, h2, h3 { h1, h2, h3 {
color: #333; color: #1a202c;
margin-top: 20px; margin-top: 25px;
font-weight: 600;
text-align: center;
} }
/* Formulaire de modification */ /* Formulaire de modification */
form { form {
background-color: #fff; background-color: #fff;
padding: 20px; padding: 30px 25px;
border: 1px solid #ccc; border-radius: 12px;
border-radius: 6px; box-shadow: 0 6px 20px rgba(0,0,0,0.1);
max-width: 600px; max-width: 500px;
width: 100%;
box-sizing: border-box;
margin-top: 20px; margin-top: 20px;
} }
/* Labels et inputs */
label { label {
display: block; display: block;
margin-bottom: 15px; margin-bottom: 8px;
font-weight: bold; font-weight: 600;
} }
input[type="text"], input[type="text"],
textarea { textarea {
width: 100%; width: 100%;
padding: 8px; padding: 10px;
border: 1px solid #bfc9d6; border: 1px solid #cbd5e0;
border-radius: 4px; border-radius: 6px;
box-sizing: border-box; box-sizing: border-box;
font-size: 1rem;
margin-bottom: 15px;
} }
/* Boutons */ /* Boutons */
button { button {
background-color: #555; /* gris foncé uniforme */ width: 100%;
background-color: #3182ce;
color: #fff; color: #fff;
padding: 10px 15px; padding: 12px;
border: none; border: none;
border-radius: 4px; border-radius: 6px;
cursor: pointer; cursor: pointer;
font-size: 1rem;
font-weight: 600;
transition: background-color 0.3s ease;
} }
button:hover { button:hover {
background-color: #333; background-color: #2b6cb0;
} }
/* Liens annuler */ /* Liens annuler */
a { a {
color: #555; display: block;
text-align: center;
margin-top: 15px;
color: #3182ce;
text-decoration: none; text-decoration: none;
margin-left: 10px; font-weight: 500;
} }
a:hover { a:hover {
@@ -95,19 +116,29 @@ a:hover {
/* Messages d'erreur */ /* Messages d'erreur */
.error { .error {
color: #721c24; color: #c53030;
background-color: #f8d7da; background-color: #fed7d7;
border: 1px solid #f5c6cb; border: 1px solid #f56565;
padding: 10px; padding: 10px;
border-radius: 5px; border-radius: 6px;
margin-bottom: 15px; margin-bottom: 15px;
text-align: center;
} }
/* Séparateurs */ /* Séparateurs */
hr { hr {
border: 0; border: 0;
border-top: 1px solid #ccc; border-top: 1px solid #cbd5e0;
margin: 20px 0; margin: 25px 0;
}
/* Responsive */
@media (max-width: 480px) {
body {
padding: 10px;
}
form {
padding: 20px;
}
} }
Propulsé par Gitea
Version: 1.

View File

@@ -1,35 +1,42 @@
/* Styles globaux */ /* Styles globaux */
body { body {
font-family: Arial, sans-serif; font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
line-height: 1.6; line-height: 1.6;
margin: 0; margin: 0;
padding: 20px; padding: 20px;
background-color: #ececec; /* gris clair */ background: linear-gradient(to right, #f0f2f5, #e2e8f0);
color: #333; color: #333;
display: flex;
justify-content: center;
align-items: flex-start;
min-height: 100vh;
} }
/* Header */ /* Header */
header { header {
background-color: #555; /* gris foncé */ background-color: #2d3748; /* gris foncé doux */
color: #fff; color: #fff;
padding: 15px; padding: 20px;
border-radius: 6px; border-radius: 10px;
text-align: center; text-align: center;
margin-bottom: 20px; margin-bottom: 25px;
box-shadow: 0 4px 12px rgba(0,0,0,0.1);
} }
header h1 { header h1 {
margin: 0; margin: 0;
font-size: 1.8rem; font-size: 2rem;
font-weight: 600;
} }
header p { header p {
margin: 5px 0 0 0; margin: 8px 0 0 0;
} }
header a { header a {
color: #cfcfcf; color: #a0aec0;
text-decoration: none; text-decoration: none;
font-weight: 500;
} }
header a:hover { header a:hover {
@@ -39,53 +46,47 @@ header a:hover {
/* Titres */ /* Titres */
h1, h2, h3 { h1, h2, h3 {
color: #333; color: #1a202c;
margin-top: 20px; margin-top: 25px;
font-weight: 600;
text-align: center;
} }
/* Formulaire de modification */ /* Formulaire de confirmation de suppression */
form { form {
background-color: #fff; background-color: #fff;
padding: 20px; padding: 30px 25px;
border: 1px solid #ccc; border-radius: 12px;
border-radius: 6px; box-shadow: 0 6px 20px rgba(0,0,0,0.1);
max-width: 600px; max-width: 400px;
margin-top: 20px;
}
label {
display: block;
margin-bottom: 15px;
font-weight: bold;
}
input[type="text"],
textarea {
width: 100%; width: 100%;
padding: 8px;
border: 1px solid #bfc9d6;
border-radius: 4px;
box-sizing: border-box; box-sizing: border-box;
margin-top: 20px;
text-align: center;
} }
/* Boutons */
button { button {
background-color: #555; /* gris foncé uniforme */ background-color: #e53e3e; /* rouge pour danger */
color: #fff; color: #fff;
padding: 10px 15px; padding: 12px 20px;
border: none; border: none;
border-radius: 4px; border-radius: 6px;
cursor: pointer; cursor: pointer;
font-size: 1rem;
font-weight: 600;
margin: 0 10px;
transition: background-color 0.3s ease;
} }
button:hover { button:hover {
background-color: #333; background-color: #c53030;
} }
/* Liens annuler */
a { a {
color: #555; display: inline-block;
text-decoration: none; text-decoration: none;
color: #3182ce;
font-weight: 500;
margin-left: 10px; margin-left: 10px;
} }
@@ -95,17 +96,34 @@ a:hover {
/* Messages d'erreur */ /* Messages d'erreur */
.error { .error {
color: #721c24; color: #c53030;
background-color: #f8d7da; background-color: #fed7d7;
border: 1px solid #f5c6cb; border: 1px solid #f56565;
padding: 10px; padding: 10px;
border-radius: 5px; border-radius: 6px;
margin-bottom: 15px; margin-bottom: 15px;
text-align: center;
} }
/* Séparateurs */ /* Séparateurs */
hr { hr {
border: 0; border: 0;
border-top: 1px solid #ccc; border-top: 1px solid #cbd5e0;
margin: 20px 0; margin: 25px 0;
}
/* Responsive */
@media (max-width: 480px) {
body {
padding: 10px;
}
form {
padding: 20px;
}
button {
width: 100%;
margin: 10px 0;
}
} }

View File

@@ -57,7 +57,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
<form method="post"> <form method="post">
<button type="submit" name="confirm" value="yes">Oui</button> <button type="submit" name="confirm" value="yes">Oui</button>
<a href="board.php">Annuler</a> <a href="dashboard.php">Annuler</a>
</form> </form>
</body> </body>

View File

@@ -1,34 +1,42 @@
/* Styles globaux */
body { body {
font-family: Arial, sans-serif; font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
line-height: 1.6; line-height: 1.6;
margin: 0; margin: 0;
padding: 20px; padding: 20px;
background-color: #ececec; /* gris clair */ background: linear-gradient(to right, #f0f2f5, #e2e8f0);
color: #333; color: #333;
display: flex;
flex-direction: column;
align-items: center;
min-height: 100vh;
} }
/* Header */ /* Header */
header { header {
background-color: #555; /* gris foncé */ background-color: #2d3748; /* gris foncé doux */
color: #fff; color: #fff;
padding: 15px; padding: 20px;
border-radius: 6px; border-radius: 10px;
text-align: center; text-align: center;
margin-bottom: 20px; margin-bottom: 25px;
box-shadow: 0 4px 12px rgba(0,0,0,0.1);
} }
header h1 { header h1 {
margin: 0; margin: 0;
font-size: 1.8rem; font-size: 2rem;
font-weight: 600;
} }
header p { header p {
margin: 5px 0 0 0; margin: 8px 0 0 0;
} }
header a { header a {
color: #cfcfcf; color: #a0aec0;
text-decoration: none; text-decoration: none;
font-weight: 500;
} }
header a:hover { header a:hover {
@@ -38,27 +46,32 @@ header a:hover {
/* Titres */ /* Titres */
h1, h2, h3 { h1, h2, h3 {
color: #333; color: #1a202c;
margin-top: 20px; margin-top: 25px;
font-weight: 600;
text-align: center;
} }
/* Articles */ /* Articles */
article { article {
background: #fff; background: #fff;
padding: 20px; padding: 20px;
margin-bottom: 15px; margin-bottom: 20px;
border: 1px solid #ccc; border-radius: 10px;
border-radius: 6px; box-shadow: 0 4px 12px rgba(0,0,0,0.05);
box-shadow: 0 2px 4px rgba(0,0,0,0.08); width: 100%;
max-width: 700px;
box-sizing: border-box;
} }
article h2 a { article h2 a {
color: #555; color: #2d3748;
text-decoration: none; text-decoration: none;
font-size: 1.2rem;
} }
article h2 a:hover { article h2 a:hover {
color: #333; color: #1a202c;
text-decoration: underline; text-decoration: underline;
} }
@@ -68,77 +81,82 @@ table {
border-collapse: collapse; border-collapse: collapse;
margin-top: 20px; margin-top: 20px;
background-color: #fff; background-color: #fff;
border-radius: 6px; border-radius: 10px;
overflow: hidden; 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 { table th, table td {
padding: 10px; padding: 12px 15px;
border: 1px solid #ccc; border: 1px solid #e2e8f0;
text-align: left; text-align: left;
} }
table th { table th {
background-color: #bbb; /* gris moyen pour entête */ background-color: #4a5568; /* gris moyen foncé */
color: #fff; color: #fff;
} }
table tr:nth-child(even) { table tr:nth-child(even) {
background-color: #f2f2f2; background-color: #edf2f7;
} }
table a { table a {
color: #555; color: #3182ce;
text-decoration: none;
} }
table a:hover { table a:hover {
color: #333; color: #2c5282;
text-decoration: underline; text-decoration: underline;
} }
/* Formulaires */ /* Formulaires */
form { form {
background-color: #fff; background-color: #fff;
padding: 20px; padding: 25px 20px;
border: 1px solid #ccc; border-radius: 10px;
border-radius: 6px; box-shadow: 0 4px 12px rgba(0,0,0,0.05);
max-width: 600px; max-width: 600px;
width: 100%;
margin-top: 20px; margin-top: 20px;
} }
label { label {
display: block; display: block;
margin-bottom: 15px; margin-bottom: 15px;
font-weight: bold; font-weight: 600;
} }
input[type="text"], input[type="text"],
textarea { textarea {
width: 100%; width: 100%;
padding: 8px; padding: 10px;
border: 1px solid #bfc9d6; border: 1px solid #cbd5e0;
border-radius: 4px; border-radius: 6px;
box-sizing: border-box; box-sizing: border-box;
} }
/* Boutons */ /* Boutons */
button { button {
background-color: #555; /* gris foncé uniforme */ background-color: #2b6cb0; /* bleu uniforme */
color: #fff; color: #fff;
padding: 10px 15px; padding: 12px 20px;
border: none; border: none;
border-radius: 4px; border-radius: 6px;
cursor: pointer; cursor: pointer;
font-weight: 600;
margin-top: 10px;
transition: background-color 0.3s ease;
} }
button:hover { button:hover {
background-color: #333; background-color: #2c5282;
} }
/* Liens annuler */ /* Liens */
a { a {
color: #555; color: #3182ce;
text-decoration: none; text-decoration: none;
margin-left: 10px; margin-left: 10px;
} }
@@ -149,17 +167,35 @@ a:hover {
/* Messages d'erreur */ /* Messages d'erreur */
.error { .error {
color: #721c24; color: #c53030;
background-color: #f8d7da; background-color: #fed7d7;
border: 1px solid #f5c6cb; border: 1px solid #f56565;
padding: 10px; padding: 12px;
border-radius: 5px; border-radius: 6px;
margin-bottom: 15px; margin-bottom: 15px;
text-align: center;
} }
/* Séparateurs */ /* Séparateurs */
hr { hr {
border: 0; border: 0;
border-top: 1px solid #ccc; border-top: 1px solid #cbd5e0;
margin: 20px 0; margin: 25px 0;
}
/* Responsive */
@media (max-width: 480px) {
body {
padding: 10px;
}
form, article, table {
width: 100%;
padding: 15px;
}
button {
width: 100%;
margin: 10px 0;
}
} }

View File

@@ -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; CREATE DATABASE IF NOT EXISTS my_sql_CMS CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
USE my_sql_CMS; USE my_sql_CMS;
-- Cree une classe utilisateur -- Table des utilisateurs
CREATE TABLE utilisateur ( CREATE TABLE utilisateur (
id INT AUTO_INCREMENT PRIMARY KEY, id INT AUTO_INCREMENT PRIMARY KEY,
login VARCHAR(50) UNIQUE NOT NULL, login VARCHAR(50) UNIQUE NOT NULL,
password VARCHAR(255) NOT NULL password VARCHAR(255) NOT NULL
); );
-- Cree une classe article -- Table des articles
CREATE TABLE articles ( CREATE TABLE articles (
id INT AUTO_INCREMENT PRIMARY KEY, id INT AUTO_INCREMENT PRIMARY KEY,
titre VARCHAR(255) NOT NULL, titre VARCHAR(255) NOT NULL,
@@ -18,6 +18,6 @@ CREATE TABLE articles (
date_creation DATETIME DEFAULT CURRENT_TIMESTAMP 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) INSERT INTO utilisateur (login, password)
VALUES ('Fahym', '$2y$10$r8k200T71R2bLOFFQlZ1CuRuWg1Ah64UT/77BLTjN737ywZEWtKLu'); VALUES ('Samy', '$2b$12$sIZ8j1yq/w36QcHwYY29COy.UE8Iu8yLJep36l.zXQgxLFGHgrmOa');

33
include/auth.php Normal file
View File

@@ -0,0 +1,33 @@
<?php
// Gestion de la connexion et de l'authentification des utilisateurs
session_start(); // Démarrage de la session
// Vérifie si un utilisateur est connecté
function isLogged(): bool {
return isset($_SESSION['user']);
}
// Vérifie les identifiants et connecte l'utilisateur si valides
function checkLogin(PDO $pdo, string $login, string $password): bool {
$stmt = $pdo->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;
}
}
?>

21
include/db.php Normal file
View File

@@ -0,0 +1,21 @@
<?php
// Connexion à la base de données avec PDO
$serveur = "CMS"; // Adresse du serveur MySQL
$dbname = "CMS_sql"; // Nom de la base
$user = "root"; // Utilisateur MySQL
$pass = "123soleil"; // Mot de passe
try {
// Création de la connexion PDO
$pdo = new PDO("mysql:host=$serveur;dbname=$dbname", $user, $pass);
// Active le mode d'erreur Exception pour PDO
$pdo->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();
}
?>

View File

@@ -1,33 +0,0 @@
<?php
// Fichier gérant la connexion et l'authentification des utilisateurs
session_start();
function isLogged() {
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: connexion.php');
exit;
}
}
?>

View File

@@ -1,22 +0,0 @@
<?php
// Fichier de connexion à la base de données
$serveur = "UnCMS"; // Adresse du serveur MySQL
$dbname = "my_sql_CMS"; // Nom de la base de données
$user = "root"; // Utilisateur MySQL
$pass = "12345"; // Mot de passe
try {
$pdo = new PDO("mysql:host=$serveur;dbname=$dbname", $user, $pass);
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
} catch (PDOException $e) {
echo "Erreur de connexion à la base de données : " . $e->getMessage();
exit();
}
?>

View File

@@ -1,8 +1,9 @@
FROM mysql FROM php:8.2-apache
LABEL authors="Samy" 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 EXPOSE 8

View File

@@ -43,7 +43,7 @@ $articles = $result->fetchAll();
</main> </main>
<footer> <footer>
<p>&copy; <?php echo date("Y"); ?> - Un CMS qui peut nous mener a la victoire</p> <p>&copy; <?php echo date("Y"); ?> - Un CMS simple et efficace</p>
</footer> </footer>
</body> </body>

View File

@@ -1,19 +1,17 @@
<?php <?php
// Page qui affiche un article selon son id dans l'URL // Page qui affiche un article selon son ID
include 'include/db.php'; require 'include/db.php'; // Connexion à la base
if (isset($_GET['id'])) { // Récupération de l'ID depuis l'URL, par défaut 0 si absent
$id = (int)$_GET['id']; $id = isset($_GET['id']) ? (int)$_GET['id'] : 0;
} else {
$id = 0;
}
// Requête SQL pour récupérer toutes les infos de l'article avec l'id donné
$sql = "SELECT * FROM articles WHERE id = ?";
$req = $pdo->prepare($sql);
$req->execute([$id]);
$article = $req->fetch();
// 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) { if (!$article) {
echo "<h1>404 - Article introuvable</h1>"; echo "<h1>404 - Article introuvable</h1>";
exit(); exit();
@@ -24,13 +22,14 @@ if (!$article) {
<html lang="fr"> <html lang="fr">
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8">
<title><?php echo htmlspecialchars($article['titre']); ?></title> <title><?= htmlspecialchars($article['titre']) ?></title>
</head> </head>
<body> <body>
<h1><?php echo htmlspecialchars($article['titre']); ?></h1> <h1><?= htmlspecialchars($article['titre']) ?></h1>
<p><?php echo nl2br(htmlspecialchars($article['contenu'])); ?></p> <!-- nl2br pour garder les retours à la ligne dans le contenu -->
<p><?= nl2br(htmlspecialchars($article['contenu'])) ?></p>
<p><a href="index.php">← Retour à l'accueil</a></p> <p><a href="index.php">← Retour à l'accueil</a></p>