-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathadmin_fetch.php
More file actions
75 lines (67 loc) · 2.38 KB
/
Copy pathadmin_fetch.php
File metadata and controls
75 lines (67 loc) · 2.38 KB
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
<?php
require("requires/json_utilities.php");
$users = lireFichierJson("./databases/users.json");
if(!isset($_GET['id'])) {
http_response_code(400);
echo "ID non spécifiée.";
exit;
}
if(!isset($_GET['action'])) {
http_response_code(400);
echo "Action non spécifiée.";
exit;
}
if ($_GET['action'] == "details") {
usleep(150000);
$id = $_GET['id'];
$nb_voyages_panier = recupererNombreVoyagesPanier($id);
$nb_voyages_reserves = recupererNombreVoyageUtilisateur($id);
$noms_voyages = recupererNomsVoyagesUtilisateur($id);
foreach ($users as $user) {
if ($user['id'] == $id) {
// Tu peux personnaliser ce tableau avec ce que tu veux afficher
echo "<div class='espaceur'></div>";
echo "<table class='details-table'>";
echo "<tr><td><strong>Nombre de voyages dans le panier:</strong></td><td>{$nb_voyages_panier}</td></tr>";
echo "<tr><td><strong>Nombre de voyages réservés:</strong></td><td>{$nb_voyages_reserves}</td></tr>";
if($nb_voyages_reserves > 0){
echo "<tr><td><strong>Voyages réservés:</strong></td><td>";
foreach ($noms_voyages as $nom_voyage) {
echo htmlspecialchars($nom_voyage) . "<br>";
}
echo "</td></tr>";
}
echo "<tr><td><strong>Téléphone:</strong></td><td>{$user['tel']}</td></tr>";
echo "<tr><td><strong>Date de Naissance:</strong></td><td>{$user['naissance']}</td></tr>";
echo "<tr><td><strong>Genre:</strong></td><td>{$user['genre']}</td></tr>";
echo "</table>";
echo "<div class='espaceur'></div>";
exit;
}
}
}
if( $_GET['action'] == "supprimer") {
$id = $_GET['id'];
sleep(1);
supprimerUtilisateur($id);
echo "success";
exit;
}
if ($_GET['action'] == "promouvoir") {
$id = $_GET['id'];
sleep(1);
foreach ($users as &$user) {
if ($user['id'] == $id) {
if ($user['role'] == 'user') {
modifierRoleUtilisateur($user['id'], 'adm');
} else {
modifierRoleUtilisateur($user['id'], 'user');
}
echo "success";
exit;
}
}
}
http_response_code(404);
echo "Utilisateur non trouvé.";
?>