site-accueil-insa/admin/script.php

49 lines
1.2 KiB
PHP
Raw Normal View History

2022-06-14 23:36:26 +02:00
<?php
include "../script/db.php";
session_start();
if(isset($_SESSION['id'])) {
$req_user = $db->prepare("SELECT pseudo, perm FROM admin WHERE id = ?");
$req_user->execute(array($_SESSION['id']));
$user_exist = $req_user->rowcount();
$user = $req_user->fetch();
} else {
$user_exist = 0;
}
2022-06-15 17:35:34 +02:00
echo '<link rel="stylesheet" type="text/css" href="admin.css" />';
2022-06-14 23:36:26 +02:00
if($user_exist != 1) {
if($page != "index") {
header('Location: index.php');
}
} else {
2022-06-15 17:35:34 +02:00
$content =
2022-06-15 21:19:49 +02:00
'<a href="index.php"><li class="green">Index</li></a>'
.'<a href="stats.php"><li class="green">Stats</li></a>';
2022-06-15 17:35:34 +02:00
2022-06-14 23:36:26 +02:00
switch ($user['perm']) {
case 1:
2022-06-15 21:19:49 +02:00
$content = $content.'<a href="planning.php"><li class="orange">Planning</li></a>';
2022-06-14 23:36:26 +02:00
break;
case 2:
2022-06-15 17:35:34 +02:00
$content = $content
2022-06-15 21:19:49 +02:00
.'<a href="planning.php"><li class="orange">Planning</li></a>'
.'<a href="gestion_des_acces.php"><li class="red">Gestion des accès</li></a>'
2022-06-15 23:07:18 +02:00
.'<a href="enigma.php"><li class="red">Enigma</li></a>';
2022-06-14 23:36:26 +02:00
break;
}
2022-06-15 17:35:34 +02:00
2022-06-15 21:19:49 +02:00
$content = $content.'<a href="deco.php"><li class="white">Se déconnecter</li></a>';
2022-06-14 23:36:26 +02:00
}
2022-06-15 17:35:34 +02:00
?>
<nav>
<ul>
<?php
if(isset($content)) {
echo $content;
} ?>
</ul>
</nav>