From 3c16b28c13f586efdad2f7e744da220d12a1d6b7 Mon Sep 17 00:00:00 2001 From: ThomasPascuzzo Date: Thu, 9 Nov 2017 09:10:43 +0100 Subject: [PATCH] La partie de Thomas La partie de Thomas --- src/mecado/auth/MecadoAuthentification.php | 2 +- src/mecado/control/MecadoController.php | 115 +++++------------- src/mecado/model/Utilisateur.php | 26 ++-- src/mecado/model/liste.php | 0 src/mecado/view/MecadoView.php | 93 ++++---------- src/mf/auth/AbstractAuthentification.php | 0 src/mf/auth/Authentification.php | 0 .../exception/AuthentificationException.php | 0 src/mf/control/AbstractController.php | 0 src/mf/router/AbstractRouter.php | 0 src/mf/router/Router.php | 0 src/mf/utils/AbstractHttpRequest.php | 0 src/mf/utils/ClassLoader.php | 52 ++++---- src/mf/utils/HttpRequest.php | 0 src/mf/view/AbstractView.php | 2 +- 15 files changed, 98 insertions(+), 192 deletions(-) mode change 100755 => 100644 src/mecado/auth/MecadoAuthentification.php mode change 100755 => 100644 src/mecado/control/MecadoController.php mode change 100755 => 100644 src/mecado/model/Utilisateur.php mode change 100755 => 100644 src/mecado/model/liste.php mode change 100755 => 100644 src/mecado/view/MecadoView.php mode change 100755 => 100644 src/mf/auth/AbstractAuthentification.php mode change 100755 => 100644 src/mf/auth/Authentification.php mode change 100755 => 100644 src/mf/auth/exception/AuthentificationException.php mode change 100755 => 100644 src/mf/control/AbstractController.php mode change 100755 => 100644 src/mf/router/AbstractRouter.php mode change 100755 => 100644 src/mf/router/Router.php mode change 100755 => 100644 src/mf/utils/AbstractHttpRequest.php mode change 100755 => 100644 src/mf/utils/ClassLoader.php mode change 100755 => 100644 src/mf/utils/HttpRequest.php mode change 100755 => 100644 src/mf/view/AbstractView.php diff --git a/src/mecado/auth/MecadoAuthentification.php b/src/mecado/auth/MecadoAuthentification.php old mode 100755 new mode 100644 index 60f10b7..f52f1f2 --- a/src/mecado/auth/MecadoAuthentification.php +++ b/src/mecado/auth/MecadoAuthentification.php @@ -60,4 +60,4 @@ public function login($pseudo, $mdp) public function deconnexion(){ $this->logout(); } -} +} \ No newline at end of file diff --git a/src/mecado/control/MecadoController.php b/src/mecado/control/MecadoController.php old mode 100755 new mode 100644 index 97a2be0..b8aa8ff --- a/src/mecado/control/MecadoController.php +++ b/src/mecado/control/MecadoController.php @@ -1,19 +1,19 @@ render('viewHome'); } @@ -43,7 +43,8 @@ public function checkLogin(){ public function deconnexion(){ $auth = new MecadoAuth(); $auth->deconnexion(); - return $this->viewHome(); + $v = new MecadoView($t = $_SESSION); + $v ->render('viewHome'); } public function viewSignUp($erreur = null){ @@ -54,7 +55,7 @@ public function viewSignUp($erreur = null){ public function checkSignUp(){ if(!empty($_POST['nom_complet']) and !empty($_POST['pseudo']) and !empty($_POST['mdp'])and !empty($_POST['remdp']) and !empty($_POST['mail'])) { - $mail = filter_var($_POST['mail'], FILTER_SANITIZE_SPECIAL_CHARS); + $mail = filter_var($_POST['mail'], FILTER_SANITIZE_SPECIAL_CHARS); $nom_complet = filter_var($_POST['nom_complet'], FILTER_SANITIZE_SPECIAL_CHARS); $pseudo = filter_var($_POST['pseudo'], FILTER_SANITIZE_SPECIAL_CHARS); $mdp = filter_var($_POST['mdp'], FILTER_SANITIZE_SPECIAL_CHARS); @@ -72,108 +73,56 @@ public function checkSignUp(){ $this->viewSignUp($co); } } - else + else { $this->viewSignUp("Les mots de passe ne sont pas identiques !"); } } } + public function viewUserListes(){ var_dump($_SESSION["user_login"]); - + if (isset ($_SESSION["user_login"])) { $pseudo = $_SESSION["user_login"]; + $req = Utilisateur::select()->where('pseudo', '=', $pseudo); $unUtilisateur = $req->first(); $req2 = Liste::select()->where('id_UTILISATEUR', '=',$unUtilisateur->id); $lesListes = $req2->get(); - - + + $v = new \mecado\view\MecadoView($lesListes); $v->render('viewUserListes'); } - else + else { $this->viewHome(); } - } - public function viewNewListe(){ - $vue = new MecadoView(''); - return $vue->render('viewNewListe'); + } - public function addListe(){ - if (isset ($_SESSION["user_login"])) - { - $pseudo = $_SESSION["user_login"]; - $req = Utilisateur::select()->where('pseudo', '=', $pseudo); - $unUtilisateur = $req->first(); - if(isset($this->request->post['nom'])){ - $form=$this->request->post; - } - $vue = new MecadoView(''); - if(isset($form)){ - $liste = new Liste(); - $liste->nom=$form['nom']; - $liste->description=$form['description']; - $liste->date_limite=$form['date_limite']; - $liste->pour_soi=$form['pour_soi']; - $liste->destinataire=$form['destinataire']; - $liste->id_UTILISATEUR=$unUtilisateur->id; - $liste->save(); - $vue = new MecadoView($liste); - return $vue->render('viewListe'); - } - else{ - return $this->viewNewListe(); - } - } - else{ - return $this->viewHome(); - } - } - public function viewModifierListe() + public function insertToken() { - $id = $_GET['id']; - $requete = Liste::select()->where('id', '=', $id); - $uneListe = $requete->first(); - $v = new MecadoView($uneListe); - $v ->render('viewModifierListe'); - } - public function setListe(){ - if (isset ($_SESSION["user_login"])) - { - $pseudo = $_SESSION["user_login"]; - $req = Utilisateur::select()->where('pseudo', '=', $pseudo); - $unUtilisateur = $req->first(); - if(isset($this->request->post['nom'])){ - $form=$this->request->post; - } - $vue = new MecadoView(''); - if(isset($form)){ - $req = Liste::select()->where('id', '=', $_GET['id']); - $liste = $req->first(); - $liste->nom=$form['nom']; - $liste->description=$form['description']; - $liste->date_limite=$form['date_limite']; - $liste->pour_soi=$form['pour_soi']; - $liste->destinataire=$form['destinataire']; - $liste->id_UTILISATEUR=$unUtilisateur->id; - $liste->save(); - $vue = new MecadoView($liste); - return $vue->render('viewListe'); - } - else{ - return $this->viewModifierListe(); - } - } - else{ - return $this->viewHome(); - } + + $id=$_POST["id"]; + + $req = Liste::select()->where('id', '=',$id); + $liste = $req->first(); + + $liste->url=bin2hex(random_bytes(20)); + $liste->save(); + + $this->viewUserListes(); + + + + + } -} \ No newline at end of file +} diff --git a/src/mecado/model/Utilisateur.php b/src/mecado/model/Utilisateur.php old mode 100755 new mode 100644 index d160397..a9035e5 --- a/src/mecado/model/Utilisateur.php +++ b/src/mecado/model/Utilisateur.php @@ -1,14 +1,14 @@ -"; + $html .= var_dump($this->data); $html .= ""; return $html; } @@ -60,10 +61,13 @@ private function renderSignUp() $html .= ""; return $html; } - private function renderUserListes() + public function renderUserListes() + { $lesListes = $this->data; - $html = ""; + $urlform = $this->script_name."/token/"; + $html = ''; + $html .= "
"; $html .=""; $html .=""; $html .=""; @@ -71,9 +75,8 @@ private function renderUserListes() $html .=""; $html .=""; $html .=""; - $html .=""; $html .=""; - + foreach ($lesListes as $uneListe){ $html .=""; $html .= ""; @@ -81,66 +84,26 @@ private function renderUserListes() $html .= ""; $html .= ""; $html .= ""; - $html .= ""; - $html .=""; + if(is_null($uneListe->url)) + { + $html .=""; + $html .= ""; + } + else + { + $html .= ""; + } + + $html .=""; } + $html .= "
NomDescriptionDestinatairePersoURLOptions
".$uneListe->nom."".$uneListe->date_limite."".$uneListe->destinataire."".$uneListe->pour_soi."".$uneListe->url."".$uneListe->url."
"; + $html .=""; return $html; + } - private function renderNewListe(){ - $chaine ="
"; - $linkform = $this->script_name."/insertListe/"; - $chaine.='
'; - $chaine.=""; - $chaine.="
"; - $chaine.=""; - $chaine.="
"; - $chaine.=""; - $chaine.="
"; - $chaine.=""; - $chaine.="
"; - $chaine.=""; - $chaine.=""; - $chaine.=""; - $chaine.=""; - $chaine.="
"; - $chaine.=""; - $chaine.="
"; - $chaine .="
"; - return $chaine; - } - private function renderModifierListe(){ - $uneListe = $this->data; - $chaine ="
"; - $linkform = $this->script_name."/setListe/?id=".$uneListe->id; - $chaine.='
'; - $chaine.=""; - $chaine.="
"; - $chaine.=""; - $chaine.="
"; - $chaine.=""; - $chaine.="
"; - $chaine.=""; - $chaine.="
"; - $chaine.=""; - if($uneListe->pour_soi == 1){ - $chaine.=""; - $chaine.=""; - $chaine.=""; - $chaine.="
"; - } - else{ - $chaine.=""; - $chaine.=""; - $chaine.=""; - $chaine.="
"; - } - $chaine.=""; - $chaine.="
"; - $chaine .="
"; - return $chaine; - } + protected function renderBody($selector=null){ $head = $this->renderHeader(); $foot = $this->renderFooter(); @@ -153,17 +116,11 @@ protected function renderBody($selector=null){ case 'viewLogin':{ $content = $this->renderLogin(); }break; - case 'viewSignUp':{ - $content = $this->renderSignUp(); - }break; case 'viewUserListes':{ $content = $this->renderUserListes(); }break; - case 'viewNewListe':{ - $content = $this->renderNewListe(); - }break; - case 'viewModifierListe':{ - $content = $this->renderModifierListe(); + case 'viewSignUp':{ + $content = $this->renderSignUp(); }break; default:{ $content = $this->renderHome(); diff --git a/src/mf/auth/AbstractAuthentification.php b/src/mf/auth/AbstractAuthentification.php old mode 100755 new mode 100644 diff --git a/src/mf/auth/Authentification.php b/src/mf/auth/Authentification.php old mode 100755 new mode 100644 diff --git a/src/mf/auth/exception/AuthentificationException.php b/src/mf/auth/exception/AuthentificationException.php old mode 100755 new mode 100644 diff --git a/src/mf/control/AbstractController.php b/src/mf/control/AbstractController.php old mode 100755 new mode 100644 diff --git a/src/mf/router/AbstractRouter.php b/src/mf/router/AbstractRouter.php old mode 100755 new mode 100644 diff --git a/src/mf/router/Router.php b/src/mf/router/Router.php old mode 100755 new mode 100644 diff --git a/src/mf/utils/AbstractHttpRequest.php b/src/mf/utils/AbstractHttpRequest.php old mode 100755 new mode 100644 diff --git a/src/mf/utils/ClassLoader.php b/src/mf/utils/ClassLoader.php old mode 100755 new mode 100644 index d926253..9968d48 --- a/src/mf/utils/ClassLoader.php +++ b/src/mf/utils/ClassLoader.php @@ -1,26 +1,26 @@ -prefix = $dir; - } - - - function loadClass($classe){ - $str = $this->prefix.DIRECTORY_SEPARATOR; - $str.= str_replace('\'',DIRECTORY_SEPARATOR,$classe); - $str.= ".php"; - if(file_exists($str)){ - require_once $str; - } - } - - function register(){ - spl_autoload_register([$this,'loadClass']); - } -} - +prefix = $dir; + } + + + function loadClass($classe){ + $str = $this->prefix.DIRECTORY_SEPARATOR; + $str.= str_replace('\\',DIRECTORY_SEPARATOR,$classe); + $str.= ".php"; + if(file_exists($str)){ + require_once $str; + } + } + + function register(){ + spl_autoload_register([$this,'loadClass']); + } +} + diff --git a/src/mf/utils/HttpRequest.php b/src/mf/utils/HttpRequest.php old mode 100755 new mode 100644 diff --git a/src/mf/view/AbstractView.php b/src/mf/view/AbstractView.php old mode 100755 new mode 100644 index db6d7eb..3b0783c --- a/src/mf/view/AbstractView.php +++ b/src/mf/view/AbstractView.php @@ -5,7 +5,7 @@ abstract class AbstractView { static protected $style_sheets = ['src/mf/html/style.css']; /* un tableau de fichiers style */ - static protected $app_title = "Mecado"; /* un titre de document */ + static protected $app_title = "MF app Title"; /* un titre de document */ protected $app_root = null; /* répertoire racine de l'application */ protected $script_name = null; /* le chemin vers le script principal */