SaeDEV2.2/php/event.php

94 lines
2.6 KiB
PHP
Raw Normal View History

2024-06-16 15:02:27 +02:00
<?php
require_once 'common.php';
session_start();
if (empty($_GET['id'])) {
header('Location: evenement.php');
exit();
}
$db = initDatabase();
$req = mysqli_query($db,"SELECT * FROM evenement WHERE id=" .$_GET['id']);
$event=mysqli_fetch_assoc($req);
$req = mysqli_query($db,"SELECT * FROM commentaire WHERE id_event=" . $_GET['id']);
$commentaire=mysqli_fetch_all($req,MYSQLI_ASSOC);
?>
<head>
<meta charset="utf-8">
<link rel="icon" href="../img/jo2024.jpg">
<link rel="stylesheet" href="../css/style.css">
<title>Évènements - Jeux Olympiques</title>
</head>
<body>
<header>
<h1 class='Hello'>Évènement</h1>
<nav>
<?php
if (isset($_SESSION['login'])) {
echo " <a href='../' class='categorie'>Page d'accueil</a>";
echo " <a href='profil.php'><img class='profil' src='https://dwarves.iut-fbleau.fr/~ghouar-t/SaeDEV2.2/img/photo-profil.png' alt='profil'></a>";
echo "<a href='deconnexion.php' class='categorie'>Déconnexion</a>";
}
else {
echo "<a href='../' class='categorie'>Page d'accueil</a>";
echo "<a href='connexion.php' class='categorie'>Connexion</a>";
echo "<a href='inscription.php' class='categorie'>Inscription</a>";
}
?>
</nav>
</header>
<body container>
<?php
echo '<div id="article">'
. '<h3>'. $event['title'] .'</h3>'
. '<div id="content">' . $event['description'] . '</div>';
echo '<h5 class="_bb1">Commentaires</h5>';
if (empty($commentaire)) {
echo '<p>Aucun</p>';
} else {
foreach ($commentaire as $com) {
echo '<section class="alert-box">';
echo "<b class='_ts2'>".$com['title']."</b>"
. (isset($_SESSION['user']['id']) && $com['id_user'] == $_SESSION['user']['id'] ?
' <a href="comment_create.php?id_article=' . $com['id_article']
. '&amp;id_comment=' . $com['id'] . '" title="'. $com['title']
. '">Modifier ce commentaire</a>' :
'')
. '<p class="_ts2">' . $comment['content'] ."</p>"
. "<p><span class='tag-box -warning'><a href=\"".$comment['url']."\">".$comment['login']."</a></p>";
echo "</section>";
}
}
echo "</div>";
if (empty($_SESSION['user'])) {
echo '<p>Il faut être identifié pour poster un commentaire.</p>';
} else {
if ($article['closed']) {
echo "<p>Article fermé, non modifiable.</p>";
} else {
echo '<p> <a href="comment_create.php?id_article='. $article['id']
.'">Ajouter un commentaire</a> avec votre compte : ' . $_SESSION['user']['name']
.' </p>';
}
}
?>
<p> <a href="article_list.php">Retour à la liste des articles</a> </p>
<?php
include 'footer.php';
?>
</body>
</html>