site-accueil-insa/admin/script.php
2022-06-17 16:21:37 +02:00

50 lines
No EOL
1.2 KiB
PHP

<?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;
}
echo '<link rel="stylesheet" type="text/css" href="admin.css" />';
if($user_exist != 1) {
if($page != "index") {
header('Location: index.php');
}
} else {
$content =
'<a href="index.php"><li class="green">Index</li></a>'
.'<a href="stats.php"><li class="green">Stats</li></a>';
switch ($user['perm']) {
case 1:
$content = $content.'<a href="planning.php"><li class="orange">Planning</li></a>';
break;
case 2:
$content = $content
.'<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>'
.'<a href="enigma.php"><li class="red">Enigma</li></a>'
.'<a href="../matomo" target="_matomo"><li class="red">Matomo</li></a>';
break;
}
$content = $content.'<a href="deco.php"><li class="white">Se déconnecter</li></a>';
}
?>
<nav>
<ul>
<?php
if(isset($content)) {
echo $content;
} ?>
</ul>
</nav>