From 5ecd0477f4498b62064727c34699893690a4b787 Mon Sep 17 00:00:00 2001 From: jbousquie Date: Wed, 30 Nov 2016 10:29:33 +0100 Subject: [PATCH] fix Username() redirection --- admin/session.php | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/admin/session.php b/admin/session.php index 5c9a849..72eeaa8 100644 --- a/admin/session.php +++ b/admin/session.php @@ -7,7 +7,11 @@ function Username() { session_start(); global $_SESSION, $winlog_url; if (!isset($_SESSION['username'])) { - header('Location: '.$winlog_url); + $destination = $winlog_url; + if (isset($_SERVER['HTTP_REFERER'])) { + $destination = $_SERVER['HTTP_REFERER']; + } + header('Location: '.$destination); exit(); } return $_SESSION['username']; @@ -19,29 +23,29 @@ function Username() { // autre => 0 function Profil($username) { global $administrateurs, $superviseurs; - global $niveaux, $lib_personnel; + global $roles, $niveaux, $lib_personnel; if (in_array($username, $administrateurs)) { - return $niveaux[3]; + return $niveaux[$roles[3]]; } elseif (in_array($username, $superviseurs)) { - return $niveaux[2]; + return $niveaux[$roles[2]]; } else { $compte = Compte($username); if ($compte[2] == $lib_personnel) { - return $niveaux[1]; + return $niveaux[$roles[1]]; } else { - return $niveaux[0]; + return $niveaux[$roles[0]]; } } }; // Fonction FiltreProfil() : redirige vers interdit.php si profil inférieur à niveau Superviseur function FiltreProfil($profil) { - global $niveaux; - if ($profil < $niveau[2]) { + global $niveaux, $roles; + if ($profil < $niveaux[$roles[2]]) { header('Location: interdit.php'); exit(); }