Merge branch 'master' of https://github.com/xdrm-brackets/projetphp
merge remote
This commit is contained in:
commit
4631e095d8
72
login.php
72
login.php
|
@ -1,72 +0,0 @@
|
||||||
<!DOCTYPE html>
|
|
||||||
|
|
||||||
<?php /* [0] VERIFICATION DE CONNECTION
|
|
||||||
=============================================*/
|
|
||||||
$postVariablesAreSet = isset($_POST['username']) && isset($_POST['mail']) && isset($_POST['password']) && isset($_POST['co']); // si les variables POST existent
|
|
||||||
$postVariablesTypeOk = $postVariablesAreSet && is_string($_POST['username']) && is_string($_POST['mail']) && is_string($_POST['password']) && is_string($_POST['co']); // si ce sont des string
|
|
||||||
$postVariablesNEmpty = $postVariablesTypeOk && strlen($_POST['username']) > 1 && strlen($_POST['mail']) > 1 && strlen($_POST['password']) > 1 && strlen($_POST['co']) > 1; // si au moins 1 caractère
|
|
||||||
$usernameCheck = $postVariablesNEmpty && preg_match("/^[\w -]{3,10}$/i", $_POST['username']); // utilisateur -> "alphanum_- " -> 3 à 10 caractères
|
|
||||||
$mailCheck = $usernameCheck && preg_match("/^[\w\.-]+@[\w\.-]+\.[a-z]{2,4}$/i", $_POST['mail']); // mail -> bon format
|
|
||||||
$passwordCheck = $mailCheck && preg_match("/^[\w -]{8,50}$/i", $_POST['password']); // password -> "alphanum_- " -> 8 à 50 caractères
|
|
||||||
$coCheck = $passwordCheck && $_POST['co'] == 'Me connecter';
|
|
||||||
|
|
||||||
if( $coCheck ){ // si toutes les valeurs sont correctes
|
|
||||||
|
|
||||||
$user = array(); // on définit l'utilisateur
|
|
||||||
$user['name'] = $_POST['username'];
|
|
||||||
$user['mail'] = $_POST['mail'];
|
|
||||||
$user['password'] = $_POST['password'];
|
|
||||||
$user['hash'] = sha1($_POST['password']);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// retourne VRAI si l'utilisateur est connecté
|
|
||||||
function connected($user){ return ($user != null); }
|
|
||||||
|
|
||||||
?>
|
|
||||||
|
|
||||||
<html>
|
|
||||||
<head>
|
|
||||||
<title>Tests php</title>
|
|
||||||
|
|
||||||
<meta charset='utf-8'/>
|
|
||||||
<meta name='description' value='Site de test'/>
|
|
||||||
<meta name='author' value='{xdrm} & SeekDaSky'/>
|
|
||||||
|
|
||||||
|
|
||||||
<link rel='stylesheet' href='login.css'/>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
|
|
||||||
|
|
||||||
<?php /* [1] AFFICHAGE DIFFÉRÉ SI CONNECTÉ
|
|
||||||
==============================================*/
|
|
||||||
|
|
||||||
echo "<form action='#auth' method='POST'>";
|
|
||||||
|
|
||||||
/* AFFICHAGE D'ERREURS */
|
|
||||||
if( $postVariablesAreSet ){ // si formulaire soumis
|
|
||||||
if( !$postVariablesNEmpty )
|
|
||||||
echo '<span class=error>Certains champs requis sont vides.</span>';
|
|
||||||
elseif( !$usernameCheck )
|
|
||||||
echo '<span class=error>Nom d\'utilisateur incorrect. (3 car. min)</span>';
|
|
||||||
elseif( !$mailCheck )
|
|
||||||
echo '<span class=error>Adresse mail incorrecte.</span>';
|
|
||||||
elseif( !$passwordCheck )
|
|
||||||
echo '<span class=error>Mot de passe incorrect. (8 car. min)</span>';
|
|
||||||
elseif( connected($user) )
|
|
||||||
echo '<span class=success>Vous êtes connectés.</span>';
|
|
||||||
}
|
|
||||||
|
|
||||||
echo "<input type='text' name='username' placeholder='username' " .( (connected($user)) ? "value='".$user['name']."'" : '' ).">";
|
|
||||||
echo "<input type='mail' name='mail' placeholder='mail' " .( (connected($user)) ? "value='".$user['mail']."'" : '' ).">";
|
|
||||||
echo "<input type='password' name='password' placeholder='password' ".( (connected($user)) ? "value='".$user['password']."'" : '' ).">";
|
|
||||||
echo "<input type='submit' name='co' value='Me connecter'>";
|
|
||||||
echo "</form>";
|
|
||||||
|
|
||||||
?>
|
|
||||||
|
|
||||||
|
|
||||||
</body>
|
|
||||||
</html>
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"host": "localhost",
|
"host": "localhost",
|
||||||
"login": "php",
|
"login": "login",
|
||||||
"password": "Qt358nUdyeTxLDM8",
|
"password": "password",
|
||||||
"database": "projetphp"
|
"database": "DBName"
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,7 +25,7 @@ class MedecinRepo
|
||||||
$req = $this->connexion->prepare('INSERT INTO Medecin VALUES (DEFAULT,:civilite,:prenom,:nom)');
|
$req = $this->connexion->prepare('INSERT INTO Medecin VALUES (DEFAULT,:civilite,:prenom,:nom)');
|
||||||
$result = $req->execute(['civilite' => $civilite,
|
$result = $req->execute(['civilite' => $civilite,
|
||||||
'nom' => $nom,
|
'nom' => $nom,
|
||||||
'prenom' => $prenom));
|
'prenom' => $prenom]);
|
||||||
if($result){return ['id' => $this->connexion->lastInsertId()];}
|
if($result){return ['id' => $this->connexion->lastInsertId()];}
|
||||||
else{return false;}
|
else{return false;}
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,13 +21,17 @@ class PatientRepo
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function add($civilite,$prenom,$nom,$adresse,$ville,$codePostal,$dateNaissance,$lieuNaissance,$numSecu,$medecinTraitant = null){
|
public function add($civilite,$prenom,$nom,$adresse,$adresse2,$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)');
|
$dateNaissance = strtotime($dateNaissance);
|
||||||
|
$dateNaissance = Date('o-m-d',$dateNaissance);
|
||||||
|
|
||||||
|
$req = $this->connexion->prepare('INSERT INTO Patient VALUES (:civilite,:nom,:prenom,:adresse,:adresse2,:ville,:codePostal,:dateNaissance,:lieuNaissance,:numSecu,DEFAULT,:medecin)');
|
||||||
$result = $req->execute(['civilite' => $civilite,
|
$result = $req->execute(['civilite' => $civilite,
|
||||||
'nom' => $nom,
|
'nom' => $nom,
|
||||||
'prenom' => $prenom,
|
'prenom' => $prenom,
|
||||||
'adresse' => $adresse,
|
'adresse' => $adresse,
|
||||||
|
'adresse2' => $adresse2,
|
||||||
'ville' => $ville,
|
'ville' => $ville,
|
||||||
'codePostal' => $codePostal,
|
'codePostal' => $codePostal,
|
||||||
'dateNaissance' => $dateNaissance,
|
'dateNaissance' => $dateNaissance,
|
||||||
|
@ -49,7 +53,7 @@ class PatientRepo
|
||||||
public function updateMedecinTraitant($idPatient,$idMedecin){
|
public function updateMedecinTraitant($idPatient,$idMedecin){
|
||||||
|
|
||||||
$req = $this->connexion->prepare('UPDATE Patient SET MedecinTraitant = :medecin WHERE Id = :id');
|
$req = $this->connexion->prepare('UPDATE Patient SET MedecinTraitant = :medecin WHERE Id = :id');
|
||||||
return $req->execute['medecin' => $idMedecin,
|
return $req->execute(['medecin' => $idMedecin,
|
||||||
'id' => $idPatient]);
|
'id' => $idPatient]);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,8 +22,11 @@ class RDVRepo
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getByDate($date){
|
public function getByDate($date){
|
||||||
$date = date('o-m-d',$date);
|
$date = strtotime($date);
|
||||||
$req = $this->connexion->prepare('SELECT * FROM RDV WHERE DATE(FROM_UNIXTIME(1449136444)) = :date');
|
$date = date('o-m-d',$date);
|
||||||
|
$req = $this->connexion->prepare('SELECT * FROM RDV WHERE DATE(FROM_UNIXTIME(1449136444)) = :date');
|
||||||
|
$req->execute(['date' => $date]);
|
||||||
|
return StaticRepo::delNumeric($req->fetchAll());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function delete($idRDV){
|
public function delete($idRDV){
|
||||||
|
|
|
@ -0,0 +1,28 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Created by PhpStorm.
|
||||||
|
* User: seekdasky
|
||||||
|
* Date: 03/12/15
|
||||||
|
* Time: 11:52
|
||||||
|
*/
|
||||||
|
|
||||||
|
ini_set('display_errors',1);
|
||||||
|
ini_set('display_startup_errors',1);
|
||||||
|
error_reporting(-1);
|
||||||
|
|
||||||
|
require_once('autoloader.php');
|
||||||
|
|
||||||
|
$jsonP = json_decode(file_get_contents('Docs/PatientExemple.json'),true);
|
||||||
|
$jsonM = json_decode(file_get_contents('Docs/MedecinExemple.json'),true);
|
||||||
|
|
||||||
|
var_dump(StaticRepo::testConnexion());
|
||||||
|
$repo = new PatientRepo();
|
||||||
|
$repoM = new MedecinRepo();
|
||||||
|
|
||||||
|
foreach($jsonM as $patient) {
|
||||||
|
$repoM->add($patient['Civilite'], $patient['Prenom'], $patient['Nom']);
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach($jsonP as $patient){
|
||||||
|
$repo->add($patient['Civilite'],$patient['Prenom'],$patient['Nom'],$patient['Adresse'],NULL,$patient['Ville'],$patient['CodePostal'],$patient['DateNaissance'],$patient['LieuNaissance'],$patient['NumSecuriteSociale'],$patient['MedecinTraitant']);
|
||||||
|
}
|
Loading…
Reference in New Issue