Test
continuous-integration/drone/push Build is passing Details

ServeurDeTest
Noé GARNIER 2 years ago
parent 62c0950c54
commit 43821baf34

@ -17,33 +17,33 @@
// } // }
// } // }
// class Connection extends SQLite3 class Connection extends SQLite3
// { {
// private $stmt; private $stmt;
// private $result; private $result;
// function __construct($dsn) function __construct($dsn)
// { {
// $this->open($dsn); $this->open($dsn);
// $this->enableExceptions(true); $this->enableExceptions(true);
// } }
// public function executeQuery(string $query, array $parameters = []) :bool {
// $this->stmt = parent::prepare($query);
// foreach ($parameters as $name => $value) {
// $this->stmt->bindValue($name, $value[0], $value[1]);
// }
// $this->result=$this->stmt->execute();
// return $this->result;
// }
// public function getResults(): array { public function executeQuery(string $query, array $parameters = []) :bool {
// return $this->result->fetchArray(); $this->stmt = parent::prepare($query);
// } foreach ($parameters as $name => $value) {
// } $this->stmt->bindValue($name, $value[0], $value[1]);
}
$this->result=$this->stmt->execute();
return $this->result;
}
class Connection extends SQLite3{ public function getResults(): array {
function __construct() return $this->result->fetchArray();
{
$this->open("./Model/scripted.db");
} }
} }
// class Connection extends SQLite3{
// function __construct()
// {
// $this->open("./Model/scripted.db");
// }
// }

