Initial commit : CMS Simplifié
This commit is contained in:
54
public/admin.php
Normal file
54
public/admin.php
Normal file
@@ -0,0 +1,54 @@
|
||||
<?php
|
||||
session_start();
|
||||
if(!isset($_SESSION['user_id'])) { header('Location: login.php'); exit; }
|
||||
require __DIR__ . '/../inc/db.php';
|
||||
$stmt = $pdo->query("SELECT * FROM articles ORDER BY date_creation DESC");
|
||||
$articles = $stmt->fetchAll();
|
||||
?>
|
||||
<!doctype html>
|
||||
<html lang="fr">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width,initial-scale=1">
|
||||
<title>Administration</title>
|
||||
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet">
|
||||
<link href="assets/style.css?v=6" rel="stylesheet">
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<nav class="navbar">
|
||||
<div class="container container-narrow d-flex align-items-center gap-3">
|
||||
<a class="navbar-brand fw-semibold" href="/">CMS Simplifié</a>
|
||||
<div class="ms-auto navbar-text">Connecté: <?= htmlspecialchars($_SESSION['user_login']) ?></div>
|
||||
<a class="btn btn-outline-accent btn-sm" href="logout.php">Se déconnecter</a>
|
||||
</div>
|
||||
</nav>
|
||||
|
||||
<main class="container container-narrow py-4">
|
||||
<div class="d-flex justify-content-between align-items-center mb-3">
|
||||
<h1 class="h4 m-0">Articles</h1>
|
||||
<a class="btn btn-accent btn-sm" href="add.php">Ajouter</a>
|
||||
</div>
|
||||
|
||||
<?php if(!$articles): ?>
|
||||
<div class="alert alert-secondary">Aucun article.</div>
|
||||
<?php else: ?>
|
||||
<div class="list-group">
|
||||
<?php foreach($articles as $a): ?>
|
||||
<div class="list-group-item d-flex justify-content-between align-items-center">
|
||||
<div>
|
||||
<div class="fw-semibold item-title"><?= htmlspecialchars($a['titre']) ?></div>
|
||||
<small class="text-muted"><?= htmlspecialchars($a['date_creation']) ?></small>
|
||||
</div>
|
||||
<div class="d-flex gap-2">
|
||||
<a class="btn btn-outline-accent btn-sm" href="edit.php?id=<?= (int)$a['id'] ?>">Modifier</a>
|
||||
<a class="btn btn-danger btn-sm" href="delete.php?id=<?= (int)$a['id'] ?>">Supprimer</a>
|
||||
</div>
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
</main>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user