From 050f7259d4579b192f7756e8e1e10d6ffafa789e Mon Sep 17 00:00:00 2001 From: xdrm-brackets Date: Mon, 11 Apr 2016 12:19:59 +0200 Subject: [PATCH] Correction pb de token interne --- manager/ResourceDispatcher.php | 21 +++++++++++++++++---- manager/sessionManager.php | 12 +++++------- 2 files changed, 22 insertions(+), 11 deletions(-) diff --git a/manager/ResourceDispatcher.php b/manager/ResourceDispatcher.php index 4a21abb..4f907fb 100755 --- a/manager/ResourceDispatcher.php +++ b/manager/ResourceDispatcher.php @@ -1,6 +1,8 @@ header); // On recupere le contenu - $svg_content = file_get_contents($this->path); + $content = file_get_contents($this->path); + + + + //////////////////////////////////////// + ///////////// SI FICHIER JS //////////// + //////////////////////////////////////// + if( $this->flags['extension'] == 'js' ) + $content = 'var js_access_token = "'. substr($_SESSION['session_token'], 0, 40) .'";' . "\n\n" . $content; + + + // On affiche tout - echo str_replace( '', $this->stylesheet.'', $svg_content ); + echo str_replace( '', $this->stylesheet.'', $content ); } @@ -263,10 +276,10 @@ // On inclut le contenu - $svg_content = file_get_contents($this->path); + $content = file_get_contents($this->path); // On retourne tout - return str_replace( '', $this->stylesheet.'', $svg_content ); + return str_replace( '', $this->stylesheet.'', $content ); } diff --git a/manager/sessionManager.php b/manager/sessionManager.php index 3963e00..94e0212 100755 --- a/manager/sessionManager.php +++ b/manager/sessionManager.php @@ -20,6 +20,7 @@ /* INITIALISATION DE SESSION */ /*****************************/ private static function reset_session($session_id=null){ + // On ferme la session session_destroy(); @@ -36,7 +37,6 @@ // On met a jour le token self::update_token(); - header('Refresh: 0'); } @@ -85,17 +85,15 @@ if( !$valid_sessid ) self::reset_session( $sessid ); // On initialise la session (bon id session) - - // si id session invalide /* [3] Verification du token ==============================================================*/ // On verifie que le token est valide - $valid_token = $session_token != null; // verification de l'existence du cookie - $valid_token = $valid_token && strpos($session_token, self::$prefix) === 0; // verification des donnes personnelles - $valid_token = $valid_token && isset($_SESSION['session_token']); // verification que la variable session associee existe - $valid_token = $valid_token && $_SESSION['session_token'] == $_COOKIE['session_token']; // verification que la session est coherente + $valid_token = $session_token != null; // verification de l'existence du cookie + $valid_token = $valid_token && strpos($session_token, self::$prefix) === 0; // verification des donnes personnelles + $valid_token = $valid_token && isset($_SESSION['session_token']); // verification que la variable session associee existe + $valid_token = $valid_token && $_SESSION['session_token'] == $_COOKIE['session_token']; // verification que la session est coherente /* [4] Si token inexistant ==============================================================*/