first commit

This commit is contained in:
2025-11-02 21:27:45 +01:00
commit 9f268216d8
27 changed files with 1275 additions and 0 deletions

68
admin/ajouter.php Normal file
View File

@@ -0,0 +1,68 @@
<?php
require '../include/db.php';
require '../include/auth.php';
requireLogin();
$errors = [];
$titre = '';
$contenu = '';
// Vérifie si le formulaire a été soumis en méthode
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$titre = trim($_POST['titre'] ?? '');
$contenu = trim($_POST['contenu'] ?? '');
if ($titre === '' || $contenu === '') {
$errors[] = 'Tous les champs sont obligatoires.';
} else {
$stmt = $pdo->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;
}
}
?>
<!doctype html>
<html lang="fr">
<head>
<meta charset="utf-8">
<title>Ajouter un article</title>
<link rel="stylesheet" href="styleajouter.css">
</head>
<body>
<h1>Ajouter un article</h1>
<?php foreach ($errors as $e): ?>
<p class="error"><?= htmlspecialchars($e) ?></p>
<?php endforeach; ?>
<form method="post">
<label>Titre<br>
<input type="text" name="titre" value="<?= htmlspecialchars($titre) ?>" required>
</label><br>
<label>Contenu<br>
<textarea name="contenu" rows="10" required><?= htmlspecialchars($contenu) ?></textarea>
</label><br>
<button type="submit">Publier de la publication</button>
<a href="board.php">Annuler de l'anulation</a>
</form>
</body>
</html>

69
admin/dashboard.php Normal file
View File

@@ -0,0 +1,69 @@
<?php
require '../include/db.php';
require '../include/auth.php';
requireLogin();
$stmt = $pdo->query('SELECT * FROM articles ORDER BY date_creation DESC');
$articles = $stmt->fetchAll();
?>
<!-- Page Du Tableau de board -->
<!DOCTYPE html>
<html lang="fr" dir="ltr">
<head>
<meta charset="UTF-8">
<title>Tableau de Bord</title>
<link rel="stylesheet" href="styleboard.css">
</head>
<body>
<header>
<h1>Tableau de Bord de bordination</h1>
<p>
Connecté en tant que
<?php
echo htmlspecialchars($_SESSION['user_login'] ?? 'Invité');
?>
<!-- retourne a la page de deconnexion -->
| <a href="deconnexion.php">Se déconnecter</a>
</p>
</header>
<hr>
<main>
<!-- Page pour ajouter un article -->
<h2>Gestion des articles</h2>
<a href="ajouter.php">Ajouter un nouvel article</a>
<hr>
<h3>Vos articles publiés</h3>
<table border="1">
<thead>
<tr>
<th>ID</th>
<th>Titre</th>
<th>Date de création</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
<?php foreach ($articles as $article) : ?>
<tr>
<td><?php echo $article['id']; ?></td>
<td><?php echo htmlspecialchars($article['titre']); ?></td>
<td><?php echo $article['date_creation']; ?></td>
<td>
<a href="modification.php?id=<?php echo $article['id']; ?>">Modifier</a>
|
<a href="supprimer.php?id=<?php echo $article['id']; ?>">Supprimer</a>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</main>
</body>
</html>

34
admin/login.php Normal file
View File

@@ -0,0 +1,34 @@
<?php
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';
}
}
?>
<!DOCTYPE html>
<html lang="fr">
<head>
<meta charset="UTF-8"><title>Connexion</title>
<link rel="stylesheet" href="styleco.css">
</head>
<body>
<h1>Connexion</h1>
<form method="post">
<input type="text" name="login" placeholder="Login" required><br>
<input type="password" name="password" placeholder="Mot de passe" required><br>
<button type="submit">Se connecter</button>
</form>
<p style="color:red;"><?= $error ?></p>
</body>
</html>

27
admin/logout.php Normal file
View File

@@ -0,0 +1,27 @@
<?php
session_start(); // Démarrer la session
$_SESSION = [];
if (ini_get('session.use_cookies')) {
$params = session_get_cookie_params();
setcookie(
session_name(),
'',
time() - 42000,
$params['path'],
$params['domain'],
$params['secure'],
$params['httponly']
);
}
session_destroy();
header('Location: ../index.php');
exit;
?>

88
admin/modifier.php Normal file
View File

@@ -0,0 +1,88 @@
<?php
// Page pour modifier un article
global $pdo;
require '../include/db.php';
require '../include/auth.php';
requireLogin();
$id = isset($_GET['id']) ? (int)$_GET['id'] : 0;
// Id est pas valide on retourne au tableau
if ($id <= 0) {
header('Location: board.php');
exit;
}
$stmt = $pdo->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;
}
}
?>
<!doctype html>
<html lang="fr">
<head>
<meta charset="utf-8">
<title>Modifier l'article</title>
<link rel="stylesheet" href="stylemodif.css">
</head>
<body>
<h1>Modifier l'article</h1>
<?php foreach ($errors as $e): ?>
<p class="error"><?= htmlspecialchars($e) ?></p>
<?php endforeach; ?>
>
<form method="post">
<label>Un Titre Quoi<br>
<input type="text" name="titre" value="<?= htmlspecialchars($titre) ?>" required>
</label><br>
<label>Contenu<br>
<textarea name="contenu" rows="10" required><?= htmlspecialchars($contenu) ?></textarea>
</label><br>
<button type="submit">Enregistrer</button>
<a href="board.php">Annuler</a>
</form>
</body>
</html>

88
admin/styleajouter.css Normal file
View File

@@ -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;
}
}

97
admin/styleboard.css Normal file
View File

@@ -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;
}

89
admin/stylelog.css Normal file
View File

@@ -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;
}
}

113
admin/stylemodif.css Normal file
View File

@@ -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.

111
admin/stylesup.css Normal file
View File

@@ -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;
}

64
admin/supprimer.php Normal file
View File

@@ -0,0 +1,64 @@
<?php
// Page pour supprimer un article
require '../include/db.php';
require '../include/auth.php';
requireLogin();
// Récupération de l'id de l'article depuis l'URL
$id = isset($_GET['id']) ? (int)$_GET['id'] : 0;
// Si l'id n'est pas valide, retour au tableau
if ($id <= 0) {
header('Location: board.php');
exit;
}
// Récupérer le titre de l'article pour l'afficher
$stmt = $pdo->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;
}
?>
<!doctype html>
<html lang="fr">
<head>
<meta charset="utf-8">
<title>Supprimer l'article</title>
<link rel="stylesheet" href="stylesup.css">
</head>
<body>
<h1>Supprimer l'article</h1>
<p>Êtes-vous sûr de vouloir supprimer : <strong><?= htmlspecialchars($article['titre']) ?></strong> ?</p>
<form method="post">
<button type="submit" name="confirm" value="yes">Oui</button>
<a href="board.php">Annuler</a>
</form>
</body>
</html>