50 lines
1.3 KiB
PHP
50 lines
1.3 KiB
PHP
<?php
|
|
session_start();
|
|
|
|
if(!isset($_SESSION['accreditation'])) {
|
|
$_SESSION['accreditation'] = 0;
|
|
}
|
|
|
|
if(!isset($_SESSION['role'])) {
|
|
$_SESSION['role'] = 0;
|
|
}
|
|
|
|
if(isset($_GET['theme'])) {
|
|
setcookie('theme', (int)$_GET['theme'] % 2, time()+10*60*60);
|
|
$theme_dark = $themes_dark[$_GET['theme']];
|
|
$theme_light = $themes_light[$_GET['theme']];
|
|
} else {
|
|
$theme_dark = $themes_dark[$_COOKIE['theme']];
|
|
$theme_light = $themes_light[$_COOKIE['theme']];
|
|
}
|
|
|
|
|
|
|
|
|
|
function nav($nav) {
|
|
foreach($nav as $name => $url) {
|
|
echo "<a href='$url'><div class='navitem'>$name</div></a>";
|
|
}
|
|
if($_SESSION['role'] >= 3) {
|
|
echo "<a href='admin.php'><div class='navitem'>Admin</div></a>";
|
|
}
|
|
if (isset($_SESSION['userid'])) {
|
|
echo "<a href='compte.php'><div class='navitem'>Options</div></a><a href='logout.php'><div class='navitem'>Déconnexion</div></a>";
|
|
} else {
|
|
echo "<a href='login.php'><div class='navitem'>Connexion</div></a>";
|
|
}
|
|
}
|
|
|
|
function connect($dbhost, $dbname, $dbuser, $dbpass) {
|
|
try
|
|
{
|
|
$bdd = new PDO('mysql:host=' . $dbhost . ';dbname=' . $dbname . ';charset=UTF8',$dbuser,$dbpass);
|
|
$bdd->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
|
}
|
|
catch(Exception $e)
|
|
{
|
|
die('Erreur : '.$e->getMessage());
|
|
}
|
|
return $bdd;
|
|
}
|
|
?>
|