diff --git a/html/news.php b/html/news.php index 1d0cc24a..7eb0671d 100644 --- a/html/news.php +++ b/html/news.php @@ -45,7 +45,28 @@ if (filter_var($_GET['article'], FILTER_VALIDATE_INT)) {
prepare("SELECT ID, titre, date FROM articles WHERE classification <= :accreditation AND titre LIKE :search ORDER BY date DESC"); + $req->bindParam(":search", $search); + $req->bindParam(":accreditation", $_SESSION['accreditation']); + $req->execute(); + $resultat = $req->fetchAll(PDO::FETCH_ASSOC); + + echo "

Dernières news du Club

"; + echo "
"; + + if ($resultat) { + foreach($resultat as $row) { + $date = strtotime($row['date']); + echo "
"; + echo ""; + echo "
" . $row['titre'] . "
"; + echo "
"; + } + } + } else if (!isset($_GET['search']) && $article != "" && file_exists('/var/www/e59/content/journal/' . $article . '.md')) { $markdownContent = file_get_contents('/var/www/e59/content/journal/' . $article . '.md'); require_once '../include/parsedown.php'; @@ -68,27 +89,6 @@ if (filter_var($_GET['article'], FILTER_VALIDATE_INT)) { echo $parsedown->text($markdownContent); echo "
"; } - } else { - $bdd = connect($dbhost, $dbname, $dbuser, $dbpass); - $search = isset($_GET['search']) ? "'%" . htmlspecialchars($_GET['search']) . "%'" : "'%'"; - $req = $bdd->prepare("SELECT ID, titre, date FROM articles WHERE classification <= :accreditation AND titre LIKE :search ORDER BY date DESC"); - $req->bindParam(":search", $search); - $req->bindParam(":accreditation", $_SESSION['accreditation']); - $req->execute(); - $resultat = $req->fetchAll(PDO::FETCH_ASSOC); - - echo "

Dernières news du Club

"; - echo "
"; - - if ($resultat) { - foreach($resultat as $row) { - $date = strtotime($row['date']); - echo "
"; - echo ""; - echo "
" . $row['titre'] . "
"; - echo "
" . date('d/m/Y', $date) . "
"; - } - } } ?>