From c66e7e7dc9ab290c79f15da223da8fc0bdecf718 Mon Sep 17 00:00:00 2001 From: SeekDaSky Date: Thu, 3 Dec 2015 10:02:40 +0100 Subject: [PATCH 1/3] correction et ajout du snipet d'authentification pour le Dashboard --- Dashboard.php | 9 +++++++-- index.php | 22 +++------------------- 2 files changed, 10 insertions(+), 21 deletions(-) diff --git a/Dashboard.php b/Dashboard.php index 9ba739c..c9170bd 100755 --- a/Dashboard.php +++ b/Dashboard.php @@ -1,4 +1,9 @@ - + @@ -38,4 +43,4 @@ - \ No newline at end of file + diff --git a/index.php b/index.php index c07c582..7feb6de 100755 --- a/index.php +++ b/index.php @@ -29,30 +29,14 @@ if(Authentification::checkUser(0)){ - + - "; - - /* AFFICHAGE D'ERREURS */ - if( $postVariablesAreSet ){ // si formulaire soumis - if( !$postVariablesNEmpty ) - echo 'Certains champs requis sont vides.'; - elseif( !$usernameCheck ) - echo 'Nom d\'utilisateur incorrect. (3 car. min)'; - elseif( !$mailCheck ) - echo 'Adresse mail incorrecte.'; - elseif( !$passwordCheck ) - echo 'Mot de passe incorrect. (8 car. min)'; - elseif( connected($user) ) - echo 'Vous êtes connectés.'; - } - echo ""; echo ""; echo ""; @@ -62,4 +46,4 @@ if(Authentification::checkUser(0)){ - \ No newline at end of file + From c64bf617b93525a9177aafae10c8090a79c89520 Mon Sep 17 00:00:00 2001 From: SeekDaSky Date: Thu, 3 Dec 2015 10:43:27 +0100 Subject: [PATCH 2/3] =?UTF-8?q?Impl=C3=A9mentation=20des=20Repo=20Patient?= =?UTF-8?q?=20et=20Medecin=20(pas=20test=C3=A9)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Docs/BDD.sql | 2 +- repositories/StaticRepo.php | 3 +++ repositories/repos/MedecinRepo.php | 24 ++++++++++++++++++++---- repositories/repos/PatientRepo.php | 23 +++++++++++++++++++---- src/Authentification.php | 4 ++-- 5 files changed, 45 insertions(+), 11 deletions(-) diff --git a/Docs/BDD.sql b/Docs/BDD.sql index ac9320d..966eaff 100644 --- a/Docs/BDD.sql +++ b/Docs/BDD.sql @@ -46,7 +46,7 @@ CREATE TABLE IF NOT EXISTS `Patient` ( `Adresse` varchar(255) NOT NULL, `Adresse 2` varchar(255) DEFAULT NULL, `Ville` varchar(50) NOT NULL, - `CodePostal` varchar(4) NOT NULL, + `CodePostal` varchar(5) NOT NULL, `DateNaissance` date NOT NULL, `LieuNaissance` varchar(50) NOT NULL, `NumSecuriteSociale` varchar(15) NOT NULL, diff --git a/repositories/StaticRepo.php b/repositories/StaticRepo.php index e42f1fe..2855736 100755 --- a/repositories/StaticRepo.php +++ b/repositories/StaticRepo.php @@ -43,6 +43,9 @@ class StaticRepo{ * */ public static function delNumeric($fetchData, $oneDimension=false){ + + // cas où fetch renvoie FALSE + if( $fetchData === false ) return false; /* [1] 2 dimensions ===============================================*/ diff --git a/repositories/repos/MedecinRepo.php b/repositories/repos/MedecinRepo.php index 4545fda..337753c 100644 --- a/repositories/repos/MedecinRepo.php +++ b/repositories/repos/MedecinRepo.php @@ -22,19 +22,35 @@ class MedecinRepo } public function add($civilite,$prenom,$nom){ - + $req = $this->connexion->prepare('INSERT INTO Medecin VALUES (DEFAULT,:civilite,:prenom,:nom)'); + $result = $req->execute(['civilite' => $civilite, + 'nom' => $nom, + 'prenom' => $prenom)); + if($result){return ['id' => $this->connexion->lastInsertId()];} + else{return false;} } - public function delete($idPatient){ - + public function delete($idMedecin){ + $req = $this->connexion->prepare('DELETE FROM Medecin WHERE Id = :id'); + return $req->execute(['id' => $idMedecin]); } public function search($nom,$prenom){ + $req = $this->connexion->prepare('SELECT * FROM Medecin WHERE Nom LIKE :nom AND Prenom LIKE :prenom'); + $req->execute(['nom' => $nom, + 'prenom' => $prenom]); + return StaticRepo::delNumeric($req->fetchAll()); } public function getPatients($idMedecin){ + $req = $this->connexion->prepare('SELECT Patient.* FROM Patient,Medecin + WHERE Medecin.Id = :id + AND Medecin.Id = Patient.MedecinTraitant'); + + $req->execute(['id' => $idMedecin]); + return StaticRepo::delNumeric($req->fetchAll()); } -} \ No newline at end of file +} diff --git a/repositories/repos/PatientRepo.php b/repositories/repos/PatientRepo.php index caa6dd4..71cb119 100644 --- a/repositories/repos/PatientRepo.php +++ b/repositories/repos/PatientRepo.php @@ -17,14 +17,14 @@ class PatientRepo public function getById($id){ $req = $this->connexion->prepare('SELECT * FROM Patient WHERE Id = :id'); $req->execute(['id' => $id]); - return $req->fetchAll(); + return StaticRepo::delNumeric( $req->fetch(), true ); } public function add($civilite,$prenom,$nom,$adresse,$ville,$codePostal,$dateNaissance,$lieuNaissance,$numSecu,$medecinTraitant = null){ $req = $this->connexion->prepare('INSERT INTO Patient VALUES (:civilite,:nom,:prenom,:adresse,:ville,:codePostal,:dateNaissance,:lieuNaissance,:numSecu,DEFAULT,:medecin)'); - $req->execute(['civilite' => $civilite, + $result = $req->execute(['civilite' => $civilite, 'nom' => $nom, 'prenom' => $prenom, 'adresse' => $adresse, @@ -34,19 +34,34 @@ class PatientRepo 'lieuNaissance' => $lieuNaissance, 'numSecu' => $numSecu, 'medecin' => $medecinTraitant ]); + if($result){return ['id' => $this->connexion->lastInsertId()];} + else{return false;} } public function delete($idPatient){ + $req = $this->connexion->prepare('DELETE FROM Patient WHERE Id = :id'); + return $req->execute(['id' => $idPatient]); + } - public function updateMedecinTraitant($idPatient,$IdMedecin){ + public function updateMedecinTraitant($idPatient,$idMedecin){ + + $req = $this->connexion->prepare('UPDATE Patient SET MedecinTraitant = :medecin WHERE Id = :id'); + return $req->execute['medecin' => $idMedecin, + 'id' => $idPatient]); } public function search($nom,$prenom){ + $req = $this->connexion->prepare('SELECT * FROM Patient WHERE Nom LIKE :nom AND Prenom LIKE :prenom'); + $req->execute(['nom' => $nom, + 'prenom' => $prenom]); + + return StaticRepo::delNumeric($req->fetchAll()); + } -} \ No newline at end of file +} diff --git a/src/Authentification.php b/src/Authentification.php index a81fd19..311c349 100755 --- a/src/Authentification.php +++ b/src/Authentification.php @@ -43,7 +43,7 @@ class Authentification{ $id = uniqid(); $_SESSION['id'] = $id; $_SESSION['token'] = sha1($_SERVER['HTTP_USER_AGENT'].$_SERVER['REMOTE_ADDR'].$id); - setcookie('UserId',$id,time()+10*60,'/'); + session_regenerate_id(); $_SESSION['user'] = $user; $_SESSION['role'] = $role; @@ -71,7 +71,7 @@ class Authentification{ foreach($_SESSION['role'] as $roleUser){ if(($strict and $roleUser == $role) or (!$strict and $roleUser<= $role)){ if($_SESSION['token'] == sha1($_SERVER['HTTP_USER_AGENT'].$_SERVER['REMOTE_ADDR'].$_SESSION['id'])){ - setcookie('UserId',$_COOKIE['UserId'],time()+10*60,'/'); + session_regenerate_id(); return true; }; } From e1a9530d5e71bbfb9dba4aa0e1495038d75be9d2 Mon Sep 17 00:00:00 2001 From: SeekDaSky Date: Thu, 3 Dec 2015 11:02:05 +0100 Subject: [PATCH 3/3] ajout de quelques fonction pour RDV --- repositories/repos/RDVRepo.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/repositories/repos/RDVRepo.php b/repositories/repos/RDVRepo.php index da8644d..9fa90a5 100644 --- a/repositories/repos/RDVRepo.php +++ b/repositories/repos/RDVRepo.php @@ -22,11 +22,13 @@ class RDVRepo } public function getByDate($date){ - + $date = date('o-m-d',$date); + $req = $this->connexion->prepare('SELECT * FROM RDV WHERE DATE(FROM_UNIXTIME(1449136444)) = :date'); } - public function delete($idPatient){ - + public function delete($idRDV){ + $req = $this->connexion->prepare('DELETE FROM RDV WHERE Id = :id'); + return $req->execute(['id' => $idRDV]); } public function add($timestamp,$duree,$idPatient,$idMedecin){ @@ -41,4 +43,4 @@ class RDVRepo } -} \ No newline at end of file +}