first commit

This commit is contained in:
2025-11-02 17:57:39 +01:00
commit d5330c0eb0
21 changed files with 1243 additions and 0 deletions

9
Dockerfile Normal file
View File

@@ -0,0 +1,9 @@
FROM php:8.2-apache
LABEL authors="Fahym"
COPY . /var/www/html
WORKDIR /var/www/html
RUN docker-php-ext-install pdo pdo_mysql
EXPOSE 80

36
README.md Normal file
View File

@@ -0,0 +1,36 @@
## Contenue du ficher
/admin
ajouter.php **Ajouter un article** styleajouter.css
board.php **Tableau de bord** styleboard.css
connexion.php **Se connecter** styleco.css
deconexion.php **Se deconnecter**
modification.php **Modifier un Article** stylemodif.css
supprimer.php **Supprimer un article** stylesup.css
/assets
style.css **css du index**
/bdd
dockerfile
init.sql **Base de donnee**
/include
auth.php **Fonctions dauthentification**
db.php **Connexion à la base de données**
index.php - Page daccueil affichant les articles récents
article.php - Page pour afficher un article spécifique
## Lancement avec docker
**./launch-dockers.sh**
Pour ce connecter:
Login : Fahym
Mot de passe : Fahym
MYSQL_ROOT_PASSWORD='12345'

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/board.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/connexion.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/deconnexion.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/modification.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;
}
}

98
admin/styleboard.css Normal file
View File

@@ -0,0 +1,98 @@
/* Design de toute la page*/
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/styleco.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;
}
}

111
admin/stylemodif.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;
}

98
admin/stylesup.css Normal file
View File

@@ -0,0 +1,98 @@
/* Styles de toute la page */
body {
font-family: Arial, sans-serif;
line-height: 1.6;
margin: 0;
padding: 20px;
background-color: #ececec; /* gris clair */
color: #333;
}
/* La Tete */
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;
}
form {
background-color: #fff;
padding: 20px;
border: 1px solid #ccc;
border-radius: 6px;
max-width: 400px;
margin-top: 20px;
}
button {
background-color: #555; /* gris foncé uniforme */
color: #fff;
padding: 10px 15px;
border: none;
border-radius: 4px;
cursor: pointer;
}
button:hover {
background-color: #333;
}
/* Lien annuler */
a {
color: #555;
text-decoration: none;
margin-left: 10px;
}
a:hover {
text-decoration: underline;
}
.error {
color: #721c24;
background-color: #f8d7da;
border: 1px solid #f5c6cb;
padding: 10px;
border-radius: 5px;
margin-bottom: 15px;
}
hr {
border: 0;
border-top: 1px solid #ccc;
margin: 20px 0;
}
strong {
color: #222;
}

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>

38
article.php Normal file
View 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>

165
assets/style.css Normal file
View 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
View File

@@ -0,0 +1,8 @@
FROM mysql
LABEL authors="Fahym"
ENV MYSQL_ROOT_PASSWORD='12345'
COPY ./init.sql /docker-entrypoint-initdb.d/
EXPOSE 3306

23
bdd/init.sql Normal file
View 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
include/auth.php Normal file
View 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
include/db.php Normal file
View 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();
}
?>

50
index.php Normal file
View 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>&copy; <?php echo date("Y"); ?> - Un CMS qui peut nous mener a la victoire</p>
</footer>
</body>
</html>

25
launch-dockers.sh Normal file
View File

@@ -0,0 +1,25 @@
#!/bin/bash
docker stop UnCMS
docker stop CMS_php
docker rm UnCMS
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 UnCMS -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