ADD : modification et fin du projet

master
Lucie Bedouret 2 years ago
parent 92e177f06f
commit 51c8d72db7

@ -58,17 +58,6 @@
return $dataVueEreur; return $dataVueEreur;
} }
static function val_id($id, $dataVueEreur){
if (!isset($id)||$id=""){
$dataVueEreur[] = "Id error";
}
if($id != filter_var($id, FILTER_VALIDATE_INT)){
$dataVueEreur[] = "Id validation error";
$id = 0;
}
return $dataVueEreur;
}
static function clear_string($champ){ static function clear_string($champ){
return filter_var($champ, FILTER_SANITIZE_STRING); return filter_var($champ, FILTER_SANITIZE_STRING);
} }

@ -3,7 +3,7 @@
//Prefixe //Prefixe
$rep=__DIR__.'/../'; $rep=__DIR__.'/../';
//BD //BD
$bd['dsn'] = "mysql:host=localhost;port=8888;dbname=bdPhp"; $bd['dsn'] = "mysql:host=localhost;port=8888;dbname=dbPhp";
$bd['user'] = "root"; $bd['user'] = "root";
$bd['pswd'] = "root"; $bd['pswd'] = "root";
//Vues //Vues

@ -4,7 +4,7 @@ class ControleurVisiteur {
public function __construct() { public function __construct() {
global $rep,$vues,$dataView,$styles,$assets; global $rep,$vues,$dataView,$styles,$assets;
$arrayErrorViews= array(); $vues_erreur= array();
try{ try{
$action = $_REQUEST['action']??null; $action = $_REQUEST['action']??null;
switch($action){ switch($action){
@ -28,33 +28,33 @@ class ControleurVisiteur {
require($rep.$vues['creationTache']); require($rep.$vues['creationTache']);
break; break;
case "addTache": case "addTache":
$this->addTache($arrayErrorViews); $this->addTache($vues_erreur);
break; break;
case "accessListInfos": case "accessListInfos":
$this->accessListInfos($arrayErrorViews); $this->accessListInfos($vues_erreur);
break; break;
case "delTache": case "delTache":
$this->delTache($arrayErrorViews); $this->delTache($vues_erreur);
break; break;
case "changeCompletedTache": case "changeCompletedTache":
$this->changeCompletedTache($arrayErrorViews); $this->changeCompletedTache($vues_erreur);
break; break;
case "connection": case "connection":
$this->connection($arrayErrorViews); $this->connection($vues_erreur);
break; break;
case "inscription": case "inscription":
$this->inscription($arrayErrorViews); $this->inscription($vues_erreur);
case "creerListe": case "creerListe":
$this->creerListe($arrayErrorViews); $this->creerListe($vues_erreur);
break; break;
case "delListe": case "delListe":
$this->delListe($arrayErrorViews); $this->delListe($vues_erreur);
break; break;
case "deconnection": case "deconnection":
$this->deconnection($arrayErrorViews); $this->deconnection($vues_erreur);
break; break;
default : default :
$arrayErrorViews[]="Erreur innatendue !!!"; $vues_erreur[]="Erreur innatendue !!!";
require($rep.$vues['acceuil']); require($rep.$vues['acceuil']);
} }
} catch(PDOException $e){ } catch(PDOException $e){
@ -65,12 +65,13 @@ class ControleurVisiteur {
} }
function deconnection($arrayErrorViews){ function deconnection($vues_erreur){
global $rep, $vues, $dataView; global $rep, $vues, $dataView;
$model = new UserModel(); $model = new UserModel();
$retour = $model->deconnection(); $retour = $model->deconnection();
$_REQUEST['action']=null; $_REQUEST['action']=null;
$control= new ControleurVisiteur(); $control= new ControleurVisiteur();
$vues_erreur= array();
} }
public function reinit(){ public function reinit(){
@ -78,49 +79,54 @@ class ControleurVisiteur {
$model = new ListeModel(); $model = new ListeModel();
$dataView = $model->pullPublicLists(); $dataView = $model->pullPublicLists();
require($rep.$vues['acceuil']); require($rep.$vues['acceuil']);
$vues_erreur= array();
} }
public function accessListInfos($arrayErrorViews){ public function accessListInfos($vues_erreur){
global $rep,$vues,$dataView; global $rep,$vues,$dataView;
$idListe=$_POST['liste']; $idListe=$_POST['liste'];
$arrayErrorViews = Validation::val_id($idListe, $arrayErrorViews);
$model = new ListeModel(); $model = new ListeModel();
$dataView = $model->pullListById($idListe); $dataView = $model->pullListById($idListe);
require($rep.$vues['infosListe']); require($rep.$vues['infosListe']);
$vues_erreur= array();
} }
public function addTache($arrayErrorViews){ public function addTache($vues_erreur){
global $rep,$vues,$dataView; global $rep,$vues,$dataView;
$nom=$_POST['name']; $nom=$_POST['name'];
$idListe=$_POST['liste']; $idListe=$_POST['liste'];
$arrayErrorViews = Validation::val_intitule($name, $arrayErrorViews); $vues_erreur = Validation::val_intitule($nom, $vues_erreur);
$arrayErrorViews = Validation::val_id($idListe, $arrayErrorViews); if(!empty($vues_erreur)){
require($rep.$vues['creationTache']);
}
else{
$model = new TacheModel(); $model = new TacheModel();
$model->addTache($nom,$idListe); $model->addTache($nom,$idListe);
$_REQUEST['action']="accessListInfos"; $_REQUEST['action']="accessListInfos";
$this->accessListInfos($arrayErrorViews); $this->accessListInfos($vues_erreur);
$vues_erreur= array();
}
} }
public function delTache($arrayErrorViews){ public function delTache($vues_erreur){
global $rep,$vues,$dataView; global $rep,$vues,$dataView;
$idTache=$_POST['tache']; $idTache=$_POST['tache'];
$arrayErrorViews = Validation::val_id($idTache, $arrayErrorViews);
$model= new TacheModel(); $model= new TacheModel();
$model->delTache($idTache); $model->delTache($idTache);
$_REQUEST['action']="accessListInfos"; $_REQUEST['action']="accessListInfos";
$this->accessListInfos($arrayErrorViews); $this->accessListInfos($vues_erreur);
$vues_erreur= array();
} }
public function changeCompletedTache($arrayErrorViews){ public function changeCompletedTache($vues_erreur){
global $rep,$vues,$dataView; global $rep,$vues,$dataView;
$idTache=$_POST['tache']; $idTache=$_POST['tache'];
$arrayErrorViews = Validation::val_id($idTache, $arrayErrorViews);
$model = new TacheModel(); $model = new TacheModel();
$model->changeCompletedTache($idTache); $model->changeCompletedTache($idTache);
$_REQUEST['action']="accessListInfos"; $_REQUEST['action']="accessListInfos";
$this->accessListInfos($arrayErrorViews); $this->accessListInfos($vues_erreur);
$vues_erreur= array();
} }
public function connection(array $vues_erreur){ public function connection(array $vues_erreur){
@ -137,6 +143,7 @@ class ControleurVisiteur {
$model->connexion($usrname); $model->connexion($usrname);
$_REQUEST['action']=null; $_REQUEST['action']=null;
$this->reinit(); $this->reinit();
$vues_erreur= array();
} }
else{ else{
$vues_erreur =array('username'=>$usrname,'password'=>$pwd); $vues_erreur =array('username'=>$usrname,'password'=>$pwd);
@ -162,6 +169,7 @@ class ControleurVisiteur {
if(empty($vues_erreur)){ if(empty($vues_erreur)){
$hash= password_hash($pwd,PASSWORD_DEFAULT); $hash= password_hash($pwd,PASSWORD_DEFAULT);
$model->inscription($usrname,$hash); $model->inscription($usrname,$hash);
$vues_erreur= array();
} }
else{ else{
require($rep.$vues['inscription']); require($rep.$vues['inscription']);
@ -175,6 +183,10 @@ class ControleurVisiteur {
global $rep, $vues; global $rep, $vues;
$nom=$_POST['name']; $nom=$_POST['name'];
$vues_erreur=Validation::val_intitule($nom, $vues_erreur); $vues_erreur=Validation::val_intitule($nom, $vues_erreur);
if(!empty($vues_erreur)){
require($rep.$vues['creationListe']);
}
else{
$model = new ListeModel(); $model = new ListeModel();
if(isset($_SESSION['login'])){ if(isset($_SESSION['login'])){
$private=$_POST['private']; $private=$_POST['private'];
@ -185,16 +197,19 @@ class ControleurVisiteur {
} }
$_REQUEST['action']=null; $_REQUEST['action']=null;
$this->reinit(); $this->reinit();
$vues_erreur= array();
}
} }
public function delListe(array $vues_erreur){ public function delListe(array $vues_erreur){
global $rep, $vues; global $rep, $vues;
$idListe=$_POST['liste']; $idListe=$_POST['liste'];
$arrayErrorViews = Validation::val_id($idListe, $arrayErrorViews);
$model = new ListeModel(); $model = new ListeModel();
$model->delListe($idListe); $model->delListe($idListe);
$_REQUEST['action']=null; $_REQUEST['action']=null;
$this->reinit(); $this->reinit();
$vues_erreur= array();
} }
} }

@ -20,7 +20,7 @@
<h4>Password</h4> <h4>Password</h4>
<input type="password" name="mdp" required/> <input type="password" name="mdp" required/>
<?php <?php
if(isset($vues_erreur)){ if(!empty($vues_erreur)){
echo '<h4 id="error">Incorrect Username or Password</h4>'; echo '<h4 id="error">Incorrect Username or Password</h4>';
} }
?> ?>

@ -28,7 +28,7 @@
?> ?>
<br/> <br/>
<?php <?php
if(isset($vues_erreur)){ if(!empty($vues_erreur)){
echo '<h4 id="error">'.$vues_erreur[0].'</h4>'; echo '<h4 id="error">'.$vues_erreur[0].'</h4>';
} }
?> ?>

@ -20,7 +20,7 @@
<br/> <br/>
<?php <?php
if(isset($vues_erreur)){ if(!empty($vues_erreur)){
echo '<h4 id="error">'.$vues_erreur[0].'</h4>'; echo '<h4 id="error">'.$vues_erreur[0].'</h4>';
} }
?> ?>

@ -61,6 +61,7 @@
<input type="hidden" name="action" value="accessCreationTachePage"/> <input type="hidden" name="action" value="accessCreationTachePage"/>
<input type="hidden" name="liste" value="<?=$dataView->get_id()?>"/> <input type="hidden" name="liste" value="<?=$dataView->get_id()?>"/>
</form> </form>
<form method="POST" id="delListe" name="delListe"> <form method="POST" id="delListe" name="delListe">
<input class="del-list" type="submit" value="Delete the list"/></p> <input class="del-list" type="submit" value="Delete the list"/></p>
<input type="hidden" name="action" value="delListe"/> <input type="hidden" name="action" value="delListe"/>

@ -23,7 +23,7 @@
<h4>Confirm Password</h4> <h4>Confirm Password</h4>
<input type="password" name="confirmpassword" required/> <input type="password" name="confirmpassword" required/>
<?php <?php
if(isset($vues_erreur)){ if(!empty($vues_erreur)){
echo '<h4 id="error">'.$vues_erreur[0].'</h4>'; echo '<h4 id="error">'.$vues_erreur[0].'</h4>';
} }
?> ?>

Loading…
Cancel
Save