diff --git a/.idea/deployment.xml b/.idea/deployment.xml new file mode 100644 index 00000000..5cb703ee --- /dev/null +++ b/.idea/deployment.xml @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/inspectionProfiles/Project_Default.xml b/.idea/inspectionProfiles/Project_Default.xml new file mode 100644 index 00000000..be4b2867 --- /dev/null +++ b/.idea/inspectionProfiles/Project_Default.xml @@ -0,0 +1,7 @@ + + + + \ No newline at end of file diff --git a/.idea/php.xml b/.idea/php.xml index 0e09af40..97a38d70 100644 --- a/.idea/php.xml +++ b/.idea/php.xml @@ -1,6 +1,6 @@ - + \ No newline at end of file diff --git a/Bd/bd.sql b/Bd/bd.sql index 2db04763..2c961fa7 100644 --- a/Bd/bd.sql +++ b/Bd/bd.sql @@ -7,7 +7,7 @@ mdp varchar(50) CREATE TABLE Enigme( idEnigme char(5) PRIMARY KEY, admin varchar(50) REFERENCES Admin(email), -enoncé varchar(250) NOT NULL, +enonce varchar(250) NOT NULL, aide varchar(250), rappel varchar(250), solution varchar(250) NOT NULL, @@ -22,8 +22,16 @@ pseudo varchar(50), mdp varchar(50) ); -CREATE TABLE Game( -idGame char(5) NOT NULL, +CREATE TABLE Partie( +idPartie char(5) NOT NULL, +joueur varchar(50) REFERENCES Joueur(email), +enigme char(5) REFERENCES Enigme(idEnigme), +points numeric CHECK (points >0), +PRIMARY KEY(idGame, joueur, enigme) +); + +CREATE TABLE DetailPartie( +idPartie char(5) NOT NULL, joueur varchar(50) REFERENCES Joueur(email), enigme char(5) REFERENCES Enigme(idEnigme), points numeric CHECK (points >0), diff --git a/WEB/Controller/Connection.php b/WEB/Config/Connection.php similarity index 100% rename from WEB/Controller/Connection.php rename to WEB/Config/Connection.php diff --git a/WEB/Config/Validation.php b/WEB/Config/Validation.php new file mode 100644 index 00000000..2fe55341 --- /dev/null +++ b/WEB/Config/Validation.php @@ -0,0 +1,32 @@ +con=$con; + session_start(); + try{ + $action=$_REQUEST['action']; + switch($action) { + case NULL: + //require ('../View/src/pages/Main.html'); + header('Location: http://londres.uca.local/~nogarnier1/Scripted/WEB/View/src/pages/Main.html'); + break; + case "login": + $this->login(); + break; + } + } catch (PDOException $e) + { + //si erreur BD, pas le cas ici + $dataVueEreur[] = "Erreur inattendue!!! "; + //require(__DIR__.'/../vues/erreur.php'); // ajout du code de la vue ici + } + catch (Exception $e2) + { + $dataVueEreur[] = "Erreur inattendue!!! "; + //require ($rep.$vues['erreur']); + } + } + + private function login() { + $gateway=new JoueurGateway($this->con); + $joueur=new Joueur($_REQUEST['email'], $_REQUEST['username'], $_REQUEST['password']); + $gateway->insert($joueur); + $gateway->showAll(); + } +} \ No newline at end of file diff --git a/WEB/Controller/DetailPartieGateway.php b/WEB/Controller/DetailPartieGateway.php new file mode 100644 index 00000000..2e2f8102 --- /dev/null +++ b/WEB/Controller/DetailPartieGateway.php @@ -0,0 +1,52 @@ +con = $con; + } + + /** + * @param Connection $con + */ + public function setCon(Connection $con): void + { + $this->con = $con; + } + + public function insert(DetailPartie $detailPartie) + { + $query="INSERT INTO DetailPartie VALUES (:idDetailPartie,:joueur,:partie,:enigme,:pointsObtenus,:classement)"; + $this->con->executeQuery($query,array( + 'idDetailPartie' => array($detailPartie->getIdDetailPartie(),PDO::PARAM_STR), + 'joueur' => array($detailPartie->getJoueur(),PDO::PARAM_STR), + 'partie' => array($detailPartie->getPartie(),PDO::PARAM_STR), + 'enigme' => array($detailPartie->getEnigme(),PDO::PARAM_STR), + 'pointsObtenus' => array($detailPartie->getPointsObtenus(),PDO::PARAM_INT), + 'classement' => array($detailPartie->getClassement(),PDO::PARAM_INT) + )); + } + public function delete(string $partie){ + $query="DELETE * FROM DetailPartie WHERE partie=:partie"; + $this->con->executeQuery($query,array( + 'partie' => array($partie,PDO::PARAM_STR) + )); + } + public function showAll(){ + $query="SELECT * FROM DetailPartie"; + $this->con->executeQuery($query); + $results=$this->con->getResults(); + foreach($results as $row) + { + $row['idDetailPartie']; + } + } + + +} \ No newline at end of file diff --git a/WEB/Controller/EnigmeGateway.php b/WEB/Controller/EnigmeGateway.php new file mode 100644 index 00000000..03a33c31 --- /dev/null +++ b/WEB/Controller/EnigmeGateway.php @@ -0,0 +1,73 @@ +con = $con; + } + + /** + * @param Connection $con + */ + public function setCon(Connection $con): void + { + $this->con = $con; + } + + public function insert(Enigme $enigme) + { + $query = "INSERT INTO Enigme VALUES (:idEnigme,:admin,:enonce,:aide,:rappel,:solution,:test,:tempsDeResolution)"; + $this->con->executeQuery($query, array( + ':idEnigme' => array($enigme->getIdEnigme(), PDO::PARAM_STR), + ':admin' => array($enigme->getAdmin(), PDO::PARAM_STR), + ':enonce' => array($enigme->getEnonce(), PDO::PARAM_STR), + ':aide' => array($enigme->getAide(), PDO::PARAM_STR), + ':rappel' => array($enigme->getRappel(), PDO::PARAM_STR), + ':solution' => array($enigme->getSolution(), PDO::PARAM_STR), + ':test' => array($enigme->getTest(), PDO::PARAM_STR), + ':tempsDeResolution' => array($enigme->getTempsDeResolution(), PDO::PARAM_INT) + )); + } + + public function delete(string $idEnigme) + { + $query= "DELETE FROM Enigme WHERE idEnigme=:idEnigme"; + $this->con->executequery($query, array( + ':idEnigme' => array($idEnigme,PDO::PARAM_STR) + )); + } + + public function findById(string $idEnigme) + { + $query="SELECT * FROM Enigme WHERE idEnigme =:idEnigme"; + $this->con->executequery($query,array( + ':idEnigme' => array($idEnigme,PDO::PARAM_STR) + )); + } + + public function showAll(): void + { + $query = "SELECT * FROM Enigme"; + $this->con->executeQuery($query); + $results = $this->con->getResults(); + foreach ($results as $row) { + echo $row['idEnigme'] . '
'; + echo $row['admin'] . '
'; + echo $row['enonce'] . '
'; + echo $row['aide'] . '
'; + echo $row['rappel'] . '
'; + echo $row['solution'] . '
'; + echo $row['test'] . '
'; + } + } +} +?> \ No newline at end of file diff --git a/WEB/Controller/JoueurGateway.php b/WEB/Controller/JoueurGateway.php new file mode 100644 index 00000000..4d49a6c5 --- /dev/null +++ b/WEB/Controller/JoueurGateway.php @@ -0,0 +1,51 @@ +con = $con; + } + + /** + * @param Connection $con + */ + public function setCon(Connection $con): void + { + $this->con = $con; + } + + public function insert(Joueur $joueur) : void{ + $query = "INSERT INTO Joueur VALUE (:email,:pseudo,:mdp)"; + $this->con->executeQuery($query, array( + ':email' => array($joueur->getEmail(),PDO::PARAM_STR), + ':pseudo' => array($joueur->getPseudo(),PDO::PARAM_STR), + ':mdp' => array($joueur->getMdp(),PDO::PARAM_STR))); + } + + public function delete(string $email) : void{ + $query = "DELETE FROM Joueur WHERE email=:email"; + $this->con->executeQuery($query, array( + ':email' => array($email,PDO::PARAM_STR) + )); + } + + public function showAll() : void{ + $query = "SELECT * FROM Joueur"; + $this->con->executeQuery($query); + $results=$this->con->getResults(); + foreach ($results as $row) { + echo $row['email'] . '
'; + echo $row['pseudo'] . '
'; + echo $row['mdp'] . '
'; + } + + } +} \ No newline at end of file diff --git a/WEB/Controller/PartieGateway.php b/WEB/Controller/PartieGateway.php new file mode 100644 index 00000000..1b0ccaf8 --- /dev/null +++ b/WEB/Controller/PartieGateway.php @@ -0,0 +1,33 @@ +con = $con; + } + public function insert(Partie $partie){ + $query= "INSERT INTO Game VALUES (:idPartie)"; + $this->con->executeQuery($query, array(':idPartie' => array($partie->getIdPartie(), PDO::PARAM_STR))); + } + public function delete(string $idPartie){ + $query= "DELETE FROM Game WHERE idGame = :idPartie"; + $this->con->executeQuery($query, array(':idPartie' => array($idPartie, PDO::PARAM_STR))); + } + public function showAll() : void{ + $query= "SELECT * FROM Partie"; + $this->con->executeQuery($query); + $results=$this->con->getResults(); + foreach ($results as $row) { + echo $row['idPartie'] . '
'; + } + } +} \ No newline at end of file diff --git a/WEB/Controller/Traitement.php b/WEB/Controller/Traitement.php new file mode 100644 index 00000000..1e7cf661 --- /dev/null +++ b/WEB/Controller/Traitement.php @@ -0,0 +1,12 @@ + + + + + \ No newline at end of file diff --git a/WEB/Controller/Validation.php b/WEB/Controller/Validation.php deleted file mode 100644 index fb682eab..00000000 --- a/WEB/Controller/Validation.php +++ /dev/null @@ -1,6 +0,0 @@ - - - setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); } - - 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]); } - return $this->stmt->execute(); } - public function getResults(): array { - return $this->stmt->fetchall(); - } - } - $email = $_POST['email']; - $nom = $_POST['username']; - $mdp = $_POST['password']; - - $dsn = 'mysql:host=localhost;dbname=dbnogarnier1'; - $user = 'nogarnier1'; - $password = 'achanger'; - - $con=new Connection($dsn, $user, $password); - $query = "INSERT INTO Joueur VALUE (:email,:nom,:mdp)"; - $con->executeQuery($query, array( - ':email' => array($email,PDO::PARAM_STR), - ':nom' => array($nom,PDO::PARAM_STR), - ':mdp' => array($mdp,PDO::PARAM_STR))); - - $db = new PDO($dsn, $user, $password); - $query= 'SELECT * FROM Joueur'; - $stmt=$db->prepare($query); - $stmt->execute(); - $results=$stmt->fetchall(); - Foreach ($results as $row) - echo $row['email'].'
'; - ?> - - \ No newline at end of file diff --git a/WEB/Model/DetailPartie.php b/WEB/Model/DetailPartie.php index 9d8eb6d6..b80095cd 100644 --- a/WEB/Model/DetailPartie.php +++ b/WEB/Model/DetailPartie.php @@ -6,18 +6,18 @@ class DetailPartie private string $joueur; private string $partie; private string $enigme; - private string $pointsObtenus; - private string $classement; + private int $pointsObtenus; + private int $classement; /** * @param string $idDetailPartie * @param string $joueur * @param string $partie * @param string $enigme - * @param string $pointsObtenus - * @param string $classement + * @param int $pointsObtenus + * @param int $classement */ - public function __construct(string $idDetailPartie, string $joueur, string $partie, string $enigme, string $pointsObtenus, string $classement) + public function __construct(string $idDetailPartie, string $joueur, string $partie, string $enigme, int $pointsObtenus, int $classement) { $this->idDetailPartie = $idDetailPartie; $this->joueur = $joueur; @@ -92,33 +92,33 @@ class DetailPartie } /** - * @return string + * @return int */ - public function getPointsObtenus(): string + public function getPointsObtenus(): int { return $this->pointsObtenus; } /** - * @param string $pointsObtenus + * @param int $pointsObtenus */ - public function setPointsObtenus(string $pointsObtenus): void + public function setPointsObtenus(int $pointsObtenus): void { $this->pointsObtenus = $pointsObtenus; } /** - * @return string + * @return int */ - public function getClassement(): string + public function getClassement(): int { return $this->classement; } /** - * @param string $classement + * @param int $classement */ - public function setClassement(string $classement): void + public function setClassement(int $classement): void { $this->classement = $classement; } diff --git a/WEB/Model/Joueur.php b/WEB/Model/Joueur.php index 44c2ad8c..16635cb1 100644 --- a/WEB/Model/Joueur.php +++ b/WEB/Model/Joueur.php @@ -2,5 +2,68 @@ class Joueur { + private string $email; + private string $pseudo; + private string $mdp; + + /** + * @param string $email + * @param string $pseudo + * @param string $mdp + */ + public function __construct(string $email, string $pseudo, string $mdp) + { + $this->email = $email; + $this->pseudo = $pseudo; + $this->mdp = $mdp; + } + + /** + * @return string + */ + public function getEmail(): string + { + return $this->email; + } + + /** + * @param string $email + */ + public function setEmail(string $email): void + { + $this->email = $email; + } + + /** + * @return string + */ + public function getPseudo(): string + { + return $this->pseudo; + } + + /** + * @param string $pseudo + */ + public function setPseudo(string $pseudo): void + { + $this->pseudo = $pseudo; + } + + /** + * @return string + */ + public function getMdp(): string + { + return $this->mdp; + } + + /** + * @param string $mdp + */ + public function setMdp(string $mdp): void + { + $this->mdp = $mdp; + } } \ No newline at end of file diff --git a/WEB/View/src/pages/LogSign/Login.php b/WEB/View/src/pages/LogSign/Login.php index 0f53216c..f8c053bd 100644 --- a/WEB/View/src/pages/LogSign/Login.php +++ b/WEB/View/src/pages/LogSign/Login.php @@ -9,17 +9,13 @@ Login -< +

Sign up

-
-
- - -
+
@@ -36,6 +32,13 @@ Submit + + + + + + Sign up +
diff --git a/WEB/View/src/pages/LogSign/SignUp.html b/WEB/View/src/pages/LogSign/SignUp.html deleted file mode 100644 index 93d1cadb..00000000 --- a/WEB/View/src/pages/LogSign/SignUp.html +++ /dev/null @@ -1,45 +0,0 @@ - - - - - - - - - - Login - - -
- -
- - \ No newline at end of file diff --git a/WEB/View/src/pages/LogSign/SignUp.php b/WEB/View/src/pages/LogSign/SignUp.php new file mode 100644 index 00000000..beb22719 --- /dev/null +++ b/WEB/View/src/pages/LogSign/SignUp.php @@ -0,0 +1,51 @@ + + + + + + + + + + Login + + +
+ +
+ + \ No newline at end of file