diff --git a/WEB/Config/Connection.php b/WEB/Config/Connection.php index d8ad3faf..be9b541f 100644 --- a/WEB/Config/Connection.php +++ b/WEB/Config/Connection.php @@ -45,12 +45,16 @@ class Connection extends SQLite3 public function getResults(): array { - $tmp = $this->result->fetchArray(SQLITE3_ASSOC); - if ($tmp == false) { - return array(); - } else { - return $tmp; + $resultArray = array(); + $multiArray = array(); + while($resultArray != false){ + $resultArray = $this->result->fetchArray(SQLITE3_ASSOC); //read next row + array_push($multiArray, $resultArray); //insert all rows to $multiArray } + if ($multiArray == NULL) + return array(); + else + return $multiArray; } } diff --git a/WEB/Controller/EnigmeGateway.php b/WEB/Controller/EnigmeGateway.php index bd13b6e0..8379835d 100644 --- a/WEB/Controller/EnigmeGateway.php +++ b/WEB/Controller/EnigmeGateway.php @@ -51,6 +51,19 @@ class EnigmeGateway )); } + public function findMultiEnigma() : array + { + $query = "SELECT * FROM Enigme + WHERE points IS NOT NULL OR points != 0"; + $this->con->executeQuery($query); + $results = $this->con->getResults(); + return $results; + } + + public function findSoloEnigma(){ + + } + public function findById(string $idEnigme) : array { $query="SELECT * FROM Enigme WHERE idEnigme =:idEnigme"; diff --git a/WEB/Controller/UtilisateurGateway.php b/WEB/Controller/UtilisateurGateway.php index 954bc06b..136ebc06 100644 --- a/WEB/Controller/UtilisateurGateway.php +++ b/WEB/Controller/UtilisateurGateway.php @@ -51,10 +51,13 @@ class UtilisateurGateway if ($results == null){ return new Utilisateur("null", "null", "null", false); } - $email=$results['email']; - $pseudo=$results['pseudo']; - $mdp=$results['mdp']; - $estAdmin=$results['estAdmin']; + foreach($results as $row) + { + $email = $row['email']; + $pseudo=$row['pseudo']; + $mdp = $row['mdp']; + $estAdmin = $row['estAdmin']; + } return new Utilisateur($email, $pseudo, $mdp, $estAdmin); } diff --git a/WEB/Model/Model.php b/WEB/Model/Model.php index d0712ad9..29c1d764 100644 --- a/WEB/Model/Model.php +++ b/WEB/Model/Model.php @@ -148,7 +148,7 @@ class Model require($rep . $vues['erreur']); } } - + public function logout() { session_unset(); @@ -156,4 +156,34 @@ class Model $_SESSION = null; $this->goToHome(); } + public function addEnigme() + { + global $rep, $vues, $error; + try{ + $solo = $_REQUEST['solo']; + if($solo) + $enigme = new Enigme($_REQUEST['enonce'],$_REQUEST['aide'],$_REQUEST['rappel'],$_REQUEST['solution'],$_REQUEST['test'],0,0); + else + $enigme = new Enigme($_REQUEST['enonce'],$_REQUEST['aide'],$_REQUEST['rappel'],$_REQUEST['solution'],$_REQUEST['test'],$_REQUEST['tempsDeResolution'],$_REQUEST['points']); + $this->enigme_gateway->insert($enigme); + } + catch(Exception $e) { + $error = "500"; + require($rep . $vues['erreur']); + } + } + + public function deleteEnigme() + { + global $rep, $vues, $error; + try{ + $this->enigme_gateway->delete($_REQUEST['id']); + } + catch(Exception $e) { + $error = "500"; + require($rep . $vues['erreur']); + } + } + + public function } \ No newline at end of file diff --git a/WEB/Model/scripted.db b/WEB/Model/scripted.db index 5ee8fe20..46151e5f 100644 Binary files a/WEB/Model/scripted.db and b/WEB/Model/scripted.db differ diff --git a/WEB/index.php b/WEB/index.php index 1b8647e6..468267f3 100644 --- a/WEB/index.php +++ b/WEB/index.php @@ -6,8 +6,8 @@ Autoload::charger(); $control = new FrontController(); //session_regenerate_id(true); -// session_unset(); -// session_destroy(); -// $_SESSION = null; +session_unset(); +session_destroy(); +$_SESSION = null; //https://a-pellegrini.developpez.com/temp/tutoriels/php/security/session/#III.2 \ No newline at end of file