From 1301b8ecfc4282673570f354ba0f1675890a94d4 Mon Sep 17 00:00:00 2001 From: brongniart Date: Mon, 2 Dec 2024 10:18:08 +0100 Subject: [PATCH] chemin racine en global --- config/config.php | 2 ++ index.php | 4 ++-- src/Controleur/FrontControler.php | 5 ++--- src/Controleur/UserControler.php | 9 ++++++--- src/Controleur/VisitorControler.php | 11 ++++++----- src/Verification/Verification.php | 18 ++++++++++++++++++ 6 files changed, 36 insertions(+), 13 deletions(-) create mode 100644 src/Verification/Verification.php diff --git a/config/config.php b/config/config.php index 87e7c39..332f3ca 100644 --- a/config/config.php +++ b/config/config.php @@ -12,6 +12,8 @@ $base = ''; $login = ''; $mdp = ''; +$racine='/~kekentin/WF/WF-Website'; + //Vues $vues['erreur'] = 'vue/erreur.php'; $vues['accueil'] = 'vue/accueil.php'; diff --git a/index.php b/index.php index b625fbe..90a1657 100644 --- a/index.php +++ b/index.php @@ -23,8 +23,8 @@ $loader = new \Twig\Loader\FilesystemLoader('vue/templates'); $twig = new \Twig\Environment($loader, [ 'cache' => false, ]); - -$twig->addGlobal('racine','/~lebeaulato/WF-Website'); // /~kekentin/WF/WF-Website +global $racine; +$twig->addGlobal('racine',$racine); // /~kekentin/WF/WF-Website $cont = new Controleur\FrontControler($co); diff --git a/src/Controleur/FrontControler.php b/src/Controleur/FrontControler.php index b4cddcd..fa48b4c 100644 --- a/src/Controleur/FrontControler.php +++ b/src/Controleur/FrontControler.php @@ -10,7 +10,7 @@ Class FrontControler{ private Connection $co; public function __construct($co){ - global $twig; + global $twig,$racine; $this->listAction = ['visitor' => array('accueil','search','quote','login','signin','validlogin','validsignin'), 'user' => array('quiz','commentary','logout','addComment','favorite','profil'), @@ -19,8 +19,7 @@ Class FrontControler{ $dVueEreur = []; $router = new \AltoRouter(); - $router->setBasePath('/~lebeaulato/WF-Website'); ///~kekentin/WF/WF-Website - + $router->setBasePath($racine); ///~kekentin/WF/WF-Website $router->map('GET', '/', 'VisitorControler','accueil'); /* diff --git a/src/Controleur/UserControler.php b/src/Controleur/UserControler.php index 6eb68ec..36db5e4 100644 --- a/src/Controleur/UserControler.php +++ b/src/Controleur/UserControler.php @@ -47,9 +47,10 @@ class UserControler { public function addComment(){ + global $racine; $id = $_POST['idQuote']; $this->cMod->createComment($_POST['content'],$_POST['idQuote'],$this->uMod->getIdByUsername($_SESSION['user'])); - header("Location: /~lebeaulato/WF-Website/quote/$id"); + header("Location:".$racine."/quote/$id"); } @@ -64,10 +65,11 @@ class UserControler { } public function unlog(){ + global $racine; session_unset(); session_destroy(); $_SESSION = array(); - header("Location: /~lebeaulato/WF-Website/"); + header("Location:".$racine); } public function quiz(array $args){ @@ -103,13 +105,14 @@ class UserControler { */ public function continueQuiz(int $id_quiz, int $total_questions) : void { + global $racine; $score = $_SESSION['score']; $_SESSION['no_question'] = isset($_SESSION['no_question']) ? ($_SESSION['no_question'] + 1) : 1; if ($_SESSION['no_question'] >= $total_questions) { session_destroy(); $this->endQuiz($id_quiz, $score); } - else header("Location: /~lebeaulato/WF-Website/quiz/$id_quiz"); ///~kekentin/WF/WF-Website + else header("Location: ".$racine."/quiz/$id_quiz"); ///~kekentin/WF/WF-Website } diff --git a/src/Controleur/VisitorControler.php b/src/Controleur/VisitorControler.php index fea371b..20bd6a1 100644 --- a/src/Controleur/VisitorControler.php +++ b/src/Controleur/VisitorControler.php @@ -13,6 +13,7 @@ use Twig\Error\LoaderError; use Twig\Error\RuntimeError; use Twig\Error\SyntaxError; + Class VisitorControler { private QuoteModel $qMod; @@ -68,7 +69,7 @@ Class VisitorControler { global $vues; $type = ($_POST['type'] ?? ""); - $search = ($_POST['search'] ?? NULL); + $search = ( $_POST['search'] ?? NULL); $filtre = ($arg['filtre'] ?? []); @@ -111,7 +112,7 @@ Class VisitorControler { public function validlogin() : void { - global $vues; + global $vues,$racine; if ($_POST) { $pseudo = $_POST['pseudo'] ?? null; @@ -125,7 +126,7 @@ Class VisitorControler { { $_SESSION['user'] = $pseudo; $_SESSION['role'] = 'user'; - header("Location: /~lebeaulato/WF-Website/"); ///~kekentin/WF/WF-Website/ + header("Location: ". $racine); ///~kekentin/WF/WF-Website/ exit(); }else { @@ -152,7 +153,7 @@ Class VisitorControler { */ public function validsignin() : void { - global $vues; + global $vues,$racine; if ($_POST) { $pseudo = $_POST['pseudo'] ?? null; @@ -193,7 +194,7 @@ Class VisitorControler { $_SESSION["role"] = 'user'; $_SESSION["user"] = $pseudo; - header("Location: /~kekentin/WF/WF-Website/profil"); + header("Location: ". $racine); } } } \ No newline at end of file diff --git a/src/Verification/Verification.php b/src/Verification/Verification.php new file mode 100644 index 0000000..a607afa --- /dev/null +++ b/src/Verification/Verification.php @@ -0,0 +1,18 @@ + \ No newline at end of file