ébauche de panel admin
This commit is contained in:
parent
c4e80659ba
commit
aafb825e30
@ -52,6 +52,9 @@ if (isset($_COOKIE['userData'])) {
|
||||
echo "<p class='text'>Bienvenue sur le panneau d'administration du site.</p>";
|
||||
echo "<p class='text'>Vous pouvez ici gérer les utilisateurs.</p>";
|
||||
echo "<p class='text'>Que souhaitez-vous faire ?</p>";
|
||||
echo "<p class='text'><a href='/admin/users'>Gérer les utilisateurs</a></p>";
|
||||
|
||||
;
|
||||
//contenu de la page admin
|
||||
} ?>
|
||||
|
||||
|
95
admin/users/index.php
Normal file
95
admin/users/index.php
Normal file
@ -0,0 +1,95 @@
|
||||
<?php
|
||||
require_once $_SERVER['DOCUMENT_ROOT'] . '/tools/dbConnect.php';
|
||||
|
||||
if (isset($_COOKIE['userData'])) {
|
||||
$userDataEncoded = $_COOKIE['userData'];
|
||||
$userData = json_decode($userDataEncoded, true); // 'true' pour obtenir un tableau associatif
|
||||
|
||||
$email = $userData['email'];
|
||||
$name = $userData['name'];
|
||||
$familyName = $userData['familyName'];
|
||||
$role = $userData['role'];
|
||||
}
|
||||
?>
|
||||
|
||||
<!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="/styles/main.css" />
|
||||
<link rel="stylesheet" href="/styles/header.css" />
|
||||
<link rel="stylesheet" href="/styles/footer.css" />
|
||||
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css" rel="stylesheet" />
|
||||
|
||||
<link rel="icon" type="image/png" sizes="32x32"
|
||||
href="https://tickets.paris2024.org/obj/media/FR-Paris2024/specialLogos/favicons/favicon-32x32.png" />
|
||||
<script src="https://kit.fontawesome.com/f16a36bad3.js" crossorigin="anonymous"></script>
|
||||
<title>Jeux Olympiques - Paris 2024</title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<?php include ($_SERVER['DOCUMENT_ROOT'] . '/views/header.php') ?>
|
||||
|
||||
<!-- code de la page ici -->
|
||||
<h1>Gestion des utilisateurs</h1>
|
||||
<?php
|
||||
if (!isset($_COOKIE['userData'])) {
|
||||
echo "<p class='text'>Vous n'êtes pas autorisé à accéder à cette page.</p>";
|
||||
echo "<p class='text'>Redirection vers l'accueil dans 5 secondes...</p>";
|
||||
header("refresh:5; url=/");
|
||||
die();
|
||||
}
|
||||
?>
|
||||
<?php
|
||||
$role = $userData['role'];
|
||||
if ($role != 'Administrateur') {
|
||||
echo "<p class='text'>Vous n'êtes pas autorisé à accéder à cette page.</p>";
|
||||
echo "<p class='text'>Redirection vers l'accueil dans 5 secondes...</p>";
|
||||
header("refresh:5; url=/");
|
||||
die();
|
||||
} else { // Si l'utilisateur est un administrateur : accès à la page
|
||||
echo "<p class='text'>Bienvenue sur le panel de gestion des utilisateurs.</p>";
|
||||
echo "<p class='text'>Vous pouvez ici gérer les utilisateurs.</p>";
|
||||
echo "<p class='text'>Que souhaitez-vous faire ?</p>";
|
||||
|
||||
//contenu de la page admin
|
||||
} ?>
|
||||
|
||||
<?php
|
||||
echo "<div class='adm-users-container'>";
|
||||
$users = mysqli_query($db, "SELECT * FROM `user`");
|
||||
echo "<table class='table'>";
|
||||
echo "<tr>";
|
||||
echo "<th>Adresse mail</th>";
|
||||
echo "<th>Nom</th>";
|
||||
echo "<th>Prénom</th>";
|
||||
echo "<th>Rôle</th>";
|
||||
echo "<th>Actions</th>";
|
||||
echo "</tr>";
|
||||
while ($row = mysqli_fetch_assoc($users)) {
|
||||
echo "<tr>";
|
||||
echo "<td>" . $row['mail'] . "</td>";
|
||||
echo "<td>" . $row['name'] . "</td>";
|
||||
echo "<td>" . $row['family_name'] . "</td>";
|
||||
echo "<td>" . $row['role'] . "</td>";
|
||||
echo "<td><a href='/admin/users/edit?email=" . $row['mail'] . "'>Modifier</a> | <a href='/admin/users/delete?email=" . $row['mail'] . "'>Supprimer</a></td>";
|
||||
echo "</tr>";
|
||||
}
|
||||
echo "</table>";
|
||||
echo "</div>";
|
||||
echo "<a href='/admin/users/add'>Ajouter un utilisateur</a>
|
||||
";
|
||||
echo "<a href='/admin'>Retour au panel d'administration</a>
|
||||
";
|
||||
echo "<a href='/'>Retour à l'accueil</a>
|
||||
";
|
||||
?>
|
||||
|
||||
|
||||
|
||||
<?php include ($_SERVER['DOCUMENT_ROOT'] . '/views/footer.php') ?>
|
||||
</body>
|
||||
|
||||
</html>
|
@ -5,6 +5,8 @@
|
||||
}
|
||||
body {
|
||||
overflow-x: hidden;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
.menu-container {
|
||||
opacity: 0.97;
|
||||
|
@ -174,6 +174,26 @@ p.text {
|
||||
font-family: "RobotoFlex";
|
||||
}
|
||||
|
||||
tr {
|
||||
color: white;
|
||||
font-size: 1rem;
|
||||
padding-left: 2rem;
|
||||
font-family: "RobotoFlex";
|
||||
}
|
||||
|
||||
th {
|
||||
color: white;
|
||||
font-size: 1rem;
|
||||
padding-left: 2rem;
|
||||
font-family: "RobotoFlex";
|
||||
}
|
||||
td {
|
||||
color: white;
|
||||
font-size: 1rem;
|
||||
padding-left: 2rem;
|
||||
font-family: "RobotoFlex";
|
||||
}
|
||||
|
||||
.avatar {
|
||||
width: 48px;
|
||||
height: 48px;
|
||||
@ -216,3 +236,17 @@ p.text {
|
||||
.searchbar button:hover {
|
||||
background-color: #f4a400;
|
||||
}
|
||||
|
||||
.adm-users-container {
|
||||
background: #26272b;
|
||||
align-items: center;
|
||||
opacity: 1;
|
||||
padding: 3rem;
|
||||
border-radius: 10px;
|
||||
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.5);
|
||||
width: 100%;
|
||||
text-align: center;
|
||||
max-width: fit-content;
|
||||
margin-inline: auto;
|
||||
margin-block: 5em;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user