-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmenu.php
61 lines (47 loc) · 2.29 KB
/
menu.php
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
<?php
include('db_config.php');
session_start();
if (isset($_SESSION['LAST_ACTIVITY']) && (time() - $_SESSION['LAST_ACTIVITY'] > 1800)) {
session_unset(); // Détruit les données de session
session_destroy(); // Détruit la session elle-même
}
$_SESSION['LAST_ACTIVITY'] = time();
$page_name = "AssociaSite";
$logo = "AssociaSite.jpg";
// Liste des pages
$page_associasite = array(
"Connexion",
"Gestion"
);
// Obtient le nom de la page actuelle
$currentPage = basename($_SERVER['PHP_SELF']);
// Crée le menu de navigation
$menu_site = "<ul>";
$menu_site .= "<li><img src='AssociaSite.jpg' width='50' border-radius='4.5vh'></li>";
$menu_site .= "<li><a href=\"index.php\"" . ($currentPage === 'index.php' ? ' class="active"' : '') . ">Accueil</a></li>";
foreach ($page_associasite as $page) {
$menu_site .= "<li><a href=\"{$page}.php\"" . ($currentPage === "{$page}.php" ? ' class="active"' : '') . ">{$page}</a></li>";
}
// Vérifie si l'ID de l'association est défini dans la session ou l'URL
if (isset($_SESSION['association_id'])) {
$association_id = $_SESSION['association_id'];
$menu_site .= "<div class=separation_menu></div>";
$menu_site .= "<li><a href=\"Associations/{$association_id}/index.php\"" . ($currentPage === "Associations/{$association_id}/index.php" ? ' class="active"' : '') . ">Accueil</a></li>";
// Préparer la requête pour récupérer les pages spécifiques à l'association
$stmt_get_pages = $connection->prepare("SELECT page_name, page_order FROM Pages WHERE association_id = ? ORDER BY page_order");
$stmt_get_pages->bind_param("i", $association_id);
$stmt_get_pages->execute();
$result = $stmt_get_pages->get_result();
$pages_site = array();
// Ajouter les pages de l'association au menu
while ($row = $result->fetch_assoc()) {
$pages_site[$row['page_order']] = $row['page_name'];
}
$stmt_get_pages->close();
foreach ($pages_site as $order => $page_site) {
$menu_site .= "<li><a href=\"Associations/{$association_id}/{$page}.php\"" . ($currentPage === "Associations/{$association_id}/{$page_site}.php" ? ' class="active"' : '') . ">{$page_site}</a></li>";
}
$_SESSION['pages_site'] = $pages_site;
}
$menu_site .= "</ul>";
?>