first commit
This commit is contained in:
8
.idea/.gitignore
generated
vendored
Normal file
8
.idea/.gitignore
generated
vendored
Normal file
@@ -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
|
||||
8
.idea/CMS.iml
generated
Normal file
8
.idea/CMS.iml
generated
Normal file
@@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module type="WEB_MODULE" version="4">
|
||||
<component name="NewModuleRootManager">
|
||||
<content url="file://$MODULE_DIR$" />
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
</component>
|
||||
</module>
|
||||
6
.idea/inspectionProfiles/Project_Default.xml
generated
Normal file
6
.idea/inspectionProfiles/Project_Default.xml
generated
Normal file
@@ -0,0 +1,6 @@
|
||||
<component name="InspectionProjectProfileManager">
|
||||
<profile version="1.0">
|
||||
<option name="myName" value="Project Default" />
|
||||
<inspection_tool class="SqlNoDataSourceInspection" enabled="false" level="WARNING" enabled_by_default="false" />
|
||||
</profile>
|
||||
</component>
|
||||
8
.idea/modules.xml
generated
Normal file
8
.idea/modules.xml
generated
Normal file
@@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectModuleManager">
|
||||
<modules>
|
||||
<module fileurl="file://$PROJECT_DIR$/.idea/CMS.iml" filepath="$PROJECT_DIR$/.idea/CMS.iml" />
|
||||
</modules>
|
||||
</component>
|
||||
</project>
|
||||
19
.idea/php.xml
generated
Normal file
19
.idea/php.xml
generated
Normal file
@@ -0,0 +1,19 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="MessDetectorOptionsConfiguration">
|
||||
<option name="transferred" value="true" />
|
||||
</component>
|
||||
<component name="PHPCSFixerOptionsConfiguration">
|
||||
<option name="transferred" value="true" />
|
||||
</component>
|
||||
<component name="PHPCodeSnifferOptionsConfiguration">
|
||||
<option name="highlightLevel" value="WARNING" />
|
||||
<option name="transferred" value="true" />
|
||||
</component>
|
||||
<component name="PhpStanOptionsConfiguration">
|
||||
<option name="transferred" value="true" />
|
||||
</component>
|
||||
<component name="PsalmOptionsConfiguration">
|
||||
<option name="transferred" value="true" />
|
||||
</component>
|
||||
</project>
|
||||
6
.idea/vcs.xml
generated
Normal file
6
.idea/vcs.xml
generated
Normal file
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="VcsDirectoryMappings">
|
||||
<mapping directory="$PROJECT_DIR$" vcs="Git" />
|
||||
</component>
|
||||
</project>
|
||||
68
admin/ajouter.php
Normal file
68
admin/ajouter.php
Normal 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
69
admin/dashboard.php
Normal 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
34
admin/login.php
Normal 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
27
admin/logout.php
Normal 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
88
admin/modifier.php
Normal 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
88
admin/styleajouter.css
Normal 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
97
admin/styleboard.css
Normal 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
89
admin/stylelog.css
Normal 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
113
admin/stylemodif.css
Normal 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
111
admin/stylesup.css
Normal 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
64
admin/supprimer.php
Normal 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>
|
||||
165
assets/stylecms.css
Normal file
165
assets/stylecms.css
Normal file
@@ -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;
|
||||
}
|
||||
8
bdd/Dockerfile
Normal file
8
bdd/Dockerfile
Normal file
@@ -0,0 +1,8 @@
|
||||
FROM mysql
|
||||
LABEL authors="Samy"
|
||||
|
||||
ENV MYSQL_ROOT_PASSWORD='123soleil'
|
||||
|
||||
COPY ./init.sql /docker-entrypoint-initdb.d/
|
||||
|
||||
EXPOSE 3306
|
||||
23
bdd/init.sql
Normal file
23
bdd/init.sql
Normal file
@@ -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');
|
||||
33
includes/config.php
Normal file
33
includes/config.php
Normal file
@@ -0,0 +1,33 @@
|
||||
<?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;
|
||||
}
|
||||
}
|
||||
?>
|
||||
22
includes/functions.php
Normal file
22
includes/functions.php
Normal file
@@ -0,0 +1,22 @@
|
||||
<?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();
|
||||
}
|
||||
?>
|
||||
25
launch-dockers.sh
Normal file
25
launch-dockers.sh
Normal file
@@ -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
|
||||
8
public/Dockerfile
Normal file
8
public/Dockerfile
Normal file
@@ -0,0 +1,8 @@
|
||||
FROM mysql
|
||||
LABEL authors="Samy"
|
||||
|
||||
ENV MYSQL_ROOT_PASSWORD='123soleil'
|
||||
|
||||
COPY ./init.sql /docker-entrypoint-initdb.d/
|
||||
|
||||
EXPOSE 3306
|
||||
50
public/index.php
Normal file
50
public/index.php
Normal file
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
include 'include/db.php';
|
||||
|
||||
$sql = "SELECT * FROM articles ORDER BY date_creation DESC LIMIT 10";
|
||||
$result = $pdo->query($sql);
|
||||
$articles = $result->fetchAll();
|
||||
?>
|
||||
|
||||
<!-- Page Principal -->
|
||||
<!DOCTYPE html>
|
||||
<html lang="fr">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Accueil - Un CMS Quoi</title>
|
||||
<link rel="stylesheet" href="assets/style.css">
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<header>
|
||||
<nav>
|
||||
<a href="index.php">Un Accueil qui Accueil</a> |
|
||||
<a href="admin/connexion.php">Administration</a>
|
||||
</nav>
|
||||
</header>
|
||||
|
||||
<main>
|
||||
<h1>Articles Publiés</h1>
|
||||
|
||||
<?php
|
||||
if (count($articles) == 0) {
|
||||
echo "<p>Aucun article trouvé pour le moment.</p>";
|
||||
} else {
|
||||
foreach ($articles as $a) {
|
||||
echo "<article>";
|
||||
echo "<h2><a href='article.php?id=" . $a['id'] . "'>" . htmlspecialchars($a['titre']) . "</a></h2>";
|
||||
echo "<small>Publie le " . date("d/m/Y", strtotime($a['date_creation'])) . "</small>";
|
||||
echo "<p>" . substr(htmlspecialchars($a['contenu']), 0, 200) . "...</p>";
|
||||
echo "<p><a href='article.php?id=" . $a['id'] . "'>Lire la suite</a></p>";
|
||||
echo "</article>";
|
||||
}
|
||||
}
|
||||
?>
|
||||
</main>
|
||||
|
||||
<footer>
|
||||
<p>© <?php echo date("Y"); ?> - Un CMS qui peut nous mener a la victoire</p>
|
||||
</footer>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
38
public/public.php
Normal file
38
public/public.php
Normal file
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
// Page qui affiche un article selon son id dans l'URL
|
||||
|
||||
include 'include/db.php';
|
||||
|
||||
if (isset($_GET['id'])) {
|
||||
$id = (int)$_GET['id'];
|
||||
} 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();
|
||||
|
||||
if (!$article) {
|
||||
echo "<h1>404 - Article introuvable</h1>";
|
||||
exit();
|
||||
}
|
||||
?>
|
||||
|
||||
<!DOCTYPE html>
|
||||
<html lang="fr">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title><?php echo htmlspecialchars($article['titre']); ?></title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<h1><?php echo htmlspecialchars($article['titre']); ?></h1>
|
||||
|
||||
<p><?php echo nl2br(htmlspecialchars($article['contenu'])); ?></p>
|
||||
|
||||
<p><a href="index.php">← Retour à l'accueil</a></p>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user