|
|
@ -1,23 +1,30 @@
|
|
|
|
<?php
|
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
|
|
class VisitorController {
|
|
|
|
class ControleurVisiteur {
|
|
|
|
|
|
|
|
|
|
|
|
public function __construct() {
|
|
|
|
public function __construct() {
|
|
|
|
global $rep,$vues;
|
|
|
|
global $rep,$vues,$styles,$assets;
|
|
|
|
$arrayErrorViews= array();
|
|
|
|
$arrayErrorViews= array();
|
|
|
|
|
|
|
|
|
|
|
|
try{
|
|
|
|
try{
|
|
|
|
$action = $_REQUEST['action']??null;
|
|
|
|
$action = $_REQUEST['action']??null;
|
|
|
|
switch($action){
|
|
|
|
switch($action){
|
|
|
|
case NULL:
|
|
|
|
case NULL:
|
|
|
|
$this->reinit();
|
|
|
|
$this->reinit();
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'accessConnectionPage':
|
|
|
|
|
|
|
|
require($rep.$vues['connection']);
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case "accessInscription":
|
|
|
|
|
|
|
|
require($rep.$vues['inscription']);
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case "accessCreationListePage":
|
|
|
|
|
|
|
|
require($rep.$vues['creationListe']);
|
|
|
|
|
|
|
|
break;
|
|
|
|
case "connection":
|
|
|
|
case "connection":
|
|
|
|
$this->connection($arrayErrorViews);
|
|
|
|
$this->connection($arrayErrorViews);
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
case "inscription":
|
|
|
|
case "inscription":
|
|
|
|
$this->inscription($arrayErrorViews);
|
|
|
|
$this->inscription($arrayErrorViews);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case "creerListe":
|
|
|
|
case "creerListe":
|
|
|
|
$this->creerListe($arrayErrorViews);
|
|
|
|
$this->creerListe($arrayErrorViews);
|
|
|
|
break;
|
|
|
|
break;
|
|
|
@ -30,74 +37,88 @@ class VisitorController {
|
|
|
|
case "cocherTache":
|
|
|
|
case "cocherTache":
|
|
|
|
$this->cocherTache($arrayErrorViews);
|
|
|
|
$this->cocherTache($arrayErrorViews);
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
case "decocherTache":
|
|
|
|
|
|
|
|
$this->decocherTache($arrayErrorViews);
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case "supprTache":
|
|
|
|
case "supprTache":
|
|
|
|
$this->supprTache($arrayErrorViews);
|
|
|
|
$this->supprTache($arrayErrorViews);
|
|
|
|
default :
|
|
|
|
default :
|
|
|
|
$arrayErrorViews[]="Erreur innatendue !!!";
|
|
|
|
$arrayErrorViews[]="Erreur innatendue !!!";
|
|
|
|
require($rep.$vues['error']);
|
|
|
|
require($rep.$vues['acceuil']);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} catch(PDOException $e){
|
|
|
|
} catch(PDOException $e){
|
|
|
|
$dataView[]="Erreur inatendue";
|
|
|
|
$dataView[]="Erreur inatendue";
|
|
|
|
require('erreur.php');
|
|
|
|
require(__DIR__.'/../vues/erreur.php');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
exit(0);
|
|
|
|
exit(0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public function reinit(){
|
|
|
|
public function reinit(){
|
|
|
|
global $rep,$vues;
|
|
|
|
global $rep,$vues,$dataView;
|
|
|
|
require($rep.$vues['acceuil.php']);
|
|
|
|
$model = new VisiteurModel();
|
|
|
|
|
|
|
|
$dataView = $model->pullPublicLists();
|
|
|
|
|
|
|
|
require($rep.$vues['acceuil']);
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public function connection(array $vues_erreur){
|
|
|
|
public function connection(array $vues_erreur){
|
|
|
|
global $rep,$vues;
|
|
|
|
global $rep,$vues,$dataView;
|
|
|
|
|
|
|
|
|
|
|
|
$usrname=$_POST['login'];
|
|
|
|
$usrname=$_POST['login'];
|
|
|
|
$pwd=$_POST['mdp'];
|
|
|
|
$pwd=$_POST['mdp'];
|
|
|
|
Validation::clear_string($pwd);
|
|
|
|
Validation::clear_string($pwd);
|
|
|
|
Validation::val_connexion($usrname,$pwd,$vues_erreur);
|
|
|
|
Validation::val_connexion($usrname,$pwd,$vues_erreur);
|
|
|
|
|
|
|
|
|
|
|
|
$model= new VisiteurModel();
|
|
|
|
$model= new VisiteurModel();
|
|
|
|
$worked=$model->connexion();
|
|
|
|
if($model->existUser($usrname)){
|
|
|
|
/* Utiliser si jamais connexion n'a pas marché et qu'on veut remettre le login dans la page pour que le visiteur n'ait pas à le retaper
|
|
|
|
if(password_verify($pwd,$model->getHashedPassword($usrname))){
|
|
|
|
$dVue = array (
|
|
|
|
$model->connexion($usrname);
|
|
|
|
'username' => $usrname,
|
|
|
|
$_REQUEST['action']=null;
|
|
|
|
);
|
|
|
|
$this->reinit();
|
|
|
|
*/
|
|
|
|
}
|
|
|
|
if($worked==false){
|
|
|
|
else{
|
|
|
|
require('erreur.php');
|
|
|
|
$arrayErrorViews =array('username'=>$usrname,'password'=>$pwd);
|
|
|
|
|
|
|
|
require($rep.$vues['erreur']);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else{
|
|
|
|
|
|
|
|
$arrayErrorViews =array('username'=>$usrname,'password'=>$pwd);
|
|
|
|
|
|
|
|
require($rep.$vues['erreur']);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public function inscription(array $vues_erreur){
|
|
|
|
public function inscription(array $vues_erreur){
|
|
|
|
global $rep,$vues;
|
|
|
|
global $rep,$vues,$dataView;
|
|
|
|
require($rep.$vues['inscription']);
|
|
|
|
$usrname=$_POST['username'];
|
|
|
|
|
|
|
|
$pwd=$_POST['password'];
|
|
|
|
$usrname=$_POST['login'];
|
|
|
|
$confirm=$_POST['confirmpassword'];
|
|
|
|
$pwd=$_POST['mdp'];
|
|
|
|
$vues_erreur=Validation::val_inscription($usrname,$pwd,$confirm,$vues_erreur);
|
|
|
|
Validation::val_connexion($usrname,$pwd,$vues_erreur);
|
|
|
|
if($vues_erreur == []){
|
|
|
|
|
|
|
|
$hash= password_hash($pwd,PASSWORD_DEFAULT);
|
|
|
|
$model = new VisiteurModel();
|
|
|
|
$model = new VisiteurModel();
|
|
|
|
$model->inscription();
|
|
|
|
$model->inscription($usrname,$hash);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
$_REQUEST['action']=null;
|
|
|
|
|
|
|
|
new ControleurVisiteur();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public function creerListe(array $vues_erreur){
|
|
|
|
public function creerListe(array $vues_erreur){
|
|
|
|
global $rep, $vues;
|
|
|
|
global $rep, $vues;
|
|
|
|
require($rep.$vues['creationListe']);
|
|
|
|
$nom=$_POST['name'];
|
|
|
|
|
|
|
|
$model = new ListeModel();
|
|
|
|
$nom=$_POST['nom'];
|
|
|
|
if(isset($_SESSION['login'])){
|
|
|
|
|
|
|
|
foreach($_POST['private'] as $valeur){
|
|
|
|
$model = new VisiteurModel();
|
|
|
|
$private=$valeur;
|
|
|
|
$model->creerListe($nom);
|
|
|
|
$model->creerListe($nom,$private);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else{
|
|
|
|
|
|
|
|
$model->creerListe($nom,null);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
$_REQUEST['action']=null;
|
|
|
|
|
|
|
|
$this->reinit();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public function supprListe(array $vues_erreur){
|
|
|
|
public function supprListe(array $vues_erreur){
|
|
|
|
global $rep, $vues;
|
|
|
|
global $rep, $vues;
|
|
|
|
require($rep.$vues['suppressionListe']);
|
|
|
|
require($rep.$vues['suppressionListe']);
|
|
|
|
|
|
|
|
|
|
|
|
$model = new VisiteurModel();
|
|
|
|
$model = new ListeModel();
|
|
|
|
$model->supprListe();
|
|
|
|
$model->supprListe();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -107,39 +128,9 @@ class VisitorController {
|
|
|
|
|
|
|
|
|
|
|
|
$intitule = $_POST['intitule'];
|
|
|
|
$intitule = $_POST['intitule'];
|
|
|
|
|
|
|
|
|
|
|
|
$model = new VisiteurModel();
|
|
|
|
$model = new ListeModel();
|
|
|
|
$model->creerTache();
|
|
|
|
$model->creerTache();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public function cocherTache(array $vues_erreur){
|
|
|
|
|
|
|
|
global $rep, $vues;
|
|
|
|
|
|
|
|
require($rep.$vues['liste']);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$id = $_POST['idTache'];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$model = new VisiteurModel();
|
|
|
|
|
|
|
|
$model->cocherTache($id);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public function decocherTache(array $vues_erreur){
|
|
|
|
|
|
|
|
global $rep, $vues;
|
|
|
|
|
|
|
|
require($rep.$vues['liste']);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$id = $_POST['idTache'];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$model = new VisiteurModel();
|
|
|
|
|
|
|
|
$model->decocherTache($id);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public function supprTache(array $vues_erreur){
|
|
|
|
|
|
|
|
global $rep, $vues;
|
|
|
|
|
|
|
|
require($rep.$vues['liste']);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$id = $_POST['idTache'];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$model = new VisiteurModel();
|
|
|
|
|
|
|
|
$model->supprTache($id);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
?>
|
|
|
|
?>
|