-
Notifications
You must be signed in to change notification settings - Fork 0
/
show-article.php
50 lines (42 loc) · 1.56 KB
/
show-article.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
<?php
$filename = __DIR__ . '/data/articles.json';
$articles = [];
$_GET = filter_input_array(INPUT_GET, FILTER_SANITIZE_FULL_SPECIAL_CHARS);
$id = $_GET['id'] ?? '';
if (!$id) {
header('Location: /');
} else {
if (file_exists($filename)) {
$articles = json_decode(file_get_contents($filename), true) ?? [];
$articleIndex = array_search($id, array_column($articles, 'id'));
$article = $articles[$articleIndex];
}
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<?php require_once 'includes/head.php' ?>
<link rel="stylesheet" href="/public/css/show-article.css">
<title>Article</title>
</head>
<body>
<div class="container">
<?php require_once 'includes/header.php' ?>
<div class="content">
<div class="article-container">
<a class="article-back" href="/">Retour à la liste des articles</a>
<div class="article-cover-img" style="background-image:url(<?= $article['image'] ?>)"></div>
<h1 class="article-title"><?= $article['title'] ?></h1>
<div class="separator"></div>
<p class="article-content"><?= $article['content'] ?></p>
<div class="action">
<a class="btn btn-secondary" href="/delete-article.php?id=<?= $article['id'] ?>">Supprimer</a>
<a class="btn btn-primary" href="/form-article.php?id=<?= $article['id'] ?>">Editer l'article</a>
</div>
</div>
</div>
<?php require_once 'includes/footer.php' ?>
</div>
</body>
</html>