diff --git a/config/Autoload.php b/config/Autoload.php new file mode 100644 index 0000000..cbbeb58 --- /dev/null +++ b/config/Autoload.php @@ -0,0 +1,33 @@ + \ No newline at end of file diff --git a/config/Validation.php b/config/Validation.php index 0490687..32e46ce 100644 --- a/config/Validation.php +++ b/config/Validation.php @@ -8,26 +8,16 @@ class Validation{ } } - static function val_form(string &$username, string &$mdp, array &$dVueErreur){ + static function val_form(string &$chaine, array &$dVueErreur){ - if (!isset($username)||$username==""){ - $dVueErreuR[] = "pas de username"; - $username=""; + if (!isset($chaine)||$chaine==""){ + $dVueErreuR[] = "pas de chaine de charactère"; + $chaine=""; } - if (!$username != filter_var($username, FILTER_SANITIZE_STRING)){ + if (!$chaine != filter_var($chaine, FILTER_SANITIZE_STRING)){ $dVueErreur[] = "tentative d'injection de code (attaque sécurité)"; - $username=""; - } - - if (!isset($mdp)||$mdp==""){ - $dVueErreuR[] = "pas de mot de passe"; - $mdp=""; - } - - if (!$mdp != filter_var($mdp, FILTER_SANITIZE_STRING)){ - $dVueErreur[] = "tentative d'injection de code (attaque sécurité)"; - $mdp=""; + $chaine=""; } } } diff --git a/config/config.php b/config/config.php new file mode 100644 index 0000000..b46a85a --- /dev/null +++ b/config/config.php @@ -0,0 +1,17 @@ + pour l'iut) + + +$vues['erreur'] = 'Vues/erreur.php' +// A faire pour toutes les vues + +?> \ No newline at end of file diff --git a/controllers/frontController.php b/controllers/frontController.php index d7b1446..275173d 100644 --- a/controllers/frontController.php +++ b/controllers/frontController.php @@ -2,7 +2,29 @@ class frontController { - + function __construct() { + global $rep, $vues; + session_start(); + $dVueErreur = array(); + $listActionUser=array('delete', 'update', 'ajouterListeU', 'supprimerListeU', 'modifierListeU', 'ajouterTacheU', 'supprimerTacheU', 'modifierTacheU'); // actions à rajouter + try{ + $user = new mdlUser(); + if (isset($_REQUEST['action'])){ + $action = $_REQUEST['action']; + Validation::val_form($action, $dVueErreur); + } + if(in_array($action, $listActionUser)) { + new userController(); + } + else { + new visitorController(); + } + } + catch (Exception $e){ + $dVueErreur[] = "Erreur FrontController"; + require $rep.$vues['erreur']; + } + } } ?> \ No newline at end of file diff --git a/controllers/userController.php b/controllers/userController.php index 10a5aa4..f16c6db 100644 --- a/controllers/userController.php +++ b/controllers/userController.php @@ -5,7 +5,7 @@ class userController { { global $rep,$vues; $mdlUsr = new MdlUser(); - $user = new User(); + $user = $mdlUsr->getUserForConnection($username, $mdp); session_start(); $this->ValidationFormulaire($dVueEreur); @@ -26,27 +26,27 @@ class userController { $this->Update(); break; - case "ajouterListe": + case "ajouterListeU": $this->AddList(); break; - case "supprimerListe": + case "supprimerListeU": $this->DelList(); break; - case "modifierListe": + case "modifierListeU": $this->UpdateList(); break; - case "ajouterTache": + case "ajouterTacheU": $this->AddTask(); break; - case "supprimerTache": + case "supprimerTacheU": $this->DelTask(); break; - case "modifierTache": + case "modifierTacheU": $this->UpdateTask(); break; diff --git a/controllers/visitorController.php b/controllers/visitorController.php index a38eb4e..ed0a933 100644 --- a/controllers/visitorController.php +++ b/controllers/visitorController.php @@ -27,6 +27,11 @@ class visitorController { $this->ValidationFormulaireLogin($dVueEreur); $this->Inscription($login, $mdp); break; + + default: + $dVueEreur[] = "Erreur d'appel php"; + require ($rep.$vues['vuephp1']); //Appel de vue à changer + break; } } catch (Exception $e){