Optimization of the code and respect of the coding standard, the project is finished

master
Emre KARTAL 2 years ago
parent e2bd0457ab
commit f721a028c8

@ -10,14 +10,25 @@ RewriteEngine On
# Règles de réécriture d'url
#---------------------------------
# Visiteur
RewriteRule ^login$ index.php?action=redirectionLogin [L]
RewriteRule ^inscription$ index.php?action=redirectionInscription [L]
RewriteRule ^VueListePublic$ index.php?action=redirectionListePublic [L]
RewriteRule ^previousPage$ index.php?action=pagePrécédente [L]
RewriteRule ^nextPage$ index.php?action=pageSuivante [L]
RewriteRule ^check$ index.php?action=check [L]
# Utilisateur
RewriteRule ^logout$ index.php?action=logout [L]
RewriteRule ^MonProfil$ index.php?action=redirectionProfil [L]
RewriteRule ^supprimerCompte$ index.php?action=supprimerCompte [L]
RewriteRule ^previousPage$ index.php?action=pagePrécédente [L]
RewriteRule ^nextPage$ index.php?action=pageSuivante [L]
RewriteRule ^Users$ index.php?action=voirUser [L]
RewriteRule ^listePrive$ index.php?action=listePrive [L]
RewriteRule ^previousPagePrive$ index.php?action=pagePrécédentePrive [L]
RewriteRule ^nextPagePrive$ index.php?action=pageSuivantePrive [L]
RewriteRule ^checkPrive$ index.php?action=checkPrive [L]
# Admin
RewriteRule ^users$ index.php?action=redirectionVueUtilisateur [L]

