From f04cfc060b9abc62edb9211c2d431b70c2542053 Mon Sep 17 00:00:00 2001 From: Anna BOUDOUL Date: Thu, 22 Dec 2022 21:55:10 +0100 Subject: [PATCH] Validation correction --- config/Validation.php | 12 ++++++------ controller/UserCtrl.php | 40 +++++++++++++++++++++----------------- controller/VisitorCtrl.php | 2 +- model/UserModel.php | 1 + 4 files changed, 30 insertions(+), 25 deletions(-) diff --git a/config/Validation.php b/config/Validation.php index 030adde..97aa788 100644 --- a/config/Validation.php +++ b/config/Validation.php @@ -2,29 +2,29 @@ class Validation { - static function val_form_texte(string &$texte, array &$TMessage) { + static function val_form_texte(&$texte, &$TMessage) { if (!isset($texte)||$texte=="") { - $TMessage[] ="champs vide"; + $TMessage[] ="Empty fields"; $texte=""; } if ($texte != filter_var($texte, FILTER_SANITIZE_STRING)) { - $TMessage[] ="testative d'injection de code (attaque sécurité)"; + $TMessage[]="Attempt to inject code (security attack)"; $texte=""; } } - static function val_form_mdp(string &$mdp, array &$TMessage) { + static function val_form_mdp(&$mdp, &$TMessage) { if (!isset($mdp)||$mdp=="") { - $TMessage[] ="pas de mdp"; + $TMessage[] ="Password not specified"; $mdp=""; } if ($mdp != filter_var($mdp, FILTER_SANITIZE_SPECIAL_CHARS)) { - $TMessage[] ="Le mot de passe ne doit pas contenir de caractères spéciaux"; + $TMessage[] ="Password must not contain special characters"; $mdp=""; } diff --git a/controller/UserCtrl.php b/controller/UserCtrl.php index 1dfa5c6..b488c7c 100644 --- a/controller/UserCtrl.php +++ b/controller/UserCtrl.php @@ -12,27 +12,31 @@ class UserCtrl $this->con = $con; $this->userModel = new UserModel($this->con); $this->taskModel = new TaskModel($this->con); - // try{ - // $action=$_REQUEST['action']; - // switch($action){ + try{ + $action=$_REQUEST['action']; + switch($action){ - // // voir les listes privees - // case 'voirListePriv': - // $this->loadListePriv(); - // break; + // voir les listes privees + case 'voirListePriv': + $this->loadListePriv(); + break; - // // ajouter une liste privee - // case 'creerListePriv': - // $this->newListPrivate(); - // break; - // case 'deconnecter': - // $this->deconnexion(); - // break; + // ajouter une liste privee + case 'creerListePriv': + $this->newListPrivate(); + break; + case 'deconnecter': + $this->deconnexion(); + break; + default: + $TMessage[] = 'Unexpected error'; + require($rep.$vues['']); + break; - // } - // } catch(Exception $e) { - // require("../view/erreur.php"); - // } + } + } catch(Exception $e) { + require("../view/erreur.php"); + } } public function loadListePriv(){ diff --git a/controller/VisitorCtrl.php b/controller/VisitorCtrl.php index fa61be4..fa68399 100644 --- a/controller/VisitorCtrl.php +++ b/controller/VisitorCtrl.php @@ -71,7 +71,7 @@ class VisitorCtrl default: # - $dvueErreur[] = 'Erreur inattendue'; + $TMessage[] = 'Unexpected error'; require($rep.$vues['']); break; } diff --git a/model/UserModel.php b/model/UserModel.php index 5f2a3ae..9123dd6 100644 --- a/model/UserModel.php +++ b/model/UserModel.php @@ -1,6 +1,7 @@