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

8
public/Dockerfile Normal file
View 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
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>

38
public/public.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>