From 8fe3893871dc0bc4ce7662dd8fe891962c8619f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Georges=20Dup=C3=A9ron?= Date: Wed, 4 Aug 2010 22:25:08 +0200 Subject: [PATCH] =?UTF-8?q?Am=C3=A9lioration=20de=20la=20gestion=20d'erreu?= =?UTF-8?q?rs.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- __cms__/code/securite/authentification.php | 6 +++++- __cms__/code/securite/erreur.php | 4 ++++ __cms__/code/stockage/session.php | 2 +- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/__cms__/code/securite/authentification.php b/__cms__/code/securite/authentification.php index c83806e..5f5f3dd 100644 --- a/__cms__/code/securite/authentification.php +++ b/__cms__/code/securite/authentification.php @@ -19,13 +19,17 @@ class Authentification { } } + public static function est_connecté() { + return get_utilisateur() == "Anonyme"; + } + public static function déconnexion() { Session::effacer("utilisateur"); } public static function get_utilisateur() { $u = Session::get("utilisateur"); - return ($u === false) ? "Anonyme" : $u; + return (Erreur::is_erreur($u)) ? "Anonyme" : $u; } public static function nouvel_utilisateur($nom_utilisateur) { diff --git a/__cms__/code/securite/erreur.php b/__cms__/code/securite/erreur.php index d5e406c..aa88833 100644 --- a/__cms__/code/securite/erreur.php +++ b/__cms__/code/securite/erreur.php @@ -40,6 +40,10 @@ class Erreur { public function __toString() { return $this->string; } + + public static function is_erreur($obj) { + return get_class($obj) === "Erreur"; + } } ?> \ No newline at end of file diff --git a/__cms__/code/stockage/session.php b/__cms__/code/stockage/session.php index 74fdace..10f4cf1 100644 --- a/__cms__/code/stockage/session.php +++ b/__cms__/code/stockage/session.php @@ -12,7 +12,7 @@ class Session { public static function get($k) { self::démarrer(); - return isset($_SESSION[$k]) ? $_SESSION[$k] : false; + return isset($_SESSION[$k]) ? $_SESSION[$k] : Erreur::lecture("N'a pas pu lire la variable de session " . $k); } public static function effacer($k) {