site-accueil-insa/admin/script.php

51 lines
1.3 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 =
'<li class="green"><a href="index.php">Index</a></li>'
.'<li class="green"><a href="stats.php">Stats</a></li>';
2022-06-14 23:36:26 +02:00
switch ($user['perm']) {
case 1:
2022-06-15 17:35:34 +02:00
$content = $content.'<li class="orange"><a href="planning.php">Planning</a></li>';
2022-06-14 23:36:26 +02:00
break;
case 2:
2022-06-15 17:35:34 +02:00
$content = $content
.'<li class="orange"><a href="planning.php">Planning</a></li>'
.'<li class="red"><a href="gestion_des_acces.php">Gestion des accès</a></li>'
.'<li class="red"><a href="enigma.php">Enigma</a></li>'
.'<li class="red"><a href="stats.php">Stats</a></li>'
.'<li class="red"><a href="vacances.php">Vacances</a></li>';
2022-06-14 23:36:26 +02:00
break;
}
2022-06-15 17:35:34 +02:00
$content = $content.'<li class="white"><a href="deco.php">Se déconnecter</a></li>';
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>