@ -91,7 +91,7 @@ class Validation {
}
static function cleanText(string &$txt) {
$txt = preg_replace('/[^A-Za-z\-\^0-9\ ]/', '', $txt);
$txt = preg_replace('/[^A-Za-z\-\^0-9\ \à\é\^]/', '', $txt);
if($txt == null || $txt == '')
{
return null;

@ -16,7 +16,6 @@ class CtrlUtilisateur {
switch($action) {
case NULL:
$this->ConsulterListePrive($dVueErreur);
break;
@ -65,6 +64,14 @@ class CtrlUtilisateur {
$this->SupprimerListePrive($dVueErreur);
break;
case "pagePrécédentePrive":
$this->listePrécédente($dVueErreur);
break;
case "pageSuivantePrive":
$this->listeSuivante($dVueErreur);
break;
default:
$dVueErreur[] = "Erreur d'appel php";
require ($rep.$vues['erreur']);
@ -129,20 +136,20 @@ class CtrlUtilisateur {
function ConsulterListePrive(array $dVueErreur) {
global $rep,$vues;
$listesPrive = MdlUtilisateur::RecupererListePrive();
$taches = MdlVisiteur::RecupererTache();
$taches = MdlUtilisateur::RecupererTache();
$action=NULL;
require ($rep.$vues['listPrive']);
}
function SupprimerTachePrive(array $dVueErreur){
global $rep,$vues;
$tache = MdlVisiteur::SupprimerTache();
$tache = MdlUtilisateur::SupprimerTache();
$this->ConsulterListePrive($dVueErreur);
}
function SupprimerListePrive(array $dVueErreur){
global $rep,$vues;
$liste = MdlVisiteur::SupprimerListe();
$liste = MdlUtilisateur::SupprimerListe();
$this->ConsulterListePrive($dVueErreur);
}
@ -150,14 +157,14 @@ class CtrlUtilisateur {
public function AjouterTachePrive(array $dVueErreur){
global $rep,$vues;
try{
$tache = MdlVisiteur::AjouterTache($dVueErreur);
$tache = MdlUtilisateur::AjouterTache($dVueErreur);
$this->ConsulterListePrive($dVueErreur);
}
catch (Exception $e)
{
$ErreurLog=$e->getMessage();
$listesPrive= MdlUtilisateur::RecupererListePrive();
$taches = MdlVisiteur::RecupererTache();
$taches = MdlUtilisateur::RecupererTache();
$action=NULL;
require ($rep.$vues['listPrive']);
}
@ -167,14 +174,14 @@ class CtrlUtilisateur {
public function ModifierListePrive(array $dVueErreur){
global $rep,$vues;
try{
$tache = MdlVisiteur::ModifierListe($dVueErreur);
$tache = MdlUtilisateur::ModifierListe($dVueErreur);
$this->ConsulterListePrive($dVueErreur);
}
catch (Exception $e)
{
$ErreurLog=$e->getMessage();
$listesPrive= MdlUtilisateur::RecupererListePrive();
$taches = MdlVisiteur::RecupererTache();
$taches = MdlUtilisateur::RecupererTache();
$action=NULL;
require ($rep.$vues['listPublic']);
}
@ -183,7 +190,7 @@ class CtrlUtilisateur {
public function checkPrive(array $dVueErreur)
{
global $rep,$vues;
$tache = MdlVisiteur::check();
$tache = MdlUtilisateur::check();
$this->ConsulterListePrive($dVueErreur);
}
@ -198,14 +205,12 @@ class CtrlUtilisateur {
{
$ErreurLog=$e->getMessage();
$listes = MdlUtilisateur::RecupererListePrive();
$taches = MdlVisiteur::RecupererTache();
$taches = MdlUtilisateur::RecupererTache();
$action=NULL;
require ($rep.$vues['listPrive']);
}
}
public function listePrécédente(array $dVueErreur){
if($_COOKIE['pageUser'] > 1){
setcookie('pageUser', $_COOKIE['pageUser'] - 1, time() + 24*3600);

@ -160,10 +160,7 @@ class CtrlVisiteur {
function SupprimerListe(array $dVueErreur){
global $rep,$vues;
$liste = MdlVisiteur::SupprimerListe();
$listes = MdlVisiteur::RecupererListePublic();
$taches = MdlVisiteur::RecupererTache();
$action=NULL;
require ($rep.$vues['listPublic']);
$this->ConsulterListePublic($dVueErreur);
}
public function AjouterTache(array $dVueErreur){

@ -14,7 +14,7 @@ class FrontControleur {
$string_actor=' ';
$listeActions=array(
'Utilisateur' => array('logout','redirectionProfil','supprimerCompte', 'listePrive','AjouterListePrive', 'checkPrive', 'SupprimerListePrive', 'AjouterTachePrive', 'ModifierListePrive', 'SupprimerTachePrive'),
'Utilisateur' => array('logout','redirectionProfil','pageSuivantePrive','pagePrécédentePrive','supprimerCompte','modifMdp' ,'listePrive','AjouterListePrive', 'checkPrive', 'SupprimerListePrive', 'AjouterTachePrive', 'ModifierListePrive', 'SupprimerTachePrive'),
'Admin' => array('redirectionVueUtilisateur','SupprimerUtilisateur')
);

@ -54,6 +54,26 @@ class MdlUtilisateur
return $listeGtw->CountListe(intval($id));
}
public function ModifierListe(&$dVueErreur){
$userGtw = new ListeGateway();
$id = $_POST['idListe'];
$nom = Validation::cleanText($_POST['nom-modif-liste']);
$description = Validation::cleanText($_POST['description-modif-liste']);
if($nom == NULL && $description==null){
return null;
}
if($description == NULL){
$userGtw->EditerNom($id, $nom);
}
else if($nom == NULL){
$userGtw->EditerDescription($id, $description);
}
else{
$userGtw->Editer($id, $nom, $description);
}
}
public static function suppressionUtilisateur(){
$userGtw = new UtilisateurGateway();
@ -85,12 +105,12 @@ class MdlUtilisateur
}
public static function AjouterListePrive(&$dVueErreur){
$taskGtw = new ListeGateway();
$listGtw = new ListeGateway();
$nom=$_POST['nom-ajout-liste'];
$description=$_POST['description-ajout-liste'];
$idCreateur =Validation::cleanInt($_SESSION['id']);
Validation::val_form_add($nom,$description,$dVueErreur);
$taskGtw->Ajouter($nom, $description,0, $idCreateur);
$listGtw->Ajouter($nom, $description,0, $idCreateur);
}
public static function RecupererListePrive(){
@ -101,5 +121,38 @@ class MdlUtilisateur
return $listeGtw->getListePrive(1,10);
}
public static function RecupererTache(){
$taskGtw = new TacheGateway();
return $taskGtw->getTache();
}
public static function SupprimerListe(){
$listeGtw = new ListeGateway();
$taskGtw = new TacheGateway();
$id = $_GET['idListe'];
$taskGtw->SupprimerViaListe($id);
$listeGtw->Supprimer($id);
}
public static function check(){
$taskGtw = new TacheGateway();
$id = $_POST['idTache'];
$taskGtw->isDone($id);
}
public static function SupprimerTache(){
$taskGtw = new TacheGateway();
$id = $_GET['idTache'];
$taskGtw->Supprimer($id);
}
public function AjouterTache(&$dVueErreur){
$taskGtw = new TacheGateway();
$id = $_POST['idListe'];
$nom = $_POST['nom-ajout'];
$description = $_POST['description-ajout'];
Validation::val_form_add($nom,$description,$dVueErreur);
$taskGtw->AjouterTache($nom, $description,false,$id);
}
}

@ -16,31 +16,31 @@ class MdlVisiteur
$userGtw->AjouterUtilisateur($_POST["nom-Form"],$_POST["prenom-Form"],$_POST["pseudo-Form"],$_POST["mail"],$hash);
}
public static function RecupererListePublic(){
$userGtw = new ListeGateway();
public static function RecupererListePublic(){
$listGtw = new ListeGateway();
if(isset($_COOKIE["page"]))
return $userGtw->getListePublic(($_COOKIE["page"]-1)*10,10);
return $listGtw->getListePublic(($_COOKIE["page"]-1)*10,10);
else
return $userGtw->getListePublic(1,10);
return $listGtw->getListePublic(1,10);
}
public static function RecupererTache(){
$userGtw = new TacheGateway();
return $userGtw->getTache();
$taskGtw = new TacheGateway();
return $taskGtw->getTache();
}
public static function SupprimerTache(){
$userGtw = new TacheGateway();
$taskGtw = new TacheGateway();
$id = $_GET['idTache'];
$userGtw->Supprimer($id);
$taskGtw->Supprimer($id);
}
public static function SupprimerListe(){
$userGtw = new ListeGateway();
$listGtw = new ListeGateway();
$taskGtw = new TacheGateway();
$id = $_GET['idListe'];
$taskGtw->SupprimerViaListe($id);
$userGtw->Supprimer($id);
$listGtw->Supprimer($id);
}
public function AjouterTache(&$dVueErreur){
@ -53,19 +53,22 @@ public static function RecupererListePublic(){
}
public function ModifierListe(&$dVueErreur){
$userGtw = new ListeGateway();
$listGtw = new ListeGateway();
$id = $_POST['idListe'];
$nom = Validation::cleanText($_POST['nom-modif-liste']);
$description = Validation::cleanText($_POST['description-modif-liste']);
if($nom == NULL && $description==null){
return null;
}
if($description == NULL){
$userGtw->EditerNom($id, $nom);
$listGtw->EditerNom($id, $nom);
}
else if($nom == NULL){
$userGtw->EditerDescription($id, $description);
$listGtw->EditerDescription($id, $description);
}
else{
$userGtw->Editer($id, $nom, $description);
$listGtw->Editer($id, $nom, $description);
}
}
@ -77,9 +80,9 @@ public static function RecupererListePublic(){
$listGtw->Ajouter($nom, $description,1, 1);
}
public function check(){
public static function check(){
$taskGtw = new TacheGateway();
$id = $_POST['idTache'];
$id = Validation::cleanInt($_POST['idTache']);
$taskGtw->isDone($id);
}

@ -47,13 +47,6 @@ class ListeGateway{
$this->con->executeQuery($query,array('id' => array($id, PDO::PARAM_INT)));
}
public function getListe(int $offset, int $limit){
$query = "SELECT * FROM ToDoList_Liste LIMITS $offset,$limit";
$this->con->executeQuery($query);
$listes=$this->con->getResults();
return $listes;
}
public function getListePublic($offset,$limit){
$query = "SELECT * FROM ToDoList_Liste WHERE estPublic LIMIT $offset, $limit";
$this->con->executeQuery($query);

@ -27,7 +27,7 @@ class UtilisateurGateway{
$query="SELECT * FROM ToDoList_Admin WHERE idAdmin=:id";
$this->con->executeQuery($query, array(
'id' => array($id, PDO::PARAM_INT)));
$results=$this->con->getResults();
$results=$this->con->getResults();
if($results!=null){
return true;
}else{

Binary file not shown.

Before

Width:  |  Height:  |  Size: 247 B

@ -26,7 +26,6 @@ body::before {
z-index: -1;
}
/* Model */
.model {

@ -200,7 +200,7 @@
$total = $total + 1;
?>
<li class="list-group-item border-0 d-flex align-items-center ps-0">
<form name="action" action="index.php?action=checkPrive" method="POST">
<form name="action" action="checkPrive" method="POST">
<input class="form-check-input me-3" id="task-<?= $tache->getId() ?>" type="checkbox" onChange="submit();"
<?php if($tache->getEstValide() == 1) echo "checked" ?>>
<label for="task-<?= $tache->getId() ?>"> <?= $tache->getNom() ?> : <?= $tache->getDescription() ?></label>
@ -209,7 +209,7 @@
</form>
<a href="index.php?action=SupprimerTachePrive&idTache=<?= $tache->getId() ?>">
<button class="btn btn-default">
<img src="./vue/Images/trash2.png" width="20" />
<img src="./vue/Images/trash.png" width="20" />
</button>
</a>
</li>
@ -240,21 +240,21 @@
<nav aria-label="Page navigation example">
<center>
<p>Page n°<?php echo $_COOKIE['page'] ?></p>
<p>Page n°<?php echo $_COOKIE['pageUser'] ?></p>
</center>
<ul class="pagination justify-content-center">
<li class="page-item">
<a class="page-link" href="previousPage">Previous</a>
<a class="page-link" href="previousPagePrive">Previous</a>
</li>
<li class="page-item">
<a class="page-link" href="nextPage">Next</a>
<a class="page-link" href="nextPagePrive">Next</a>
</li>
</ul>
</nav>
</body>
<!-- Footer -->
<footer class="text-center text-lg-start bg-light ">
<footer class="text-center text-lg-start bg-light sticky-bottom">
<br>
<!-- Section: Links -->
<section class="">

@ -179,7 +179,7 @@
?>
<li class="list-group-item border-0 d-flex align-items-center ps-0">
<form name="action" action="index.php?action=check" method="POST">
<form name="action" action="check" method="POST">
<input class="form-check-input me-3" id="task-<?= $tache->getId() ?>" type="checkbox" onChange="submit();"
<?php if($tache->getEstValide() == 1) echo "checked" ?>>
<label for="task-<?= $tache->getId() ?>"> <?= $tache->getNom() ?> : <?= $tache->getDescription() ?></label>
@ -188,7 +188,7 @@
</form>
<a href="index.php?action=SupprimerTache&idTache=<?= $tache->getId() ?>">
<button class="btn btn-default">
<img src="./vue/Images/trash2.png" width="20" />
<img src="./vue/Images/trash.png" width="20" />
</button>
</a>
</li>
@ -220,7 +220,7 @@
<center>
<p>Page n°<?php echo $_COOKIE['page'] ?></p>
</center>
<ul class="pagination justify-content-center">
<ul class="pagination justify-content-center ">
<li class="page-item">
<a class="page-link" href="previousPage">Previous</a>
</li>
@ -232,7 +232,7 @@
</body>
<!-- Footer -->
<footer class="text-center text-lg-start bg-light ">
<footer class="text-center text-lg-start bg-light sticky-bottom">
<br>
<!-- Section: Links -->
<section class="">

@ -15,7 +15,6 @@
</head>
<body>
<div class="model">
<h1>Un problème est survenue !</h1>
<?php
@ -27,6 +26,5 @@
?>
<a href="VueListePublic">Revenir</a>
</div>
</body>
</body>
</html>

@ -1,87 +1,87 @@
<!DOCTYPE html>
<html>
<head>
<title>Page d'inscription</title>
<link rel="shortcut icon" href="./vue/Images/gif.gif" type="../Images/gif">
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<!-- CSS only -->
<link rel="stylesheet" href="./vue/css/style.css">
<link rel="stylesheet" href="./vue/css/reset.css">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@4.0.0/dist/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
</head>
<body>
<div class="main">
<div class="model">
<div class="main-logo">
<img src="./vue/Images/Logo.png" alt="logo">
</div>
<div class="login-card-header">
<h1>Inscrivez-vous</h1>
</div>
<?php
if(isset($ErreurLog)){?>
<center><p class="ErreurText"> <?php echo $ErreurLog?></p></center><?php
}
?>
<form method="POST" class="login-card-form">
<div class="row">
<head>
<title>Page d'inscription</title>
<link rel="shortcut icon" href="./vue/Images/gif.gif" type="../Images/gif">
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<!-- CSS only -->
<link rel="stylesheet" href="./vue/css/style.css">
<link rel="stylesheet" href="./vue/css/reset.css">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@4.0.0/dist/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
</head>
<body>
<div class="main">
<div class="model">
<div class="main-logo">
<img src="./vue/Images/Logo.png" alt="logo">
</div>
<div class="login-card-header">
<h1>Inscrivez-vous</h1>
</div>
<?php
if(isset($ErreurLog)){?>
<center><p class="ErreurText"> <?php echo $ErreurLog?></p></center><?php
}
?>
<form method="POST" class="login-card-form">
<div class="row">
<div class="col-md-6 mb-4">
<?php
if(isset($dVueErreur['nom'])){?>
<center><p class="ErreurText"> <?php echo $dVueErreur['nom']?></p></center><?php
}
?>
<div>
<input type="text" name="nom-Form" placeholder="Nom" required autofocus>
</div>
</div>
<div class="col-md-6 mb-4">
<?php
if(isset($dVueErreur['nom'])){?>
<center><p class="ErreurText"> <?php echo $dVueErreur['nom']?></p></center><?php
if(isset($dVueErreur['prenom'])){?>
<center><p class="ErreurText"> <?php echo $dVueErreur['prenom']?></p></center><?php
}
?>
<div>
<input type="text" name="nom-Form" placeholder="Nom" required autofocus>
</div>
</div>
<div class="col-md-6 mb-4">
<?php
if(isset($dVueErreur['prenom'])){?>
<center><p class="ErreurText"> <?php echo $dVueErreur['prenom']?></p></center><?php
}
?>
<div>
<input type="text" name="prenom-Form" placeholder="Prenom" required autofocus>
</div>
<input type="text" name="prenom-Form" placeholder="Prenom" required autofocus>
</div>
</div>
<div class="form-item">
<?php
if(isset($dVueErreur['pseudo'])){?>
<center><p class="ErreurText"> <?php echo $dVueErreur['pseudo']?></p></center><?php
}
?>
<input type="text" name="pseudo-Form" placeholder="Pseudo" required autofocus>
</div>
</div>
<div class="form-item">
<?php
if(isset($dVueErreur['pseudo'])){?>
<center><p class="ErreurText"> <?php echo $dVueErreur['pseudo']?></p></center><?php
}
?>
<input type="text" name="pseudo-Form" placeholder="Pseudo" required autofocus>
</div>
<div class="form-item">
<?php
if(isset($dVueErreur['mail'])){?>
<center><p class="ErreurText"> <?php echo $dVueErreur['mail']?></p></center><?php
}
?>
<input type="text" name="mail" placeholder="Mail" required autofocus>
</div>
<div class="form-item">
<?php
if(isset($dVueErreur['password'])){?>
<center><p class="ErreurText"> <?php echo $dVueErreur['password']?></p></center><?php
}
?>
<input type="password" name="password" placeholder="Password" required >
</div>
<div class="form-item">
<?php
if(isset($dVueErreur['mail'])){?>
<center><p class="ErreurText"> <?php echo $dVueErreur['mail']?></p></center><?php
}
?>
<input type="text" name="mail" placeholder="Mail" required autofocus>
</div>
<div class="form-item">
<?php
if(isset($dVueErreur['password'])){?>
<center><p class="ErreurText"> <?php echo $dVueErreur['password']?></p></center><?php
}
?>
<input type="password" name="password" placeholder="Password" required >
</div>
<button type="submit" class="btn btn-primary">S'inscrire</button>
<!-- action !!!!!!!!!! -->
<input type="hidden" name="action" value="validationFormulaire">
<p class="text-center text-muted mt-5 mb-0">Déjà un compte?
<a href="login" class="fw-bold text-body"><u>Connectez-vous</u></a></p>
</form>
</div>
<button type="submit" class="btn btn-primary">S'inscrire</button>
<!-- action !!!!!!!!!! -->
<input type="hidden" name="action" value="validationFormulaire">
<p class="text-center text-muted mt-5 mb-0">Déjà un compte?
<a href="login" class="fw-bold text-body"><u>Connectez-vous</u></a></p>
</form>
</div>
</body>
</div>
</body>
</html>
Loading…
Cancel
Save