@ -8,19 +8,19 @@ class UserController
try{ try{
echo "UserController"; echo "UserController";
global $dsn, $rep, $vues, $error; global $dsn, $rep, $vues, $error;
$this->con=new Connection (); $this->con=new Connection ($dsn);
echo "USconection"; echo "USconection";
$action=$_REQUEST['action']; $action=$_REQUEST['action'];
switch($action) { switch($action) {
case NULL: case NULL:
$this->goToHome(); $this->goToHome();
break; break;
// case "signUp": case "signUp":
// $this->signUp(); $this->signUp();
// break; break;
// case "login": case "login":
// $this->login(); $this->login();
// break; break;
case "goToPresentation": case "goToPresentation":
$this->goToPresentation(); $this->goToPresentation();
break; break;
@ -48,72 +48,72 @@ class UserController
} }
} }
// private function signUp() { private function signUp() {
// global $rep, $vues, $sel, $error; global $rep, $vues, $sel, $error;
// try { try {
// $gateway = new UtilisateurGateway($this->con); $gateway = new UtilisateurGateway($this->con);
// $validation = new Validation(); $validation = new Validation();
// if (! $validation->ValidateEmail($_REQUEST['email'])) { if (! $validation->ValidateEmail($_REQUEST['email'])) {
// $error = "Email invalides."; $error = "Email invalides.";
// throw (new Exception("Email non valide")); throw (new Exception("Email non valide"));
// } }
// if(! $validation->ValidateUsername($_REQUEST['username'])){ if(! $validation->ValidateUsername($_REQUEST['username'])){
// $error = "Nom d'utilisateur invalides. Il ne doit pas contenir de caractère spéciaux."; $error = "Nom d'utilisateur invalides. Il ne doit pas contenir de caractère spéciaux.";
// throw(new Exception("Pseudo non valide")); throw(new Exception("Pseudo non valide"));
// } }
// if(! $validation->ValidatePassword($_REQUEST['password'])){ if(! $validation->ValidatePassword($_REQUEST['password'])){
// $error = "Mots de passe invalides. Il ne doit pas dépasser 100 caractères."; $error = "Mots de passe invalides. Il ne doit pas dépasser 100 caractères.";
// throw(new Exception("Mot de passe non valide")); throw(new Exception("Mot de passe non valide"));
// } }
// $j = $gateway->getUtilisateurByEmail($_REQUEST['email']); $j = $gateway->getUtilisateurByEmail($_REQUEST['email']);
// if ($j != null) { if ($j != null) {
// $error = "Email déjà utilisé."; $error = "Email déjà utilisé.";
// throw (new Exception("Email déjà utilisé")); throw (new Exception("Email déjà utilisé"));
// } }
// $password = password_hash($_REQUEST['password'], PASSWORD_DEFAULT); $password = password_hash($_REQUEST['password'], PASSWORD_DEFAULT);
// $estAdmin = $gateway->getEstAdminByEmail($_REQUEST['email']); $estAdmin = $gateway->getEstAdminByEmail($_REQUEST['email']);
// $Utilisateur = new Utilisateur($_REQUEST['email'], $_REQUEST['username'], $password, $estAdmin); $Utilisateur = new Utilisateur($_REQUEST['email'], $_REQUEST['username'], $password, $estAdmin);
// $gateway->insert($Utilisateur); $gateway->insert($Utilisateur);
// $_SESSION['connected'] = 'true'; $_SESSION['connected'] = 'true';
// $_SESSION['role'] = 'utilisateur'; $_SESSION['role'] = 'utilisateur';
// require ($rep.$vues['main']); require ($rep.$vues['main']);
// }catch (PDOException $e) }catch (PDOException $e)
// { {
// $error = "Erreur de connexion à la base de données."; $error = "Erreur de connexion à la base de données.";
// require ($rep.$vues['erreur']); require ($rep.$vues['erreur']);
// } }
// catch (Exception $e){ catch (Exception $e){
// require($rep.$vues['erreur']); require($rep.$vues['erreur']);
// } }
// } }
// private function login(){ private function login(){
// global $rep, $vues, $sel, $error; global $rep, $vues, $sel, $error;
// try { try {
// $gateway = new UtilisateurGateway($this->con); $gateway = new UtilisateurGateway($this->con);
// $Utilisateur = $gateway->getUtilisateurByEmail($_REQUEST['email']); $Utilisateur = $gateway->getUtilisateurByEmail($_REQUEST['email']);
// if ($Utilisateur->getEmail() == null){ if ($Utilisateur->getEmail() == null){
// $error = "Utilisateur non trouvé."; $error = "Utilisateur non trouvé.";
// throw new Exception("Utilisateur introuvable"); throw new Exception("Utilisateur introuvable");
// } }
// $mdp = $gateway->getMdpByEmail($_REQUEST['email']); $mdp = $gateway->getMdpByEmail($_REQUEST['email']);
// if (password_verify($mdp, $_REQUEST['password'])){ if (password_verify($mdp, $_REQUEST['password'])){
// $error = "Mot de passe incorrect."; $error = "Mot de passe incorrect.";
// throw new Exception("Mot de passe invalide"); throw new Exception("Mot de passe invalide");
// } }
// $estAdmin =$gateway->getEstAdminByEmail($_REQUEST['email']); $estAdmin =$gateway->getEstAdminByEmail($_REQUEST['email']);
// if ($estAdmin == true) { if ($estAdmin == true) {
// $_SESSION['role'] = "admin"; $_SESSION['role'] = "admin";
// } }
// else{ else{
// $_SESSION['role'] = "utilisateur"; $_SESSION['role'] = "utilisateur";
// } }
// $_SESSION['connected'] = 'true'; $_SESSION['connected'] = 'true';
// require ($rep.$vues['main']); require ($rep.$vues['main']);
// }catch (Exception $e){ }catch (Exception $e){
// require($rep.$vues['erreur']); require($rep.$vues['erreur']);
// } }
// } }
private function goToPresentation() { private function goToPresentation() {
global $rep, $vues, $error; global $rep, $vues, $error;

@ -19,81 +19,81 @@ class UtilisateurGateway
$this->con = $con; $this->con = $con;
} }
// public function insert(Utilisateur $utilisateur) : void{ public function insert(Utilisateur $utilisateur) : void{
// $query = "INSERT INTO Utilisateur VALUE (:email,:pseudo,:mdp,:estAdmin)"; $query = "INSERT INTO Utilisateur VALUE (:email,:pseudo,:mdp,:estAdmin)";
// $this->con->executeQuery($query, array( $this->con->executeQuery($query, array(
// ':email' => array($utilisateur->getEmail(),PDO::PARAM_STR), ':email' => array($utilisateur->getEmail(),PDO::PARAM_STR),
// ':pseudo' => array($utilisateur->getPseudo(),PDO::PARAM_STR), ':pseudo' => array($utilisateur->getPseudo(),PDO::PARAM_STR),
// ':mdp' => array($utilisateur->getMdp(),PDO::PARAM_STR), ':mdp' => array($utilisateur->getMdp(),PDO::PARAM_STR),
// ':estAdmin' => array($utilisateur->getEstAdmin(),PDO::PARAM_BOOL))); ':estAdmin' => array($utilisateur->getEstAdmin(),PDO::PARAM_BOOL)));
// } }
// public function delete(string $email) : void{ public function delete(string $email) : void{
// $query = "DELETE FROM utilisateur WHERE email=:email"; $query = "DELETE FROM utilisateur WHERE email=:email";
// $this->con->executeQuery($query, array( $this->con->executeQuery($query, array(
// ':email' => array($email ,PDO::PARAM_STR) ':email' => array($email ,PDO::PARAM_STR)
// )); ));
// } }
// public function getUtilisateurByEmail(string $email) : Utilisateur{ public function getUtilisateurByEmail(string $email) : Utilisateur{
// global $error; global $error;
// $query = "SELECT * FROM Utilisateur WHERE email=:email"; $query = "SELECT * FROM Utilisateur WHERE email=:email";
// $this->con->executeQuery($query, array( $this->con->executeQuery($query, array(
// ':email' => array($email,PDO::PARAM_STR) ':email' => array($email,PDO::PARAM_STR)
// )); ));
// $results=$this->con->getResults(); $results=$this->con->getResults();
// foreach ($results as $row) { foreach ($results as $row) {
// $email=$row['email']; $email=$row['email'];
// $pseudo=$row['pseudo']; $pseudo=$row['pseudo'];
// $mdp=$row['mdp']; $mdp=$row['mdp'];
// $estAdmin=$row['estAdmin']; $estAdmin=$row['estAdmin'];
// } }
// if ($results == null){ if ($results == null){
// return new Utilisateur("null", "null", "null", false); return new Utilisateur("null", "null", "null", false);
// } }
// return new Utilisateur($email, $pseudo, $mdp, $estAdmin); return new Utilisateur($email, $pseudo, $mdp, $estAdmin);
// } }
// public function getMdpByEmail(string $email) : string{ public function getMdpByEmail(string $email) : string{
// global $error; global $error;
// $query = "SELECT mdp FROM Utilisateur WHERE email=:email"; $query = "SELECT mdp FROM Utilisateur WHERE email=:email";
// $this->con->executeQuery($query, array( $this->con->executeQuery($query, array(
// ':email' => array($email,PDO::PARAM_STR) ':email' => array($email,PDO::PARAM_STR)
// )); ));
// $results=$this->con->getResults(); $results=$this->con->getResults();
// foreach ($results as $row) { foreach ($results as $row) {
// $mdp=$row['mdp']; $mdp=$row['mdp'];
// } }
// if ($results == null){ if ($results == null){
// $error = "Mot de passe non trouvé."; $error = "Mot de passe non trouvé.";
// throw new Exception("Mots de passe Incorrect"); throw new Exception("Mots de passe Incorrect");
// } }
// return $mdp; return $mdp;
// } }
// public function getEstAdminByEmail(string $email) : bool{ public function getEstAdminByEmail(string $email) : bool{
// global $error; global $error;
// $query = "SELECT estAdmin FROM Utilisateur WHERE email=:email"; $query = "SELECT estAdmin FROM Utilisateur WHERE email=:email";
// $this->con->executeQuery($query, array( $this->con->executeQuery($query, array(
// ':email' => array($email,PDO::PARAM_STR) ':email' => array($email,PDO::PARAM_STR)
// )); ));
// $results=$this->con->getResults(); $results=$this->con->getResults();
// foreach ($results as $row) { foreach ($results as $row) {
// $estAdmin=$row['estAdmin']; $estAdmin=$row['estAdmin'];
// } }
// return $estAdmin; return $estAdmin;
// } }
// public function showAll() : void{ public function showAll() : void{
// $query = "SELECT * FROM Utilisateur"; $query = "SELECT * FROM Utilisateur";
// $this->con->executeQuery($query); $this->con->executeQuery($query);
// $results=$this->con->getResults(); $results=$this->con->getResults();
// foreach ($results as $row) { foreach ($results as $row) {
// echo $row['email'] . '</br>'; echo $row['email'] . '</br>';
// echo $row['pseudo'] . '</br>'; echo $row['pseudo'] . '</br>';
// echo $row['mdp'] . '</br>'; echo $row['mdp'] . '</br>';
// echo $row['estAdmin'] . '</br>'; echo $row['estAdmin'] . '</br>';
// } }
// } }
} }

@ -18,7 +18,7 @@ Autoload::charger();
// } // }
echo "test"; echo "test";
$db = new Connection(); $db = new Connection($dsn);
echo "test2"; echo "test2";
// $control = new FrontController(); // $control = new FrontController();

Loading…
Cancel
Save