Update 4 files

- /html/editpage.php
- /html/journal.php
- /html/upload.php
- /html/users.php
This commit is contained in:
Jan BELLON 2024-03-07 20:52:48 +00:00
parent 39f8085492
commit 03bd67ca7d
4 changed files with 84 additions and 4 deletions

View File

@ -119,7 +119,7 @@ if(isset($fichier)) {
echo "</div></div><div>";
echo "<div><h2>Articles</h2></div>";
$bdd = connect($dbhost, $dbname, $dbuser, $dbpass);
$req = $bdd->prepare("SELECT ID, titre, auteur, date FROM articles WHERE classification <= :role ORDER BY date DESC LIMIT 10");
$req = $bdd->prepare("SELECT ID, titre, auteur, date, classification FROM articles WHERE classification <= :role ORDER BY date DESC LIMIT 10");
$req->bindParam(":role", $_SESSION['role']);
$req->execute();
$resultat = $req->fetchAll(PDO::FETCH_ASSOC);
@ -128,7 +128,7 @@ if(isset($fichier)) {
if ($resultat) {
foreach($resultat as $row) {
echo "<a href='?article=" . $row['ID'] . "' class='article-link'><div class='article'><div class='article-content'><div><h1>" . $row['titre'] . "</h1></div><div><h2>" . $row['auteur'] . "</h2></div><div>" . $date->format('d/m/Y') . "</div></div></div></a>";
echo "<a href='?article=" . $row['ID'] . "' class='article-link'><div class='article'><div class='article-content'><div><h1>" . $row['titre'] . "</h1></div><div>Classification : " . $classifications[$row['classificaation']] . "</div><div><h2>" . $row['auteur'] . "</h2></div><div>" . $date->format('d/m/Y') . "</div></div></div></a>";
}
}
echo "</div>";

View File

@ -64,7 +64,7 @@ if (filter_var($_GET['article'], FILTER_VALIDATE_INT)) {
if ($resultat) {
foreach($resultat as $row) {
echo "<a href='?article=" . $row['ID'] . "' class='article-link'><div class='article'><div class='article-content'><div><h1>" . $row['titre'] . "</h1></div><div><h2>" . $row['auteur'] . "</h2></div><div>" . $date->format('d/m/Y') . "</div></div></div></a>";
echo "<a href='?article=" . $row['ID'] . "' class='article-link'><div class='article'><div class='article-content'><div><h1>" . $row['titre'] . "</h1></div><div>Classification : " . $classifications[$row['classificaation']] . "</div><div><h2>" . $row['auteur'] . "</h2></div><div>" . $date->format('d/m/Y') . "</div></div></div></a>";
}
}
}

View File

@ -79,7 +79,7 @@ if(isset($_POST['page-content'])) {
<div><input type="text" name="titre" placeholder="Titre"></div>
<div><textarea name="page-content"></textarea></div>
<div>
<select name="classification" id="cars" required>
<select name="classification" required>
<?php foreach($classifications as $id => $nom) { echo '<option value="' . $id .'">' . $nom . '</option>'; }?>
</select>
</div>

80
html/users.php Normal file
View File

@ -0,0 +1,80 @@
<?php
require "../include/variables.php";
require "../include/functions.php";
if($role < 4) {
header("Location: login.php");
http_response_code(404);
die();
}
?>
<!DOCTYPE html>
<html lang="fr">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="./src/css/style.css">
<link rel="icon" href="src/img/favicon.ico">
<title><?=$title?></title>
</head>
<body>
<header>
<div class="pancontent">
<div class="athena-container">
<a href="/">
<img src="./src/img/athena-mono.png" class="athena">
</a>
</div>
<div class="content">
<div>
<div class="main-title">
<div class="title"><?=$header_title?></div>
<div class="subtitle"><?=$header_subtitle?></div>
</div>
</div>
</div>
</div>
</header>
<nav>
<div class="pancontent">
<?php nav($nav);?>
</div>
</nav>
<main>
<div class="content">
<div>
<div>
<?php
$bdd = connect($dbhost, $dbname, $dbuser, $dbpass);
$req = $bdd->prepare("SELECT display_name, username, email, role FROM users ORDER BY creation_date DESC");
$req->execute();
$resultat = $req->fetchAll(PDO::FETCH_ASSOC);
if ($resultat) {
foreach($resultat as $row) {
echo "<div><form action='' method='post'><div>" . $row['display_name'] . "</div><div>" . $row['username'] . "</div><div>" . $row['email'] . "</div><div><select name='role' required>";
foreach($classifications as $id => $nom) {
if($req['role'] == $id) {
echo '<option value="' . $id .'">' . $nom . '</option>';
} else {
echo '<option value="' . $id .'" selected>' . $nom . '</option>';
}
}
echo "</select><input type='submit' value='Mettre à jour'</div></form></div>";
}
}
?>
</div>
</div>
</div>
</main>
<footer>
<div class="content">
<div>
<div><?=$copyright?></div>
</div>
</div>
</footer>
</body>
</html>