Compare commits
30 Commits
@ -1,8 +0,0 @@
|
||||
# Default ignored files
|
||||
/shelf/
|
||||
/workspace.xml
|
||||
# Datasource local storage ignored files
|
||||
/dataSources/
|
||||
/dataSources.local.xml
|
||||
# Editor-based HTTP Client requests
|
||||
/httpRequests/
|
@ -1,18 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module type="WEB_MODULE" version="4">
|
||||
<component name="NewModuleRootManager">
|
||||
<content url="file://$MODULE_DIR$">
|
||||
<sourceFolder url="file://$MODULE_DIR$/project/src/config" isTestSource="false" packagePrefix="config\" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/project/src/controller" isTestSource="false" packagePrefix="controller\" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/project/src/model" isTestSource="false" packagePrefix="model\" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/project/src/model/exception" isTestSource="false" packagePrefix="model\" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/project/src/model/gateways" isTestSource="false" packagePrefix="model\" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/project/src/model/mdl" isTestSource="false" packagePrefix="model\" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/project/src/model/metier" isTestSource="false" packagePrefix="model\" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/project/src/vendor/altorouter/altorouter" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/project/src/vendor/composer" />
|
||||
</content>
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
</component>
|
||||
</module>
|
@ -1,14 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="PublishConfigData" remoteFilesAllowedToDisappearOnAutoupload="false">
|
||||
<serverData>
|
||||
<paths name="ProjetPHP">
|
||||
<serverdata>
|
||||
<mappings>
|
||||
<mapping local="$PROJECT_DIR$" web="/" />
|
||||
</mappings>
|
||||
</serverdata>
|
||||
</paths>
|
||||
</serverData>
|
||||
</component>
|
||||
</project>
|
@ -1,8 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectModuleManager">
|
||||
<modules>
|
||||
<module fileurl="file://$PROJECT_DIR$/.idea/ScienceQuest.iml" filepath="$PROJECT_DIR$/.idea/ScienceQuest.iml" />
|
||||
</modules>
|
||||
</component>
|
||||
</project>
|
@ -1,28 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="MessDetectorOptionsConfiguration">
|
||||
<option name="transferred" value="true" />
|
||||
</component>
|
||||
<component name="PHPCSFixerOptionsConfiguration">
|
||||
<option name="transferred" value="true" />
|
||||
</component>
|
||||
<component name="PHPCodeSnifferOptionsConfiguration">
|
||||
<option name="highlightLevel" value="WARNING" />
|
||||
<option name="transferred" value="true" />
|
||||
</component>
|
||||
<component name="PhpIncludePathManager">
|
||||
<include_path>
|
||||
<path value="$PROJECT_DIR$/project/src/vendor/altorouter/altorouter" />
|
||||
<path value="$PROJECT_DIR$/project/src/vendor/composer" />
|
||||
</include_path>
|
||||
</component>
|
||||
<component name="PhpProjectSharedConfiguration" php_language_level="7.4">
|
||||
<option name="suggestChangeDefaultLanguageLevel" value="false" />
|
||||
</component>
|
||||
<component name="PhpStanOptionsConfiguration">
|
||||
<option name="transferred" value="true" />
|
||||
</component>
|
||||
<component name="PsalmOptionsConfiguration">
|
||||
<option name="transferred" value="true" />
|
||||
</component>
|
||||
</project>
|
@ -1,6 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="VcsDirectoryMappings">
|
||||
<mapping directory="" vcs="Git" />
|
||||
</component>
|
||||
</project>
|
After Width: | Height: | Size: 42 KiB |
After Width: | Height: | Size: 107 KiB |
After Width: | Height: | Size: 189 KiB |
After Width: | Height: | Size: 29 KiB |
After Width: | Height: | Size: 52 KiB |
After Width: | Height: | Size: 159 KiB |
After Width: | Height: | Size: 31 KiB |
@ -1,5 +0,0 @@
|
||||
vendor/
|
||||
composer.lock
|
||||
js/bootstrap*.js*
|
||||
css/bootstrap*.css*
|
||||
config.php
|
@ -1,3 +0,0 @@
|
||||
RewriteEngine on
|
||||
RewriteCond %{REQUEST_FILENAME} !-f
|
||||
RewriteRule . index.php [L]
|
@ -1,26 +0,0 @@
|
||||
{
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"controller\\": "controller/",
|
||||
"config\\": "config/",
|
||||
"model\\": ["model/", "model/mdl/", "model/gateways/", "model/metier/", "model/exception/"]
|
||||
}
|
||||
},
|
||||
"require": {
|
||||
"altorouter/altorouter": "^2.0",
|
||||
"twig/twig": "^3.7",
|
||||
"twbs/bootstrap": "^5.3",
|
||||
"ext-iconv": "*",
|
||||
"ext-pdo": "*"
|
||||
},
|
||||
"scripts": {
|
||||
"post-update-cmd": [
|
||||
"mkdir -p ./css",
|
||||
"mkdir -p ./js",
|
||||
"rm -f ./js/bootstrap*.js*",
|
||||
"rm -f ./css/bootstrap*.css*",
|
||||
"cp ./vendor/twbs/bootstrap/dist/js/* ./js/",
|
||||
"cp ./vendor/twbs/bootstrap/dist/css/* ./css/"
|
||||
]
|
||||
}
|
||||
}
|
@ -1,111 +0,0 @@
|
||||
<?php
|
||||
namespace config;
|
||||
|
||||
|
||||
use model\ConfigurationJeu;
|
||||
use model\Joueur;
|
||||
use model\MdlPendu;
|
||||
use model\MdlScienceQuizz;
|
||||
use model\ValidationException;
|
||||
|
||||
class Validation
|
||||
{
|
||||
public static function val_action($action)
|
||||
{
|
||||
if (!isset($action)) {
|
||||
throw new ValidationException('pas d\'action');
|
||||
}
|
||||
}
|
||||
|
||||
public static function val_form(string &$jeu, string &$difficulty, &$dVueErreur)
|
||||
{
|
||||
if ($jeu == '' || !filter_var($jeu, FILTER_SANITIZE_STRING)) {
|
||||
$dVueErreur[] = 'Aucun jeu selectionné';
|
||||
$jeu = 0;
|
||||
throw new ValidationException("Erreur jeu");
|
||||
}
|
||||
|
||||
if ($difficulty == '' || !filter_var($difficulty, FILTER_VALIDATE_INT)) {
|
||||
$dVueErreur[] = "Aucune difficulté séléctionnée";
|
||||
$difficulty = 0;
|
||||
throw new ValidationException("Erreur difficulté");
|
||||
}
|
||||
}
|
||||
|
||||
public static function valUserLogin(string $user, &$dVueErreur)
|
||||
{
|
||||
if ($user == '' || !filter_var($user, FILTER_SANITIZE_STRING)) {
|
||||
$dVueErreur[] = 'Identifiant invalide';
|
||||
$jeu = 0;
|
||||
throw new ValidationException("Erreur identifiant");
|
||||
}
|
||||
}
|
||||
|
||||
public static function valCodeInvitation(string $codeInvitation, &$dVueErreur): string
|
||||
{
|
||||
if($codeInvitation == ''){
|
||||
$dVueErreur[] = 'Code d\'invitation invalide';
|
||||
throw new ValidationException("Code d'invitation invalide");
|
||||
}
|
||||
return htmlspecialchars($codeInvitation);
|
||||
}
|
||||
|
||||
public static function valPseudo(string &$pseudo, &$dVueErreur){
|
||||
$pseudo = trim($pseudo);
|
||||
$pseudo = htmlspecialchars($pseudo);
|
||||
$pseudo = filter_var($pseudo, FILTER_UNSAFE_RAW);
|
||||
if($pseudo == '' ){
|
||||
$dVueErreur[] = 'Pseudo invalide';
|
||||
throw new ValidationException("Pseudo invalide");
|
||||
}
|
||||
return $pseudo;
|
||||
}
|
||||
|
||||
public static function valRole(&$role, &$dVueErreur): Joueur
|
||||
{
|
||||
if(! $role instanceof Joueur){
|
||||
$role = NULL;
|
||||
$dVueErreur[] = 'Role invalide';
|
||||
throw new ValidationException('Role invalide');
|
||||
}
|
||||
return $role;
|
||||
}
|
||||
|
||||
public static function valConfigurationJeu($configurationJeu, &$dVueErreur): ConfigurationJeu
|
||||
{
|
||||
if(! $configurationJeu instanceof ConfigurationJeu){
|
||||
$role = NULL;
|
||||
$dVueErreur[] = 'Configuration du jeu invalide';
|
||||
throw new ValidationException('Configuration du jeu');
|
||||
}
|
||||
return $configurationJeu;
|
||||
}
|
||||
|
||||
public static function valMdlPendu($pendu, &$dVueErreur): MdlPendu
|
||||
{
|
||||
if(! $pendu instanceof MdlPendu){
|
||||
$role = NULL;
|
||||
$dVueErreur[] = 'Erreur mauvais jeu en utilisation';
|
||||
throw new ValidationException('Erreur mauvais jeu en utilisation');
|
||||
}
|
||||
return $pendu;
|
||||
}
|
||||
|
||||
public static function valPosInt($val) : int {
|
||||
if(is_int($val) && $val > 0) {
|
||||
return 0;
|
||||
}
|
||||
return $val;
|
||||
}
|
||||
|
||||
public static function valMdlScienceQuizz($scienceQuizz, array &$dVueErreur): MdlScienceQuizz
|
||||
{
|
||||
if(! $scienceQuizz instanceof MdlScienceQuizz){
|
||||
$role = NULL;
|
||||
$dVueErreur[] = 'Erreur, mauvais jeu en utilisation';
|
||||
throw new ValidationException('Erreur, mauvais jeu en utilisation');
|
||||
}
|
||||
return $scienceQuizz;
|
||||
}
|
||||
|
||||
}
|
@ -1,18 +0,0 @@
|
||||
<?php
|
||||
namespace config;
|
||||
|
||||
$config = [
|
||||
"rep" => __DIR__.'/../',
|
||||
|
||||
"db" => ["dsn" => 'pgsql:host=localhost;dbname=postgres',
|
||||
"login" => 'postgres',
|
||||
"mdp" => 'root'],
|
||||
"templates" => ["index" => 'vues/index.php',
|
||||
"pseudo" => 'pseudo.html',
|
||||
"jouer" => "jouer.html",
|
||||
"pendu" => "pendu.html",
|
||||
"penduScore" => 'penduScore.html',
|
||||
"scienceQuizz" => 'scienceQuizz.html',
|
||||
"scienceQuizzReponse" => 'scienceQuizzReponse.html',
|
||||
"scienceQuizzRecap" => 'scienceQuizzRecap.html',]
|
||||
];
|
@ -1,137 +0,0 @@
|
||||
<?php
|
||||
namespace controller;
|
||||
use config\Validation;
|
||||
use Exception;
|
||||
use PDOException;
|
||||
use model\MdlDifficulte;
|
||||
use model\MdlScientifique;
|
||||
use model\MdlSexe;
|
||||
use model\MdlThematique;
|
||||
use model\Scientifique;
|
||||
|
||||
//gerer la connexion des admins
|
||||
class AdminController {
|
||||
|
||||
public function defaultAction(array $params) {
|
||||
global $twig;
|
||||
|
||||
echo $twig->render('admin/accueil.html');
|
||||
}
|
||||
public function notLogged(array $params) {
|
||||
global $twig;
|
||||
//dire acces interdit aux non admins
|
||||
$dVueErreur[] = 'Erreur 403 : Accès interdit !';
|
||||
echo $twig->render('erreur.html', ['dVueErreur' => $dVueErreur]);
|
||||
}
|
||||
public function stats(array $params) {
|
||||
global $twig;
|
||||
|
||||
echo $twig->render('admin/stats.html');
|
||||
}
|
||||
public function ajouterScientifiques(array $params) {
|
||||
global $twig;
|
||||
|
||||
$sexe = new MdlSexe();
|
||||
$theme = new MdlThematique();
|
||||
$diff = new MdlDifficulte();
|
||||
$scient=null;
|
||||
if(!empty($_POST)){
|
||||
$id=0;
|
||||
if(isset($_GET["id"])){
|
||||
$id=intval($_GET["id"]);
|
||||
}
|
||||
try{
|
||||
$this->verifierDonnees();
|
||||
} catch (Exception $ex){
|
||||
$dVueErreur[] = 'Erreur : '.$ex;
|
||||
echo $twig->render('erreur.html', ['dVueErreur' => $dVueErreur]);
|
||||
return;
|
||||
}
|
||||
$sci = new Scientifique(
|
||||
$id,
|
||||
$_POST["name"],
|
||||
$_POST["prenom"],
|
||||
$_POST["url"],
|
||||
\DateTime::createFromFormat("Y-m-d", $_POST["date"]),
|
||||
$_POST["description"],
|
||||
0,
|
||||
$theme->getFromId(intval($_POST["theme"])),
|
||||
$diff->getFromId(intval($_POST["difficulte"])),
|
||||
$sexe->getFromId(intval($_POST["sexe"]))
|
||||
);
|
||||
$mdlsci=new MdlScientifique();
|
||||
if(isset($_GET["id"])){
|
||||
$mdlsci->editScientifique($sci);
|
||||
} else {
|
||||
$mdlsci->addScientifique($sci);
|
||||
}
|
||||
}
|
||||
if(isset($_GET["id"])){
|
||||
$scient=new MdlScientifique();
|
||||
$scient=$scient->getScientifique($_GET["id"]);
|
||||
}
|
||||
|
||||
echo $twig->render('admin/ajouterScientifiques.html',['sexe' => $sexe->getAll(), 'themes' => $theme->getAll(), 'difficultes' => $diff->getAll(), 'scientifique' => $scient]);
|
||||
}
|
||||
public function listeScientifiques(array $params) {
|
||||
global $twig;
|
||||
|
||||
$ms = new MdlScientifique();
|
||||
if (!isset($params['id'])) {
|
||||
$page = 1;
|
||||
} else {
|
||||
$page = Validation::valPosInt($params['id']);
|
||||
}
|
||||
$dVue['listeScientifiques'] = $ms->getScientifiquesParPage($page);
|
||||
$dVue['pageMax'] = $ms->getMaxPages();
|
||||
$dVue['page'] = $page;
|
||||
if ($page - 1 <= 0) {
|
||||
$dVue['pagePrec'] = 1;
|
||||
} else {
|
||||
$dVue['pagePrec'] = $page - 1;
|
||||
}
|
||||
if ($page + 1 >= $dVue['pageMax']) {
|
||||
$dVue['pageSuiv'] = $dVue['pageMax'];
|
||||
} else {
|
||||
$dVue['pageSuiv'] = $page + 1;
|
||||
}
|
||||
echo $twig->render('admin/listeScientifiques.html',['dVue' => $dVue]);
|
||||
}
|
||||
|
||||
|
||||
private function verifierDonnees(){
|
||||
$sexe = new MdlSexe();
|
||||
$theme = new MdlThematique();
|
||||
$diff = new MdlDifficulte();
|
||||
$selectTheme=$theme->getFromId(intval($_POST["theme"]));
|
||||
$selectDiff=$diff->getFromId(intval($_POST["difficulte"]));
|
||||
$selectSexe=$sexe->getFromId(intval($_POST["sexe"]));
|
||||
//todo : verifier les données, mettre dans une fonction et try catch
|
||||
if(strlen($_POST["name"]) < 2){
|
||||
throw new Exception("nom trop court");
|
||||
}
|
||||
if(strlen($_POST["prenom"]) < 2){
|
||||
throw new Exception("prénom trop court");
|
||||
}
|
||||
if(empty($_POST["url"])){
|
||||
throw new Exception("pas de photo");
|
||||
}
|
||||
if(strlen($_POST["name"]) < 2){
|
||||
throw new Exception("nom trop court");
|
||||
}
|
||||
if(strlen($_POST["description"]) < 20){
|
||||
throw new Exception("description trop courte ");
|
||||
}
|
||||
if($selectTheme==null){
|
||||
throw new Exception("thematique inconnue");
|
||||
}
|
||||
if($selectSexe==null){
|
||||
throw new Exception("sexe inconnu");
|
||||
}
|
||||
if($selectDiff==null){
|
||||
throw new Exception("difficulté inconnue");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
@ -1,116 +0,0 @@
|
||||
<?php
|
||||
namespace controller;
|
||||
|
||||
use AltoRouter;
|
||||
use config\Validation;
|
||||
use Exception;
|
||||
use http\Params;
|
||||
use model\ConfigurationJeu;
|
||||
use model\Connection;
|
||||
use model\LoginException;
|
||||
use model\MdlAdmin;
|
||||
use model\MdlDifficulte;
|
||||
use model\MdlJeu;
|
||||
use model\MdlUser;
|
||||
use model\ValidationException;
|
||||
use PDOException;
|
||||
|
||||
class FrontController
|
||||
{
|
||||
private Connection $con;
|
||||
|
||||
/**
|
||||
* @throws Exception
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
|
||||
global $twig, $router, $dVue;
|
||||
global $basePath;
|
||||
global $dVueErreur;
|
||||
|
||||
//altorouter
|
||||
$router = new AltoRouter();
|
||||
$router->setBasePath($basePath);
|
||||
|
||||
// Correspond à action = null et permet d'éviter une erreur sur la page /index.php
|
||||
$router->map('GET|POST','/index.php','UserController');
|
||||
|
||||
$router->map('GET|POST','/pseudo/[a:action]?','_TO_DELETE__PseudoController');
|
||||
$router->map('GET|POST','/admin/[a:action]?/[i:id]?','AdminController');
|
||||
$router->map('GET|POST','/[a:action]?/[i:id]?','UserController');
|
||||
|
||||
try {
|
||||
session_start();
|
||||
} catch (Exception $e) {
|
||||
die('Session start failed: ' . $e->getMessage());
|
||||
}
|
||||
|
||||
$dVue['idAdmin'] = false;
|
||||
$dVue['idUser'] = false;
|
||||
|
||||
if(isset($_SESSION['pseudo'])) {
|
||||
$dVue['pseudo'] = $_SESSION['pseudo'];
|
||||
if (isset($_SESSION['isUser']) && $_SESSION['isUser']) {
|
||||
$dVue['isUser'] = true;
|
||||
} elseif (isset($_SESSION['idAdmin']) && $_SESSION['idAdmin']) {
|
||||
$dVue['isAdmin'] = true;
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
$match = $router->match();
|
||||
|
||||
if (!$match) {
|
||||
throw new Exception('Wrong call');
|
||||
}
|
||||
|
||||
switch($match['target']) {
|
||||
|
||||
case 'UserController':
|
||||
$this->callController('UserController',$match);
|
||||
break;
|
||||
|
||||
case 'AdminController':
|
||||
$action = $match['params']['action'] ?? '';
|
||||
if (!MdlAdmin::isAdmin()) {
|
||||
$match['params']['action'] = 'notLogged';
|
||||
}
|
||||
$this->callController('AdminController',$match);
|
||||
break;
|
||||
|
||||
case '_TO_DELETE__PseudoController':
|
||||
$this->callController('_TO_DELETE__PseudoController',$match);
|
||||
break;
|
||||
//mauvaise action
|
||||
default:
|
||||
$dVueErreur[] = "Erreur d'appel php";
|
||||
echo $twig->render('accueil.html', ['dVueErreur' => $dVueErreur]);
|
||||
break;
|
||||
}
|
||||
} catch (LoginException $e) {
|
||||
echo $twig->render('erreur.html', ['dVueErreur' => $dVueErreur]);
|
||||
echo $twig->render('login.html');
|
||||
} catch (Exception $e2) {
|
||||
$dVueErreur[] = 'Erreur inattendue !';
|
||||
$dVueErreur[] = $e2->getMessage();
|
||||
echo $twig->render('erreur.html', ['dVueErreur' => $dVueErreur]);
|
||||
}
|
||||
|
||||
exit(0);
|
||||
}
|
||||
|
||||
private function callController(string $cont, array $match) {
|
||||
global $twig;
|
||||
|
||||
$controller = '\\controller\\'.$cont;
|
||||
$controller = new $controller;
|
||||
$action = $match['params']['action'] ?? 'defaultAction';
|
||||
|
||||
if (is_callable(array($controller,$action))) {
|
||||
call_user_func_array(array($controller,$action),array($match['params']));
|
||||
} else {
|
||||
echo $twig->render('erreur.html', ['dVueErreur' => array('Page inconnue')]);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,157 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace controller;
|
||||
|
||||
use config\Validation;
|
||||
use Exception;
|
||||
use model\ConfigurationJeu;
|
||||
use model\Connection;
|
||||
use model\LoginException;
|
||||
use model\MdlAdmin;
|
||||
use model\MdlDifficulte;
|
||||
use model\MdlJeu;
|
||||
use model\MdlScientifique;
|
||||
use model\MdlUser;
|
||||
use model\PseudoDejaPrisException;
|
||||
use model\ValidationException;
|
||||
|
||||
class InviteController
|
||||
{
|
||||
|
||||
public function defaultAction(array $params) {
|
||||
global $twig, $dVue;
|
||||
|
||||
echo $twig->render('accueil.html', ["dVue"=>$dVue]);
|
||||
}
|
||||
|
||||
public function historique(array $params) {
|
||||
global $twig;
|
||||
global $dVueErreur;
|
||||
global $dVue;
|
||||
|
||||
$ms = new MdlScientifique();
|
||||
|
||||
if (!isset($params['id'])) {
|
||||
$page = 1;
|
||||
} else {
|
||||
$page = Validation::valPosInt($params['id']);
|
||||
}
|
||||
|
||||
$pseudo = Validation::valPseudo($_SESSION['pseudo'],$dVueErreur);
|
||||
|
||||
$dVue['listeScientifiques'] = $ms->getHistoriqueParPage($pseudo,$page);
|
||||
$dVue['pageMax'] = $ms->getMaxPagesHistorique($pseudo);
|
||||
$dVue['page'] = $page;
|
||||
|
||||
if ($page - 1 <= 0) {
|
||||
$dVue['pagePrec'] = 1;
|
||||
} else {
|
||||
$dVue['pagePrec'] = $page - 1;
|
||||
}
|
||||
if ($page + 1 >= $dVue['pageMax']) {
|
||||
$dVue['pageSuiv'] = $dVue['pageMax'];
|
||||
} else {
|
||||
$dVue['pageSuiv'] = $page + 1;
|
||||
}
|
||||
|
||||
echo $twig->render('historique.html',['dVue' => $dVue]);
|
||||
}
|
||||
|
||||
public function joinParty(array $params) {
|
||||
global $twig;
|
||||
|
||||
if(isset($_POST['codeInvitation'])){
|
||||
$codeInvitation = $_POST['codeInvitation'];
|
||||
Validation::valCodeInvitation($codeInvitation, $dVueErreur);
|
||||
echo $twig->render('join.html');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws Exception
|
||||
*/
|
||||
public function jouer(array $params) {
|
||||
global $twig, $config;
|
||||
$dVue = [];
|
||||
$dVueErreur = [];
|
||||
|
||||
if(isset($_SESSION["configuration"]) && isset($_SESSION['role'])){
|
||||
try{
|
||||
$role = $_SESSION['role'];
|
||||
$role = Validation::valRole($role, $dVueErreur);
|
||||
$configurationJeu = $_SESSION['configuration'];
|
||||
$configurationJeu = Validation::valConfigurationJeu($configurationJeu, $dVueErreur);
|
||||
}catch(ValidationException $e){
|
||||
header('Location: .');
|
||||
}
|
||||
|
||||
if(count($dVueErreur) == 0){
|
||||
$idJeu = $configurationJeu->getJeu()->getId();
|
||||
switch($idJeu){
|
||||
case 2:
|
||||
new _TO_DELETE__ScienceQuizzController($role, $configurationJeu);
|
||||
break;
|
||||
case 3:
|
||||
new _TO_DELETE__PenduController($role, $configurationJeu);
|
||||
break;
|
||||
default:
|
||||
throw new Exception("Jeu non défini !");
|
||||
}
|
||||
}
|
||||
}else{
|
||||
header("Location: .");
|
||||
}
|
||||
}
|
||||
|
||||
public function createParty(array $params) : void
|
||||
{
|
||||
global $twig;
|
||||
global $dVueErreur;
|
||||
|
||||
$listJeu = (new MdlJeu())->getAll();
|
||||
$listDifficulte = (new MdlDifficulte())->getAll();
|
||||
|
||||
$dVueCreateJeu = [];
|
||||
foreach($listJeu as $jeu){
|
||||
$dVueCreateJeu[] = ['id' => $jeu->getId(), 'nom' => $jeu->getNom()];
|
||||
}
|
||||
|
||||
$dVueCreateDifficulte = [];
|
||||
foreach($listDifficulte as $difficulte){
|
||||
$dVueCreateDifficulte[] = ['id' => $difficulte->getId(), 'libelle' => $difficulte->getLibelle()];
|
||||
}
|
||||
|
||||
echo $twig->render('create.html', ["dVueErreur" => $dVueErreur, 'dVueCreate' => ["jeux" => $dVueCreateJeu, "difficultes" => $dVueCreateDifficulte]]);
|
||||
}
|
||||
|
||||
public function ValidationFormulaire(array $params)
|
||||
{
|
||||
global $twig;
|
||||
global $dVue;
|
||||
global $dVueErreur;
|
||||
global $basePath;
|
||||
|
||||
$id_jeu = $_POST['jeu'] ?? '';
|
||||
$id_difficulte = $_POST['difficulte'] ?? '';
|
||||
try{
|
||||
Validation::val_form($id_jeu, $id_difficulte, $dVueErreur);
|
||||
}catch (ValidationException|Exception $ex){
|
||||
$this->CreateParty($dVueErreur);
|
||||
}
|
||||
|
||||
if(count($dVueErreur) == 0){
|
||||
$jeu = (new MdlJeu())->getFromId($id_jeu);
|
||||
$difficulte = (new MdlDifficulte())->getFromId($id_difficulte);
|
||||
$_SESSION['configuration'] = new ConfigurationJeu($jeu, $difficulte);
|
||||
|
||||
if(isset($_SESSION['role'])){
|
||||
header('Location: '.$basePath.'/jouer');
|
||||
}else{
|
||||
header("Location: ".$basePath."/pseudo");
|
||||
}
|
||||
#echo $twig->render('accueil.html', ['dVue' => $dVue, 'dVueErreur' => $dVueErreur]);
|
||||
}else{
|
||||
$this->CreateParty($dVueErreur);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,96 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace controller;
|
||||
|
||||
use config\Validation;
|
||||
use Exception;
|
||||
use model\ConfigurationJeu;
|
||||
use model\Connection;
|
||||
use model\GameGateway;
|
||||
use model\Joueur;
|
||||
use model\MdlDifficulte;
|
||||
use model\MdlJeu;
|
||||
use model\MdlScientifique;
|
||||
use model\PseudoDejaPrisException;
|
||||
use model\ValidationException;
|
||||
use model\MdlUser;
|
||||
use model\MdlAdmin;
|
||||
use model\LoginException;
|
||||
use model\Utilisateur;
|
||||
|
||||
class UserController extends InviteController {
|
||||
|
||||
|
||||
public function listerLesScientifiquesDecouverts() {
|
||||
|
||||
}
|
||||
|
||||
public function afficherDetailScientifique() {
|
||||
|
||||
}
|
||||
|
||||
public function login() {
|
||||
global $twig;
|
||||
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||
Validation::valUserLogin($_REQUEST['login'], $dVueErreur);
|
||||
$ug = new MdlUser();
|
||||
if ($ug->login($_REQUEST['login'], $_REQUEST['password'])) {
|
||||
$_SESSION['pseudo'] = $_REQUEST['login'];
|
||||
$_SESSION['idUser'] = true;
|
||||
$_SESSION['isLogged'] = true;
|
||||
$_SESSION['role'] = $ug->getFromEmail($_REQUEST['login']);
|
||||
header("Location: .");
|
||||
} else {
|
||||
//voir si c'est un admin
|
||||
$ug = new MdlAdmin();
|
||||
if ($ug->login($_REQUEST['login'], $_REQUEST['password'])) {
|
||||
$_SESSION['pseudo'] = $_REQUEST['login'];
|
||||
$_SESSION['isAdmin'] = true;
|
||||
$_SESSION['isLogged'] = true;
|
||||
unset($_SESSION['role']);
|
||||
header("Location: .");
|
||||
} else {
|
||||
$dVueErreur[] = "Connexion échouée";
|
||||
throw new LoginException("Connexion err");
|
||||
}
|
||||
}
|
||||
} else {
|
||||
echo $twig->render('login.html');
|
||||
}
|
||||
}
|
||||
|
||||
public function register() {
|
||||
global $twig, $dVueErreur;
|
||||
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||
if($_REQUEST['password']!=$_REQUEST['cpassword']){
|
||||
$dVueErreur[]="Mots de passe différents.";
|
||||
echo $twig->render('erreur.html',["dVueErreur" => $dVueErreur]);
|
||||
return;
|
||||
}
|
||||
$ug = new MdlUser();
|
||||
try{
|
||||
if($ug->register($_REQUEST['login'], $_REQUEST['password'])){
|
||||
header('Location: login');
|
||||
} else {
|
||||
$dVueErreur[]="Erreur de création de compte. Le compte doit déjà exister.";
|
||||
echo $twig->render('erreur.html',["dVueErreur" => $dVueErreur]);
|
||||
}
|
||||
} catch (PseudoDejaPrisException $ex){
|
||||
$dVueErreur[]="Erreur de création de compte. Le compte existe déjà.";
|
||||
echo $twig->render('erreur.html',["dVueErreur" => $dVueErreur]);
|
||||
}catch(Exception $ex){
|
||||
$dVueErreur[]="Erreur de création de compte.";
|
||||
echo $twig->render('erreur.html',["dVueErreur" => $dVueErreur]);
|
||||
}
|
||||
|
||||
} else {
|
||||
echo $twig->render('register.html');
|
||||
}
|
||||
}
|
||||
|
||||
public function logout(){
|
||||
session_destroy();
|
||||
$_SESSION=[];
|
||||
header("Location: .");
|
||||
}
|
||||
}
|
@ -1,46 +0,0 @@
|
||||
<?php
|
||||
namespace controller;
|
||||
|
||||
use config\Validation;
|
||||
use Exception;
|
||||
use model\ValidationException;
|
||||
|
||||
class _TO_DELETE__JouerController{
|
||||
|
||||
/**
|
||||
* @throws Exception
|
||||
*/
|
||||
public function __construct(){
|
||||
global $twig, $config;
|
||||
global $dVue;
|
||||
global $dVueErreur;
|
||||
global $basePath;
|
||||
|
||||
if(isset($_SESSION["configuration"]) && isset($_SESSION['role'])){
|
||||
try{
|
||||
$role = $_SESSION['role'];
|
||||
$role = Validation::valRole($role, $dVueErreur);
|
||||
$configurationJeu = $_SESSION['configuration'];
|
||||
$configurationJeu = Validation::valConfigurationJeu($configurationJeu, $dVueErreur);
|
||||
}catch(ValidationException $e){
|
||||
header('Location: '.$basePath);
|
||||
}
|
||||
|
||||
if(count($dVueErreur) == 0){
|
||||
$idJeu = $configurationJeu->getJeu()->getId();
|
||||
switch($idJeu){
|
||||
case 2:
|
||||
new _TO_DELETE__ScienceQuizzController($role, $configurationJeu);
|
||||
break;
|
||||
case 3:
|
||||
new _TO_DELETE__PenduController($role, $configurationJeu);
|
||||
break;
|
||||
default:
|
||||
throw new Exception("Jeu non défini !");
|
||||
}
|
||||
}
|
||||
}else{
|
||||
header("Location: ".$basePath);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,133 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace controller;
|
||||
|
||||
use Exception;
|
||||
use model\ConfigurationJeu;
|
||||
use model\Joueur;
|
||||
use model\MdlPendu;
|
||||
use model\MdlScientifique;
|
||||
use config\Validation;
|
||||
use model\MdlUser;
|
||||
use model\Utilisateur;
|
||||
use model\ValidationException;
|
||||
use Twig\Error\LoaderError;
|
||||
use Twig\Error\RuntimeError;
|
||||
use Twig\Error\SyntaxError;
|
||||
|
||||
class _TO_DELETE__PenduController{
|
||||
private array $dVue;
|
||||
private Joueur $role;
|
||||
private array $dVueErreur;
|
||||
private MdlPendu $pendu;
|
||||
|
||||
/**
|
||||
* @throws Exception
|
||||
*/
|
||||
public function __construct(Joueur $role, ConfigurationJeu $configJeu)
|
||||
{
|
||||
$this->role=$role;
|
||||
$this->dVue = [];
|
||||
$this->dVueErreur = [];
|
||||
if(isset($_SESSION['pendu']) && Validation::valMdlPendu($_SESSION['pendu'], $this->dVueErreur)){
|
||||
$this->pendu = $_SESSION['pendu'];
|
||||
}else{
|
||||
$this->reinit();
|
||||
}
|
||||
|
||||
if(isset($_POST['lettre'])){
|
||||
try{
|
||||
$this->pendu->jouerLettre($_POST['lettre']);
|
||||
}catch (ValidationException $e){
|
||||
$this->dVueErreur[] = $e->getMessage();
|
||||
}
|
||||
}
|
||||
|
||||
if($this->pendu->aGagne()){
|
||||
$this->renderAgagne();
|
||||
}elseif($this->pendu->aPerdu()){
|
||||
$this->renderAPerdu();
|
||||
}else{
|
||||
$this->renderJeu();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws Exception
|
||||
*/
|
||||
private function reinit(){
|
||||
$mdlScientifique = new MdlScientifique();
|
||||
$scientifique = $mdlScientifique->getRandom();
|
||||
$this->pendu = new MdlPendu($scientifique);
|
||||
$_SESSION['pendu'] = $this->pendu;
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws SyntaxError
|
||||
* @throws RuntimeError
|
||||
* @throws LoaderError
|
||||
*/
|
||||
private function renderJeu(){
|
||||
global $twig, $config;
|
||||
$this->dVue['decouvert'] = $this->pendu->getDecouvert();
|
||||
$this->dVue['essaisRestant'] = $this->pendu->getEssaisRestant();
|
||||
$lettreUtilisees = $this->pendu->getLettreUtilisees();
|
||||
sort($lettreUtilisees);
|
||||
$this->dVue['lettresUtilisees'] = $lettreUtilisees;
|
||||
echo $twig->render($config['templates']['pendu'], ['dVue' => $this->dVue, 'dVueErreur'=>$this->dVueErreur]);
|
||||
}
|
||||
|
||||
private function ajouterScientifiqueDecouvert(){
|
||||
if($this->role instanceof Utilisateur){
|
||||
try{
|
||||
(new MdlUser())->addScientifiqueDecouvert($this->role->getId(), $this->pendu->getScientifique()->getId());
|
||||
}
|
||||
catch(ValidationException $e){
|
||||
$this->dVueErreur[] = $e->getMessage();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws SyntaxError
|
||||
* @throws RuntimeError
|
||||
* @throws LoaderError
|
||||
*/
|
||||
private function renderAgagne(){
|
||||
$this->dVue['messageScore'] = "Vous avez gagné !";
|
||||
$this->ajouterScientifiqueDecouvert();
|
||||
$this->renderScore();
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws SyntaxError
|
||||
* @throws RuntimeError
|
||||
* @throws LoaderError
|
||||
*/
|
||||
private function renderAPerdu(){
|
||||
$this->dVue['messageScore'] = "Vous avez perdu !";
|
||||
$this->renderScore();
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws SyntaxError
|
||||
* @throws RuntimeError
|
||||
* @throws LoaderError
|
||||
*/
|
||||
private function renderScore(){
|
||||
global $twig, $config;
|
||||
$this->dVue['nbTours'] = $this->pendu->getNbTours();
|
||||
$this->dVue['nbFails'] = $this->pendu->getNbFails();
|
||||
$scientifique = $this->pendu->getScientifique();
|
||||
$dScientifique = [];
|
||||
$dScientifique['nom'] = $scientifique->getNom();
|
||||
$dScientifique['prenom'] = $scientifique->getPrenom();
|
||||
$dScientifique['sexe'] = $scientifique->getSexe()->getLibelle();
|
||||
$dScientifique['thematique'] = $scientifique->getThematique()->getLibelle();
|
||||
$dScientifique['dateNaiss'] = $scientifique->getDateNaiss()->format('d/m/Y');
|
||||
$this->dVue['scientifique'] = $dScientifique;
|
||||
unset($_SESSION['pendu']);
|
||||
|
||||
echo $twig->render($config['templates']['penduScore'], ["dVue" => $this->dVue]);
|
||||
}
|
||||
}
|
@ -1,44 +0,0 @@
|
||||
<?php
|
||||
namespace controller;
|
||||
|
||||
use config\Validation;
|
||||
use model\IdSessionDoubleException;
|
||||
use model\PseudoDejaPrisException;
|
||||
use model\ValidationException;
|
||||
use model\MdlInvite;
|
||||
|
||||
class _TO_DELETE__PseudoController{
|
||||
|
||||
public function defaultAction(){
|
||||
global $twig, $config;
|
||||
global $basePath;
|
||||
$dVue = [];
|
||||
$dVueErreur = [];
|
||||
|
||||
if(isset($_POST["pseudo"])){
|
||||
try{
|
||||
$mdlInvite = new MdlInvite();
|
||||
$pseudo = $_POST["pseudo"];
|
||||
$pseudo = Validation::valPseudo($pseudo, $dVueErreur);
|
||||
$role = $mdlInvite->insertInvite($pseudo, session_id());
|
||||
}catch(ValidationException $e){
|
||||
|
||||
}catch(PseudoDejaPrisException $e){
|
||||
$dVueErreur[] = "Pseudo déjà pris";
|
||||
}catch(IdSessionDoubleException $e){
|
||||
try{
|
||||
$role = $mdlInvite->setPseudo($e->getIdJoueur(), $pseudo);
|
||||
|
||||
}catch(PseudoDejaPrisException $e){
|
||||
$dVueErreur[] = "Pseudo déjà pris";
|
||||
}
|
||||
}
|
||||
|
||||
if(isset($role)){
|
||||
$_SESSION['role'] = $role;
|
||||
header('Location: '.$basePath.'/jouer');
|
||||
}
|
||||
}
|
||||
echo $twig->render($config['templates']['pseudo'], ["dVue" => $dVue, "dVueErreur" => $dVueErreur]);
|
||||
}
|
||||
}
|
@ -1,132 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace controller;
|
||||
|
||||
use Exception;
|
||||
use model\ConfigurationJeu;
|
||||
use model\Connection;
|
||||
use model\Joueur;
|
||||
use model\MdlScienceQuizz;
|
||||
use model\MdlScientifique;
|
||||
use config\Validation;
|
||||
use model\ScientifiqueGateway;
|
||||
use model\ValidationException;
|
||||
use Twig\Error\LoaderError;
|
||||
use Twig\Error\RuntimeError;
|
||||
use Twig\Error\SyntaxError;
|
||||
|
||||
class _TO_DELETE__ScienceQuizzController
|
||||
{
|
||||
private array $dVue;
|
||||
private array $dVueErreur;
|
||||
private MdlScienceQuizz $scienceQuizz;
|
||||
private Connection $con;
|
||||
|
||||
/**
|
||||
* @throws RuntimeError
|
||||
* @throws SyntaxError
|
||||
* @throws LoaderError
|
||||
* @throws Exception
|
||||
*/
|
||||
public function __construct(Joueur $role, ConfigurationJeu $configJeu)
|
||||
{
|
||||
$this->dVue = [];
|
||||
$this->dVueErreur = [];
|
||||
if (isset($_SESSION['scienceQuizz']) && Validation::valMdlScienceQuizz($_SESSION['scienceQuizz'], $this->dVueErreur)) {
|
||||
$this->scienceQuizz = $_SESSION['scienceQuizz'];
|
||||
} else {
|
||||
$this->reInit();
|
||||
}
|
||||
|
||||
if ($this->scienceQuizz->partieTerminee()) {
|
||||
$this->vueRecap();
|
||||
}
|
||||
else {
|
||||
$this->vueJeu();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws Exception
|
||||
*/
|
||||
private function reInit()
|
||||
{
|
||||
$mdlScientifique = new MdlScientifique();
|
||||
$scientifique = $mdlScientifique->getRandom();
|
||||
$idScientifique = $scientifique->getId();
|
||||
$questions = $mdlScientifique->getQuestions($idScientifique);
|
||||
$this->scienceQuizz = new MdlScienceQuizz($idScientifique,$questions);
|
||||
$_SESSION['scienceQuizz'] = $this->scienceQuizz;
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws SyntaxError
|
||||
* @throws RuntimeError
|
||||
* @throws LoaderError
|
||||
*/
|
||||
private function vueJeu()
|
||||
{
|
||||
global $twig, $config;
|
||||
|
||||
$dStatJeu['numQuestion'] = $this->scienceQuizz->getNumQuestion();
|
||||
|
||||
$questions = $this->scienceQuizz->getQuestions();
|
||||
|
||||
if ($questions) {
|
||||
$dStatJeu['question'] = $this->scienceQuizz->getRandomQuestion($questions);
|
||||
} else {
|
||||
// Gérer le cas où aucune question n'est disponible
|
||||
$this->dVueErreur[] = "Aucune question disponible.";
|
||||
echo $twig->render('erreur.html', ['dVueErreur' => $this->dVueErreur]);
|
||||
return;
|
||||
}
|
||||
|
||||
$this->dVue['statJeu'] = $dStatJeu;
|
||||
|
||||
echo $twig->render($config['templates']['scienceQuizz'], ['dVue' => $this->dVue, 'dVueErreur' => $this->dVueErreur]);
|
||||
?>
|
||||
<script>
|
||||
setTimeout(function() {
|
||||
window.location.href = "/scienceQuizzReponse.html";
|
||||
}, 30000);
|
||||
</script>
|
||||
<?php
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws RuntimeError
|
||||
* @throws SyntaxError
|
||||
* @throws LoaderError
|
||||
*/
|
||||
private function vueReponse()
|
||||
{
|
||||
global $twig, $config;
|
||||
|
||||
$dScientifique['nom'] = $this->scienceQuizz->getNom();
|
||||
$dScientifique['prenom'] = $this->scienceQuizz->getPrenom();
|
||||
$dScientifique['dateNaissance'] = $this->scienceQuizz->getDateNaissance();
|
||||
|
||||
|
||||
$this->dVue['scientifique'] = $dScientifique;
|
||||
|
||||
echo $twig->render($config['templates']['scienceQuizzReponse'], ["dVue" => $this->dVue]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws RuntimeError
|
||||
* @throws SyntaxError
|
||||
* @throws LoaderError
|
||||
*/
|
||||
private function vueRecap()
|
||||
{
|
||||
global $twig, $config;
|
||||
|
||||
$dStatJoueur ['bonneReponse'] = $this->scienceQuizz->getBonneReponse();
|
||||
$dStatJoueur ['nbPoints'] = $this->scienceQuizz->getNbPoints();
|
||||
|
||||
$this->dVue['statJoueur'] = $dStatJoueur;
|
||||
unset($_SESSION['scienceQuizz']);
|
||||
|
||||
echo $twig->render($config['templates']['scienceQuizzRecap'], ["dVue" => $this->dVue]);
|
||||
}
|
||||
}
|
@ -1,22 +0,0 @@
|
||||
<?php
|
||||
require_once(__DIR__.'/vendor/autoload.php');
|
||||
require_once(__DIR__.'/config/config.php');
|
||||
|
||||
use controller\FrontController;
|
||||
use Twig\Environment;
|
||||
use Twig\Loader\FilesystemLoader;
|
||||
|
||||
//twig
|
||||
$loader = new FilesystemLoader('templates');
|
||||
$twig = new Environment($loader, [
|
||||
'cache' => false,
|
||||
]);
|
||||
|
||||
$basePath = preg_replace('/\/index.php/i', '', $_SERVER['PHP_SELF']);
|
||||
|
||||
// Tableau qui contient les messages d'erreur
|
||||
$dVueErreur = [];
|
||||
$dVue['basePath'] = $basePath;
|
||||
|
||||
$cont = new FrontController();
|
||||
|
@ -1,26 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace model;
|
||||
|
||||
use RuntimeException;
|
||||
|
||||
class IdSessionDoubleException extends RuntimeException
|
||||
{
|
||||
private int $idJoueur;
|
||||
private string $idSession;
|
||||
|
||||
public function __construct($idJoueur, $idSession)
|
||||
{
|
||||
parent::__construct();
|
||||
$this->idJoueur=$idJoueur;
|
||||
$this->idSession=$idSession;
|
||||
}
|
||||
|
||||
public function getIdJoueur():int{
|
||||
return $this->idJoueur;
|
||||
}
|
||||
|
||||
public function getIdSession(): string{
|
||||
return $this->idSession;
|
||||
}
|
||||
}
|
@ -1,9 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace model;
|
||||
|
||||
use Exception;
|
||||
|
||||
class LoginException extends Exception
|
||||
{
|
||||
}
|
@ -1,10 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace model;
|
||||
|
||||
use RuntimeException;
|
||||
|
||||
class PseudoDejaPrisException extends RuntimeException
|
||||
{
|
||||
|
||||
}
|
@ -1,7 +0,0 @@
|
||||
<?php
|
||||
namespace model;
|
||||
|
||||
use RuntimeException;
|
||||
|
||||
class ValidationException extends RuntimeException{
|
||||
}
|
@ -1,122 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace model;
|
||||
|
||||
use PDO;
|
||||
use PDOStatement;
|
||||
|
||||
class AdminGateway
|
||||
{
|
||||
private Connection $con;
|
||||
public function __construct(Connection $con)
|
||||
{
|
||||
$this->con=$con;
|
||||
}
|
||||
|
||||
public function login(string $email, string $password): bool
|
||||
{
|
||||
$sql = "SELECT * FROM Admin WHERE email=:email";
|
||||
$this->con->executeQuery($sql, array(
|
||||
':email' => array($email, PDO::PARAM_STR)
|
||||
));
|
||||
|
||||
$result = $this->con->getOneResult();
|
||||
|
||||
if (!empty($result)) {
|
||||
return password_verify($password,$result['password']);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
public function addUser(string $email, string $password): void
|
||||
{
|
||||
$sql = "INSERT INTO Admin (email, password) VALUES (:email, :password)";
|
||||
$stmt = $this->con->prepare($sql);
|
||||
$stmt->bindValue(':email', $email);
|
||||
$stmt->bindValue(':password', password_hash($password, PASSWORD_DEFAULT));
|
||||
$stmt->execute();
|
||||
}
|
||||
public function deleteUser(int $id): void
|
||||
{
|
||||
$sql = "DELETE FROM Admin WHERE id=:id";
|
||||
$stmt = $this->con->prepare($sql);
|
||||
$stmt->bindValue(':id', $id);
|
||||
$stmt->execute();
|
||||
}
|
||||
public function updateUser(int $id, string $email, string $password): void
|
||||
{
|
||||
$sql = "UPDATE Admin SET email=:email, password=:password WHERE id=:id";
|
||||
$stmt = $this->con->prepare($sql);
|
||||
$stmt->bindValue(':id', $id);
|
||||
$stmt->bindValue(':email', $email);
|
||||
$stmt->bindValue(':password', password_hash($password, PASSWORD_DEFAULT));
|
||||
$stmt->execute();
|
||||
}
|
||||
public function getUser(int $id): Admin
|
||||
{
|
||||
$sql = "SELECT * FROM Admin WHERE id=:id";
|
||||
$stmt = $this->con->prepare($sql);
|
||||
$stmt->bindValue(':id', $id);
|
||||
$stmt->execute();
|
||||
$result = $stmt->fetch();
|
||||
return new Admin($result['id'], $result['email'], $result['password']);
|
||||
}
|
||||
public function getUsers(): array
|
||||
{
|
||||
$sql = "SELECT * FROM Admin";
|
||||
$stmt = $this->con->prepare($sql);
|
||||
$stmt->execute();
|
||||
$result = $stmt->fetchAll();
|
||||
$users = [];
|
||||
foreach ($result as $user) {
|
||||
$users[] = new Admin($user['id'], $user['email'], $user['password']);
|
||||
}
|
||||
return $users;
|
||||
}
|
||||
public function getHashedPasswordById(int $id): string
|
||||
{
|
||||
$sql = "SELECT password FROM Admin WHERE id=:id";
|
||||
$stmt = $this->con->prepare($sql);
|
||||
$stmt->bindValue(':id', $id);
|
||||
$stmt->execute();
|
||||
$result = $stmt->fetch();
|
||||
return $result['password'];
|
||||
}
|
||||
public function getHashedPassword(int $email): string
|
||||
{
|
||||
$sql = "SELECT password FROM Admin WHERE email=:email";
|
||||
$stmt = $this->con->prepare($sql);
|
||||
$stmt->bindValue(':email', $email);
|
||||
$stmt->execute();
|
||||
$result = $stmt->fetch();
|
||||
return $result['password'];
|
||||
}
|
||||
|
||||
public function getUserId(string $email): int
|
||||
{
|
||||
$sql = "SELECT id FROM Admin WHERE email=:email";
|
||||
$stmt = $this->con->prepare($sql);
|
||||
$stmt->bindValue(':email', $email);
|
||||
$stmt->execute();
|
||||
$result = $stmt->fetch();
|
||||
return $result['id'];
|
||||
}
|
||||
public function getUserByEmailAndPassword(string $email, string $password): Admin
|
||||
{
|
||||
$sql = "SELECT * FROM Admin WHERE email=:email AND password=:password";
|
||||
$stmt = $this->con->prepare($sql);
|
||||
$stmt->bindValue(':email', $email);
|
||||
$stmt->bindValue(':password', password_hash($password, PASSWORD_DEFAULT));
|
||||
$stmt->execute();
|
||||
$result = $stmt->fetch();
|
||||
return new Admin($result['id'], $result['email'], $result['password']);
|
||||
}
|
||||
|
||||
public function getFromEmail(string $email): array
|
||||
{
|
||||
$this->con->executeQuery(
|
||||
"SELECT id, email, password FROM Admin WHERE email = :email;",
|
||||
[":pseudo" => [$email, $this->con::PARAM_STR]]
|
||||
);
|
||||
return $this->con->getOneResult();
|
||||
}
|
||||
}
|
@ -1,63 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace model;
|
||||
|
||||
use Exception;
|
||||
use PDO;
|
||||
use PDOException;
|
||||
use PDOStatement;
|
||||
|
||||
class Connection extends PDO {
|
||||
|
||||
private PDOStatement $stmt;
|
||||
|
||||
public function __construct(string $dsn, string $username, string $password) {
|
||||
try {
|
||||
parent::__construct($dsn, $username, $password);
|
||||
$this->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
||||
} catch (PDOException $e) {
|
||||
die("Connection failed: " . $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/** *
|
||||
* @param string $query
|
||||
* @param array $params
|
||||
* @return bool|null Returns `true` on success, `false` otherwise
|
||||
*/
|
||||
|
||||
/**
|
||||
* @param string $query
|
||||
* @param array $params
|
||||
* @return PDOStatement|false Returns `PDOStatement` on success, `false` otherwise
|
||||
* @throws Exception
|
||||
*/
|
||||
public function executeQuery(string $query, array $params = [])
|
||||
{
|
||||
try {
|
||||
$stmt = $this->prepare($query);
|
||||
|
||||
foreach ($params as $param => $value) {
|
||||
$stmt->bindValue($param, $value[0], $value[1]);
|
||||
}
|
||||
|
||||
$stmt->execute();
|
||||
$this->stmt = $stmt;
|
||||
|
||||
return $stmt;
|
||||
|
||||
} catch (PDOException $e) {
|
||||
throw new Exception($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public function getResults() : array {
|
||||
return $this->stmt->fetchall();
|
||||
}
|
||||
|
||||
public function getOneResult() {
|
||||
return $this->stmt->fetch();
|
||||
}
|
||||
|
||||
}
|
@ -1,24 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace model;
|
||||
|
||||
class DifficulteGateway
|
||||
{
|
||||
private Connection $con;
|
||||
|
||||
function __construct(Connection $con) {
|
||||
$this->con = $con;
|
||||
}
|
||||
public function getAll() : array
|
||||
{
|
||||
$this->con->executeQuery("SELECT id, libelle FROM Difficulte;");
|
||||
return $this->con->getResults();
|
||||
}
|
||||
|
||||
public function getFromId(int $id): array
|
||||
{
|
||||
$this->con->executeQuery("SELECT id, libelle FROM Difficulte WHERE id=:id;",
|
||||
[':id' => [$id, $this->con::PARAM_INT]]);
|
||||
return $this->con->getOneResult();
|
||||
}
|
||||
}
|
@ -1,20 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace model;
|
||||
|
||||
class IndiceGateway
|
||||
{
|
||||
|
||||
public function __construct(Connection $con)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public function getFromId(int $id) : array {
|
||||
|
||||
}
|
||||
|
||||
public function getFromScientifique(int $idScientifique) : array {
|
||||
|
||||
}
|
||||
}
|
@ -1,68 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace model;
|
||||
|
||||
class InviteGateway extends JoueurGateway
|
||||
{
|
||||
|
||||
function __construct(Connection $con) {
|
||||
parent::__construct($con);
|
||||
}
|
||||
|
||||
// public function getFromIdSession($idSession): array|bool // <- Seulement autorisé en PHP 8 /!\ (on est en 7.4)
|
||||
// {
|
||||
// $this->con->executeQuery("SELECT idJoueur, pseudo, idSession FROM Invite JOIN Joueur ON id=idJoueur WHERE idSession = :idSession;",
|
||||
// [":idSession" => [$idSession, $this->con::PARAM_STR]]);
|
||||
// return $this->con->getOneResult();
|
||||
// }
|
||||
|
||||
/**
|
||||
* @param string $idSession
|
||||
* @return array|bool
|
||||
*/
|
||||
public function getFromIdSession(string $idSession) { // <- PHP 7.4
|
||||
$this->con->executeQuery(
|
||||
"SELECT idJoueur, pseudo, idSession FROM Invite JOIN Joueur ON id=idJoueur WHERE idSession = :idSession;",
|
||||
[":idSession" => [$idSession, $this->con::PARAM_STR]]
|
||||
);
|
||||
return $this->con->getOneResult();
|
||||
}
|
||||
|
||||
|
||||
|
||||
// public function getFromId($id): array|bool // <- Seulement autorisé en PHP 8 /!\ (on est en 7.4)
|
||||
// {
|
||||
// $this->con->executeQuery("SELECT idJoueur, pseudo, idSession FROM Invite JOIN Joueur ON id=idJoueur WHERE id = :id;",
|
||||
// [":id" => [$id, $this->con::PARAM_INT]]);
|
||||
// return $this->con->getOneResult();
|
||||
// }
|
||||
|
||||
/**
|
||||
* @param int $id
|
||||
* @return array|bool
|
||||
*/
|
||||
public function getFromId(int $id) { // <- PHP 7.4
|
||||
$this->con->executeQuery(
|
||||
"SELECT idJoueur, pseudo, idSession FROM Invite JOIN Joueur ON id=idJoueur WHERE id = :id;",
|
||||
[":id" => [$id, $this->con::PARAM_INT]]
|
||||
);
|
||||
return $this->con->getOneResult();
|
||||
}
|
||||
|
||||
public function insertInvite(string $pseudo, string $idSession): int{
|
||||
$row = $this->getFromIdSession($idSession);
|
||||
if($row){
|
||||
throw new IdSessionDoubleException($row['idjoueur'], $row['idsession']);
|
||||
}else{
|
||||
$id = $this->insertJoueur($pseudo);
|
||||
$this->con->executeQuery("INSERT INTO Invite(idJoueur, idSession) VALUES(:id, :idSession);",
|
||||
[":id" => [$id, $this->con::PARAM_INT],
|
||||
":idSession" => [$idSession, $this->con::PARAM_STR]]);
|
||||
return $id;
|
||||
}
|
||||
}
|
||||
|
||||
public function supprimerInvite(int $id) : bool {
|
||||
|
||||
}
|
||||
}
|
@ -1,24 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace model;
|
||||
|
||||
class JeuGateway
|
||||
{
|
||||
private Connection $con;
|
||||
|
||||
function __construct(Connection $con) {
|
||||
$this->con = $con;
|
||||
}
|
||||
public function getAll() : array
|
||||
{
|
||||
$this->con->executeQuery("SELECT id, nom, nbrparties FROM Jeu;");
|
||||
return $this->con->getResults();
|
||||
}
|
||||
|
||||
public function getFromId(int $id): array
|
||||
{
|
||||
$this->con->executeQuery("SELECT id, nom, nbrparties FROM Jeu WHERE id=:id;",
|
||||
[':id' => [$id, $this->con::PARAM_INT]]);
|
||||
return $this->con->getOneResult();
|
||||
}
|
||||
}
|
@ -1,51 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace model;
|
||||
|
||||
class JoueurGateway
|
||||
{
|
||||
protected Connection $con;
|
||||
|
||||
function __construct(Connection $con) {
|
||||
$this->con = $con;
|
||||
}
|
||||
|
||||
// protected function getFromPseudo($pseudo): array|bool <- autorisé seulement en PHP 8
|
||||
// {
|
||||
// $this->con->executeQuery("SELECT id, pseudo FROM Joueur WHERE pseudo = :pseudo;",
|
||||
// [":pseudo" => [$pseudo, $this->con::PARAM_STR]]);
|
||||
// return $this->con->getOneResult();
|
||||
// }
|
||||
|
||||
/**
|
||||
* @param string $pseudo
|
||||
* @return array|bool
|
||||
*/
|
||||
public function getFromPseudo(string $pseudo) { // <- PHP 7.4
|
||||
$this->con->executeQuery(
|
||||
"SELECT id, pseudo FROM Joueur WHERE pseudo = :pseudo;",
|
||||
[":pseudo" => [$pseudo, $this->con::PARAM_STR]]
|
||||
);
|
||||
return $this->con->getOneResult();
|
||||
}
|
||||
|
||||
public function insertJoueur(string $pseudo): int{
|
||||
if($this->getFromPseudo($pseudo)){
|
||||
throw new PseudoDejaPrisException();
|
||||
}else{
|
||||
$this->con->executeQuery("INSERT INTO Joueur(pseudo) VALUES(:pseudo);",
|
||||
[":pseudo" => [$pseudo, $this->con::PARAM_STR]]);
|
||||
return $this->getFromPseudo($pseudo)["id"];
|
||||
}
|
||||
}
|
||||
|
||||
public function setPseudo(int $id, string $pseudo){
|
||||
if($this->getFromPseudo($pseudo)){
|
||||
throw new PseudoDejaPrisException();
|
||||
}else{
|
||||
$this->con->executeQuery("UPDATE Joueur SET pseudo=:pseudo WHERE id=:id",
|
||||
[":pseudo" => [$pseudo, $this->con::PARAM_STR],
|
||||
":id" => [$id, $this->con::PARAM_INT]]);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,31 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace model;
|
||||
|
||||
class PartieGateway
|
||||
{
|
||||
public function __construct(Connection $con)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public function getFromId(int $id) : Partie {
|
||||
|
||||
}
|
||||
|
||||
public function getFromCodeInvitation(string $code) : Partie {
|
||||
|
||||
}
|
||||
|
||||
public function creerPartie(Jeu $jeu, Joueur $joueur) : Partie {
|
||||
|
||||
}
|
||||
|
||||
public function rejoindrePartie(string $codeInvitation, Joueur $joueur) : bool {
|
||||
|
||||
}
|
||||
|
||||
public function supprimerPartie(int $id) : bool {
|
||||
|
||||
}
|
||||
}
|
@ -1,20 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace model;
|
||||
|
||||
class QuestionGateway
|
||||
{
|
||||
|
||||
public function __construct(Connection $con)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public function getRandom() : Question {
|
||||
|
||||
}
|
||||
|
||||
public function getFromId(int $id) : Question {
|
||||
|
||||
}
|
||||
}
|
@ -1,20 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace model;
|
||||
|
||||
class ReponseGateway
|
||||
{
|
||||
|
||||
public function __construct(Connection $con)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public function getFromId(int $id) : Reponse {
|
||||
|
||||
}
|
||||
|
||||
public function getFromQuestion(int $idQuestion) : array {
|
||||
|
||||
}
|
||||
}
|
@ -1,164 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace model;
|
||||
|
||||
use Exception;
|
||||
|
||||
class ScientifiqueGateway
|
||||
{
|
||||
private Connection $con;
|
||||
|
||||
function __construct(Connection $con) {
|
||||
$this->con = $con;
|
||||
}
|
||||
|
||||
public function getFromId(int $id) : array {
|
||||
|
||||
}
|
||||
|
||||
// public function getRandom(): array|bool{ <- autorisé seulement en PHP 8
|
||||
// $this->con->executeQuery(
|
||||
// "SELECT id, nom, prenom, photo, dateNaissance, descriptif, ratiotrouvee, idthematique, iddifficulte, index FROM Scientifique ORDER BY RANDOM() LIMIT 1;");
|
||||
// return $this->con->getOneResult();
|
||||
// }
|
||||
|
||||
/**
|
||||
* @return array|bool
|
||||
* @throws Exception
|
||||
*/
|
||||
public function getRandom() { // PHP 7.4
|
||||
$this->con->executeQuery(
|
||||
"SELECT id, nom, prenom, photo, dateNaissance, descriptif, ratiotrouvee, idthematique, iddifficulte, idsexe FROM Scientifique ORDER BY RANDOM() LIMIT 1;"
|
||||
);
|
||||
return $this->con->getOneResult();
|
||||
}
|
||||
|
||||
public function getRandomFromDifficulte(Difficulte $difficulte) : array {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws Exception
|
||||
*/
|
||||
public function addScientifique(Scientifique $sci): bool{
|
||||
return $this->con->executeQuery(
|
||||
"INSERT INTO Scientifique(nom, prenom, photo, dateNaissance, descriptif, ratioTrouvee, idThematique, idDifficulte, idSexe) VALUES (:nom, :prenom, :photo, :dateNaissance, :descriptif, :ratioTrouvee, :idThematique, :idDifficulte, :idSexe);"
|
||||
,[
|
||||
":nom"=>[$sci->getNom(),$this->con::PARAM_STR],
|
||||
":prenom"=>[$sci->getPrenom(),$this->con::PARAM_STR],
|
||||
":photo"=>[$sci->getPhoto(),$this->con::PARAM_STR],
|
||||
":dateNaissance"=>[date("Y-m-d H:i:s", $sci->getDateNaiss()->getTimestamp()),$this->con::PARAM_STR],
|
||||
":descriptif"=>[$sci->getDescriptif(),$this->con::PARAM_STR],
|
||||
":ratioTrouvee"=>[$sci->getRatioTrouvee(),$this->con::PARAM_STR],
|
||||
":idThematique"=>[$sci->getThematique()->getId(),$this->con::PARAM_STR],
|
||||
":idDifficulte"=>[$sci->getDifficulte()->getId(),$this->con::PARAM_STR],
|
||||
":idSexe"=>[$sci->getSexe()->getId(),$this->con::PARAM_STR]
|
||||
]) ? true : false ;
|
||||
}
|
||||
|
||||
public function getScientifiquesParPages(int $currentPage, int $nbElemByPage) : array {
|
||||
$query = 'SELECT * FROM Scientifique LIMIT :nbElem OFFSET :ind ';
|
||||
$index = ($currentPage-1)*$nbElemByPage;
|
||||
$this->con->executeQuery($query,array(
|
||||
':ind' => array($index,\PDO::PARAM_INT),
|
||||
':nbElem' => array($nbElemByPage,\PDO::PARAM_INT)
|
||||
));
|
||||
return $this->con->getResults();
|
||||
}
|
||||
|
||||
public function getHistorique(string $pseudoJoueur, int $currentPage, int $nbElemByPage) : array {
|
||||
if($currentPage == 0) $currentPage = 1;
|
||||
|
||||
$query = 'SELECT s.*
|
||||
FROM Scientifique s, Decouvrir d, Utilisateur u
|
||||
WHERE s.id = d.idscientifique
|
||||
AND d.idutilisateur = u.idJoueur
|
||||
AND u.email = :pseudo
|
||||
LIMIT :nbElem OFFSET :ind ';
|
||||
$index = ($currentPage-1)*$nbElemByPage;
|
||||
$this->con->executeQuery($query,array(
|
||||
':ind' => array($index,\PDO::PARAM_INT),
|
||||
':nbElem' => array($nbElemByPage,\PDO::PARAM_INT),
|
||||
':pseudo' => array($pseudoJoueur,\PDO::PARAM_STR)
|
||||
));
|
||||
return $this->con->getResults();
|
||||
}
|
||||
|
||||
public function getNbScientifique() : int {
|
||||
$query = 'SELECT DISTINCT count(*) as val FROM Scientifique';
|
||||
$this->con->executeQuery($query);
|
||||
return $this->con->getResults()[0]['val'];
|
||||
}
|
||||
|
||||
public function getNbScientifiqueHistorique(string $pseudoJoueur) : int {
|
||||
$query = 'SELECT count(*) as val
|
||||
FROM Scientifique s, Decouvrir d, Utilisateur u
|
||||
WHERE s.id = d.idscientifique
|
||||
AND d.idutilisateur = u.idJoueur
|
||||
AND u.email = :pseudo';
|
||||
$params = array(
|
||||
':pseudo' => array($pseudoJoueur,\PDO::PARAM_STR)
|
||||
);
|
||||
$this->con->executeQuery($query,$params);
|
||||
return $this->con->getResults()[0]['val'];
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws Exception
|
||||
*/
|
||||
public function editScientifique(Scientifique $sci): bool{
|
||||
return $this->con->executeQuery(
|
||||
"UPDATE Scientifique SET nom = :nom, prenom = :prenom, photo = :photo, dateNaissance = :dateNaissance, descriptif = :descriptif, ratioTrouvee = :ratioTrouvee, idThematique = :idThematique, idDifficulte = :idDifficulte, idSexe = :idSexe WHERE id=:id;"
|
||||
,[
|
||||
":nom"=>[$sci->getNom(),$this->con::PARAM_STR],
|
||||
":prenom"=>[$sci->getPrenom(),$this->con::PARAM_STR],
|
||||
":photo"=>[$sci->getPhoto(),$this->con::PARAM_STR],
|
||||
":dateNaissance"=>[date("Y-m-d H:i:s", $sci->getDateNaiss()->getTimestamp()),$this->con::PARAM_STR],
|
||||
":descriptif"=>[$sci->getDescriptif(),$this->con::PARAM_STR],
|
||||
":ratioTrouvee"=>[$sci->getRatioTrouvee(),$this->con::PARAM_STR],
|
||||
":idThematique"=>[$sci->getThematique()->getId(),$this->con::PARAM_STR],
|
||||
":idDifficulte"=>[$sci->getDifficulte()->getId(),$this->con::PARAM_STR],
|
||||
":idSexe"=>[$sci->getSexe()->getId(),$this->con::PARAM_STR],
|
||||
":id"=>[$sci->getId(),$this->con::PARAM_INT]
|
||||
]) ? true : false ;
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws Exception
|
||||
*/
|
||||
public function deleteScientifique(int $id): bool{
|
||||
return $this->con->executeQuery(
|
||||
"DELETE FROM Scientifique WHERE id=:id;"
|
||||
,[
|
||||
":id"=>[$id,$this->con::PARAM_INT]
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws Exception
|
||||
*/
|
||||
public function getScientifique(int $id) {
|
||||
$this->con->executeQuery(
|
||||
"SELECT id, nom, prenom, photo, dateNaissance, descriptif, ratioTrouvee, idThematique, idDifficulte, idSexe FROM Scientifique WHERE id=:id;"
|
||||
,[
|
||||
":id"=>[$id,$this->con::PARAM_INT]
|
||||
]);
|
||||
return $this->con->getOneResult();
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws Exception
|
||||
*/
|
||||
public function getQuestions(int $idScientifique): array
|
||||
{
|
||||
$query = "SELECT q.* FROM Question q
|
||||
JOIN Reponse r ON q.id = r.idQuestion
|
||||
WHERE r.idScientifique = :idScientifique
|
||||
ORDER BY RANDOM() LIMIT 5";
|
||||
$params = [":idScientifique" => [$idScientifique, $this->con::PARAM_INT]];
|
||||
|
||||
$this->con->executeQuery($query, $params);
|
||||
|
||||
return $this->con->getResults();
|
||||
}
|
||||
}
|
@ -1,29 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace model;
|
||||
|
||||
class SexeGateway
|
||||
{
|
||||
private Connection $con;
|
||||
|
||||
function __construct(Connection $con) {
|
||||
$this->con = $con;
|
||||
}
|
||||
|
||||
public function getFromId(int $id): array
|
||||
{
|
||||
$this->con->executeQuery("SELECT id, libelle FROM Sexe WHERE id=:id;",
|
||||
[':id' => [$id, $this->con::PARAM_INT]]);
|
||||
return $this->con->getOneResult();
|
||||
}
|
||||
|
||||
public function getAll(): array
|
||||
{
|
||||
$this->con->executeQuery("SELECT id, libelle FROM Sexe;");
|
||||
return $this->con->getResults();
|
||||
}
|
||||
|
||||
public function getFromScientifique(int $idScientifique) : array {
|
||||
|
||||
}
|
||||
}
|
@ -1,28 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace model;
|
||||
|
||||
class ThematiqueGateway
|
||||
{
|
||||
private Connection $con;
|
||||
|
||||
function __construct(Connection $con) {
|
||||
$this->con = $con;
|
||||
}
|
||||
|
||||
public function getFromId(int $id): array
|
||||
{
|
||||
$this->con->executeQuery("SELECT id, libelle FROM Thematique WHERE id=:id;",
|
||||
[':id' => [$id, $this->con::PARAM_INT]]);
|
||||
return $this->con->getOneResult();
|
||||
}
|
||||
public function getAll(): array
|
||||
{
|
||||
$this->con->executeQuery("SELECT id, libelle FROM Thematique;");
|
||||
return $this->con->getResults();
|
||||
}
|
||||
|
||||
public function getFromScientifique(int $idScientifique) : array {
|
||||
|
||||
}
|
||||
}
|
@ -1,59 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace model;
|
||||
|
||||
class UtilisateurConnecteGateway extends JoueurGateway {
|
||||
|
||||
function __construct(Connection $con) {
|
||||
$this->con = $con;
|
||||
}
|
||||
|
||||
public function login(string $email, string $password): bool
|
||||
{
|
||||
$sql = "SELECT * FROM Utilisateur WHERE email=:email";
|
||||
$this->con->executeQuery($sql, array(
|
||||
':email' => array($email, \PDO::PARAM_STR)
|
||||
));
|
||||
|
||||
$result = $this->con->getOneResult();
|
||||
|
||||
if (!empty($result)) {
|
||||
return password_verify($password,$result['password']);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
public function register(string $email, string $password, int $idjoueur): bool
|
||||
{
|
||||
$sql = "INSERT INTO Utilisateur(email, password,idjoueur) VALUES (:email,:password,:idjoueur);";
|
||||
return $this->con->executeQuery($sql, [
|
||||
':email' => array($email, \PDO::PARAM_STR),
|
||||
':password' => array(password_hash($password, PASSWORD_BCRYPT), \PDO::PARAM_STR),
|
||||
':idjoueur' => array($idjoueur, \PDO::PARAM_INT)
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
public function getFromId(int $id){
|
||||
$this->con->executeQuery(
|
||||
"SELECT idJoueur, pseudo, email, password FROM Utilisateur JOIN Joueur ON id=idJoueur WHERE id = :id;",
|
||||
[":id" => [$id, $this->con::PARAM_INT]]
|
||||
);
|
||||
return $this->con->getOneResult();
|
||||
}
|
||||
|
||||
public function getFromEmail(string $email){
|
||||
$this->con->executeQuery(
|
||||
"SELECT idJoueur, pseudo, email, password FROM Utilisateur JOIN Joueur ON id=idJoueur WHERE email = :email;",
|
||||
[":email" => [$email, $this->con::PARAM_STR]]
|
||||
);
|
||||
return $this->con->getOneResult();
|
||||
}
|
||||
|
||||
public function addScientifiqueDecouvert(int $idUtilisateur, int $idScientifique){
|
||||
$this->con->executeQuery(
|
||||
"INSERT INTO Decouvrir(idUtilisateur, idScientifique) VALUES (:idUtilisateur, :idScientifique);",
|
||||
[":idUtilisateur" => [$idUtilisateur, $this->con::PARAM_INT],
|
||||
":idScientifique" => [$idScientifique, $this->con::PARAM_INT]]
|
||||
);
|
||||
}
|
||||
}
|
@ -1,46 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace model;
|
||||
|
||||
class MdlAdmin extends MdlBase{
|
||||
private AdminGateway $gw;
|
||||
|
||||
public function __construct(){
|
||||
parent::__construct();
|
||||
$this->gw = new AdminGateway($this->con);
|
||||
}
|
||||
public function login(string $username, string $password): bool{
|
||||
if ($this->gw->login($username, $password)) {
|
||||
$_SESSION['pseudo'] = $username;
|
||||
$_SESSION['admin'] = true;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static function isAdmin(): bool
|
||||
{
|
||||
if(!isset($_SESSION['admin'])
|
||||
|| !$_SESSION['admin']
|
||||
|| !isset($_SESSION['pseudo'])
|
||||
|| $_SESSION['pseudo'] == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public static function logout() {
|
||||
global $basePath;
|
||||
|
||||
session_unset();
|
||||
session_destroy();
|
||||
$_SESSION = array();
|
||||
header("Location: .");
|
||||
}
|
||||
|
||||
public function getFromEmail(string $email): Admin{
|
||||
$row = $this->gw->getFromEmail($email);
|
||||
return new Admin($row['id'], $row['email'], $row['password']);
|
||||
}
|
||||
}
|
@ -1,13 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace model;
|
||||
|
||||
abstract class MdlBase{
|
||||
protected Connection $con;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
global $config;
|
||||
$this->con = new Connection($config["db"]["dsn"], $config["db"]["login"], $config["db"]["mdp"]);
|
||||
}
|
||||
}
|
@ -1,25 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace model;
|
||||
|
||||
class MdlDifficulte extends MdlBase{
|
||||
private DifficulteGateway $gw;
|
||||
|
||||
public function __construct(){
|
||||
parent::__construct();
|
||||
$this->gw = new DifficulteGateway($this->con);
|
||||
}
|
||||
|
||||
public function getAll(): array{
|
||||
$listDifficulte = [];
|
||||
foreach($this->gw->getAll() as $row){
|
||||
$listDifficulte[] = new Difficulte($row['id'], $row['libelle']);
|
||||
}
|
||||
return $listDifficulte;
|
||||
}
|
||||
|
||||
public function getFromId(int $id): Difficulte{
|
||||
$row = $this->gw->getFromId($id);
|
||||
return new Difficulte($row['id'], $row['libelle']);
|
||||
}
|
||||
}
|
@ -1,27 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace model;
|
||||
|
||||
class MdlInvite extends MdlBase{
|
||||
private InviteGateway $gw;
|
||||
|
||||
public function __construct(){
|
||||
parent::__construct();
|
||||
$this->gw = new InviteGateway($this->con);
|
||||
}
|
||||
|
||||
public function setPseudo(int $id, string $pseudo): Invite{
|
||||
$this->gw->setPseudo($id, $pseudo);
|
||||
return $this->getFromId($id);
|
||||
}
|
||||
|
||||
public function insertInvite(string $pseudo, string $idSession): Invite{
|
||||
$id = $this->gw->insertInvite($pseudo, $idSession);
|
||||
return $this->getFromId($id);
|
||||
}
|
||||
|
||||
public function getFromId(int $id): Invite{
|
||||
$row = $this->gw->getFromId($id);
|
||||
return new Invite($row['idjoueur'], $row['pseudo'], $row['idsession']);
|
||||
}
|
||||
}
|
@ -1,25 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace model;
|
||||
|
||||
class MdlJeu extends MdlBase{
|
||||
private JeuGateway $gw;
|
||||
|
||||
public function __construct(){
|
||||
parent::__construct();
|
||||
$this->gw = new JeuGateway($this->con);
|
||||
}
|
||||
|
||||
public function getAll(): array{
|
||||
$listJeu = [];
|
||||
foreach($this->gw->getAll() as $row){
|
||||
$listJeu[] = new Jeu($row['id'], $row['nom'], $row['nbrparties']);
|
||||
}
|
||||
return $listJeu;
|
||||
}
|
||||
|
||||
public function getFromId(int $id): Jeu{
|
||||
$row = $this->gw->getFromId($id);
|
||||
return new Jeu($row['id'], $row['nom'], $row['nbrparties']);
|
||||
}
|
||||
}
|
@ -1,91 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace model;
|
||||
|
||||
class MdlPendu{
|
||||
private Scientifique $scientifiqueATrouver;
|
||||
private string $aTrouver;
|
||||
private int $nbFail;
|
||||
private int $nbTours;
|
||||
private array $lettreExceptees;
|
||||
private array $lettreUtilisees;
|
||||
|
||||
private static int $nbFailsMax = 8;
|
||||
|
||||
public function __construct(Scientifique $scientifiqueATrouver){
|
||||
$this->scientifiqueATrouver = $scientifiqueATrouver;
|
||||
$this->aTrouver = iconv('UTF-8', 'ASCII//TRANSLIT', $scientifiqueATrouver->getPrenom()." ".$scientifiqueATrouver->getNom()); #suppression des accents
|
||||
$this->aTrouver = preg_replace('/[^A-Za-z0-9 ]/', '', $this->aTrouver); // Retire les caractères non-alphanumeric
|
||||
$this->nbFail = 0;
|
||||
$this->nbTours = 0;
|
||||
$this->lettreExceptees = [' ', '-'];
|
||||
$this->lettreUtilisees = [];
|
||||
}
|
||||
|
||||
public function jouerLettre(string $lettre): string{
|
||||
$lettre = strtolower($lettre);
|
||||
if(strlen($lettre) != 1){ throw new ValidationException("Veuillez fournir une seule lettre");}
|
||||
if(!ctype_alpha($lettre)){ throw new ValidationException("Veuillez fournir un caractère alphabétique");}
|
||||
if(in_array($lettre, $this->lettreUtilisees)){ throw new ValidationException("Vous avez déjà joué cette lettre");}
|
||||
$this->nbTours += 1;
|
||||
|
||||
// if(!str_contains($this->aTrouver, $lettre)){ // UNIQUEMENT EN PHP 8.0
|
||||
// $this->nbFail += 1;
|
||||
// }
|
||||
|
||||
if (strpos($this->aTrouver, $lettre) === false) { // PHP 7.4
|
||||
$this->nbFail += 1;
|
||||
}
|
||||
|
||||
$this->lettreUtilisees[] = $lettre;
|
||||
return $this->getDecouvert();
|
||||
}
|
||||
|
||||
public function getScientifique(): Scientifique
|
||||
{
|
||||
return $this->scientifiqueATrouver;
|
||||
}
|
||||
|
||||
public function getLettreUtilisees(): array{
|
||||
return $this->lettreUtilisees;
|
||||
}
|
||||
|
||||
public function getATrouver(): string
|
||||
{
|
||||
return $this->aTrouver;
|
||||
}
|
||||
|
||||
public function getDecouvert(): string
|
||||
{
|
||||
$decouvert = '';
|
||||
foreach(str_split($this->aTrouver) as $lettre){
|
||||
if(in_array(strtolower($lettre), $this->lettreUtilisees) || in_array(strtolower($lettre), $this->lettreExceptees)){
|
||||
$decouvert.=$lettre;
|
||||
}else{
|
||||
$decouvert.="_";
|
||||
}
|
||||
}
|
||||
return $decouvert;
|
||||
}
|
||||
|
||||
public function getNbTours():int{
|
||||
return $this->nbTours;
|
||||
}
|
||||
|
||||
public function getNbFails():int{
|
||||
return $this->nbFail;
|
||||
}
|
||||
|
||||
public function getEssaisRestant():int{
|
||||
return $this::$nbFailsMax - $this->nbFail;
|
||||
}
|
||||
|
||||
public function aGagne(): bool{
|
||||
return $this->getDecouvert() == $this->getATrouver();
|
||||
}
|
||||
|
||||
public function aPerdu(): bool{
|
||||
return $this->getEssaisRestant() <= 0;
|
||||
}
|
||||
|
||||
}
|
@ -1,108 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace model;
|
||||
|
||||
|
||||
|
||||
use Exception;
|
||||
|
||||
class MdlScienceQuizz
|
||||
{
|
||||
private int $bonneReponse;
|
||||
private string $nbPoints;
|
||||
private int $numQuestion;
|
||||
private array $reponses;
|
||||
private array $questions;
|
||||
private array $questionsPass;
|
||||
private bool $partieTerminee;
|
||||
|
||||
private int $scientifique;
|
||||
|
||||
public function __construct(int $scientifique, array $questions)
|
||||
{
|
||||
$this->bonneReponse = 0;
|
||||
$this->nbPoints = 0;
|
||||
$this->numQuestion = 0;
|
||||
$this->reponses = [];
|
||||
$this->scientifique = $scientifique;
|
||||
$this->questions = $questions;
|
||||
$this->questionsPass = [];
|
||||
$this->partieTerminee = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getQuestions(): array
|
||||
{
|
||||
return $this->questions;
|
||||
}
|
||||
|
||||
public function getScientifique(): int
|
||||
{
|
||||
return $this->scientifique;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getBonneReponse(): int
|
||||
{
|
||||
return $this->bonneReponse;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getNbPoints(): string
|
||||
{
|
||||
return $this->nbPoints;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getNumQuestion(): int
|
||||
{
|
||||
return $this->numQuestion;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getReponses(): array
|
||||
{
|
||||
return $this->reponses;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $bonneReponse
|
||||
*/
|
||||
public function setBonneReponse(int $bonneReponse): void
|
||||
{
|
||||
$this->bonneReponse = $bonneReponse;
|
||||
}
|
||||
|
||||
// Sélectionne une question aléatoire
|
||||
|
||||
/**
|
||||
* @throws Exception
|
||||
*/
|
||||
public function getRandomQuestion(array $questions): string
|
||||
{
|
||||
$randomNum=random_int(0, count($questions)-1);
|
||||
$question=$questions[$randomNum];
|
||||
$this->questionsPass[]=$question;
|
||||
if (count($this->questionsPass)==count($questions))
|
||||
{
|
||||
$this->partieTerminee=true;
|
||||
}
|
||||
return $question;
|
||||
}
|
||||
|
||||
public function partieTerminee(): bool
|
||||
{
|
||||
return $this->partieTerminee;
|
||||
}
|
||||
|
||||
}
|
@ -1,172 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace model;
|
||||
|
||||
use DateTime;
|
||||
use Exception;
|
||||
use RuntimeException;
|
||||
|
||||
class MdlScientifique extends MdlBase{
|
||||
private ScientifiqueGateway $gw;
|
||||
private MdlSexe $mdlSexe;
|
||||
private MdlDifficulte $mdlDifficulte;
|
||||
private MdlThematique $mdlThematique;
|
||||
|
||||
public function __construct(){
|
||||
parent::__construct();
|
||||
$this->gw = new ScientifiqueGateway($this->con);
|
||||
$this->mdlSexe = new MdlSexe();
|
||||
$this->mdlDifficulte = new MdlDifficulte();
|
||||
$this->mdlThematique = new MdlThematique();
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws Exception
|
||||
*/
|
||||
public function getRandom(): Scientifique{
|
||||
$row = $this->gw->getRandom();
|
||||
if(!$row) throw new RuntimeException("Erreur aucun scientifique trouvé");
|
||||
$sexe = $this->mdlSexe->getFromId($row['idsexe']);
|
||||
$difficulte = $this->mdlDifficulte->getFromId($row['iddifficulte']);
|
||||
$thematique = $this->mdlThematique->getFromId($row['idthematique']);
|
||||
|
||||
return new Scientifique($row['id'],
|
||||
$row['nom'],
|
||||
$row['prenom'],
|
||||
$row['photo'],
|
||||
new DateTime($row['datenaissance']),
|
||||
$row['descriptif'],
|
||||
$row['ratiotrouvee'],
|
||||
$thematique,
|
||||
$difficulte,
|
||||
$sexe);
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws Exception
|
||||
*/
|
||||
public function addScientifique(Scientifique $s): bool
|
||||
{
|
||||
return $this->gw->addScientifique($s);
|
||||
}
|
||||
|
||||
public function getScientifiquesParPage(int $page) : array {
|
||||
$nbElemParPage = 20;
|
||||
$pageMax = ceil($this->gw->getNbScientifique()/$nbElemParPage);
|
||||
if ($page <= 0) {
|
||||
$page = 1;
|
||||
} elseif ($page > $pageMax) {
|
||||
$page = $pageMax;
|
||||
}
|
||||
$result = $this->gw->getScientifiquesParPages($page,$nbElemParPage);
|
||||
$scientifiques = array();
|
||||
foreach ($result as $scientifique) {
|
||||
$sexe = $this->mdlSexe->getFromId($scientifique['idsexe']);
|
||||
$difficulte = $this->mdlDifficulte->getFromId($scientifique['iddifficulte']);
|
||||
$thematique = $this->mdlThematique->getFromId($scientifique['idthematique']);
|
||||
$scientifiques[] = new Scientifique($scientifique['id'],
|
||||
$scientifique['nom'],
|
||||
$scientifique['prenom'],
|
||||
$scientifique['photo'],
|
||||
new DateTime($scientifique['datenaissance']),
|
||||
$scientifique['descriptif'],
|
||||
$scientifique['ratiotrouvee'],
|
||||
$thematique,
|
||||
$difficulte,
|
||||
$sexe);
|
||||
}
|
||||
return $scientifiques;
|
||||
}
|
||||
public function getHistoriqueParPage(string $pseudoJoueur,int $page) {
|
||||
$nbElemParPage = 20;
|
||||
$pageMax = ceil($this->gw->getNbScientifiqueHistorique($pseudoJoueur)/$nbElemParPage);
|
||||
|
||||
if ($page <= 0) {
|
||||
$page = 1;
|
||||
} elseif ($page > $pageMax) {
|
||||
$page = $pageMax;
|
||||
}
|
||||
$result = $this->gw->getHistorique($pseudoJoueur,$page,$nbElemParPage);
|
||||
$scientifiques = array();
|
||||
foreach ($result as $scientifique) {
|
||||
$sexe = $this->mdlSexe->getFromId($scientifique['idsexe']);
|
||||
$difficulte = $this->mdlDifficulte->getFromId($scientifique['iddifficulte']);
|
||||
$thematique = $this->mdlThematique->getFromId($scientifique['idthematique']);
|
||||
$scientifiques[] = new Scientifique($scientifique['id'],
|
||||
$scientifique['nom'],
|
||||
$scientifique['prenom'],
|
||||
$scientifique['photo'],
|
||||
new DateTime($scientifique['datenaissance']),
|
||||
$scientifique['descriptif'],
|
||||
$scientifique['ratiotrouvee'],
|
||||
$thematique,
|
||||
$difficulte,
|
||||
$sexe);
|
||||
}
|
||||
return $scientifiques;
|
||||
}
|
||||
public function getMaxPages() : int {
|
||||
$nbElemParPage = 20;
|
||||
return ceil($this->gw->getNbScientifique()/$nbElemParPage);
|
||||
}
|
||||
public function getMaxPagesHistorique(string $pseudo) : int {
|
||||
$nbElemParPage = 20;
|
||||
return ceil($this->gw->getNbScientifiqueHistorique($pseudo)/$nbElemParPage);
|
||||
}
|
||||
|
||||
public function editScientifique(Scientifique $s){
|
||||
return $this->gw->editScientifique($s);
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws Exception
|
||||
*/
|
||||
public function getScientifique(int $id): Scientifique
|
||||
{
|
||||
$t=$this->gw->getScientifique($id);
|
||||
if(gettype($t)!="array"){
|
||||
throw new Exception("Scientifique non trouvé");
|
||||
}
|
||||
|
||||
$sexe=new MdlSexe();
|
||||
$sexe=$sexe->getFromId($t["idsexe"]);
|
||||
|
||||
$diff=new MdlDifficulte();
|
||||
$diff=$diff->getFromId($t["iddifficulte"]);
|
||||
|
||||
$theme=new MdlThematique();
|
||||
$theme=$theme->getFromId($t["idthematique"]);
|
||||
|
||||
return new Scientifique(
|
||||
$id,
|
||||
$t["nom"],
|
||||
$t["prenom"],
|
||||
$t["photo"],
|
||||
DateTime::createFromFormat("Y-m-d", $t["datenaissance"]),
|
||||
$t["descriptif"],
|
||||
$t["ratiotrouvee"],
|
||||
$theme,
|
||||
$diff,
|
||||
$sexe
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws Exception
|
||||
*/
|
||||
public function getQuestions(int $id): array
|
||||
{
|
||||
$t = $this->gw->getQuestions($id);
|
||||
|
||||
if (gettype($t) != "array") {
|
||||
throw new Exception("Scientifique non trouvé");
|
||||
}
|
||||
|
||||
$questions = [];
|
||||
|
||||
foreach ($t as $question) {
|
||||
$questions[] = $question["question"];
|
||||
}
|
||||
return $questions;
|
||||
}
|
||||
}
|
@ -1,25 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace model;
|
||||
|
||||
class MdlSexe extends MdlBase{
|
||||
private SexeGateway $gw;
|
||||
|
||||
public function __construct(){
|
||||
parent::__construct();
|
||||
$this->gw = new SexeGateway($this->con);
|
||||
}
|
||||
|
||||
public function getFromId(int $id): Sexe{
|
||||
$row = $this->gw->getFromId($id);
|
||||
return new Sexe($row['id'], $row['libelle']);
|
||||
}
|
||||
public function getAll(): array {
|
||||
$ret=array();
|
||||
$row = $this->gw->getAll();
|
||||
for($i=0; $i< count($row); $i++){
|
||||
array_push($ret, new Sexe($row[$i]['id'], $row[$i]['libelle']));
|
||||
}
|
||||
return $ret;
|
||||
}
|
||||
}
|
@ -1,26 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace model;
|
||||
|
||||
class MdlThematique extends MdlBase{
|
||||
private ThematiqueGateway $gw;
|
||||
|
||||
public function __construct(){
|
||||
parent::__construct();
|
||||
$this->gw = new ThematiqueGateway($this->con);
|
||||
}
|
||||
|
||||
public function getFromId(int $id): Thematique{
|
||||
$row = $this->gw->getFromId($id);
|
||||
return new Thematique($row['id'], $row['libelle']);
|
||||
}
|
||||
|
||||
public function getAll(): array {
|
||||
$ret=array();
|
||||
$row = $this->gw->getAll();
|
||||
for($i=0; $i< count($row); $i++){
|
||||
array_push($ret, new Thematique($row[$i]['id'], $row[$i]['libelle']));
|
||||
}
|
||||
return $ret;
|
||||
}
|
||||
}
|
@ -1,39 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace model;
|
||||
|
||||
class MdlUser extends MdlBase{
|
||||
private UtilisateurConnecteGateway $gw;
|
||||
|
||||
public function __construct(){
|
||||
parent::__construct();
|
||||
$this->gw = new UtilisateurConnecteGateway($this->con);
|
||||
}
|
||||
public function login(string $username, string $password): bool{
|
||||
return $this->gw->login($username, $password);
|
||||
}
|
||||
public function register(string $username, string $password): bool{
|
||||
$temp = new JoueurGateway($this->con);
|
||||
$temp->insertJoueur($username);
|
||||
return $this->gw->register($username, $password, $temp->getFromPseudo($username)["id"]);
|
||||
}
|
||||
|
||||
public function setPseudo(int $id, string $pseudo): Utilisateur{
|
||||
$this->gw->setPseudo($id, $pseudo);
|
||||
return $this->getFromId($id);
|
||||
}
|
||||
|
||||
public function getFromId(int $id): Utilisateur{
|
||||
$row = $this->gw->getFromId($id);
|
||||
return new Utilisateur($row['idjoueur'], $row['pseudo'], $row['email'], $row['password']);
|
||||
}
|
||||
|
||||
public function getFromEmail(string $email): Utilisateur{
|
||||
$row = $this->gw->getFromEmail($email);
|
||||
return new Utilisateur($row['idjoueur'], $row['pseudo'], $row['email'], $row['password']);
|
||||
}
|
||||
|
||||
public function addScientifiqueDecouvert(int $idUtilisateur, int $idScientifique){
|
||||
$this->gw->addScientifiqueDecouvert($idUtilisateur, $idScientifique);
|
||||
}
|
||||
}
|
@ -1,47 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace model;
|
||||
|
||||
class Admin
|
||||
{
|
||||
private int $id;
|
||||
private string $email;
|
||||
private string $password;
|
||||
|
||||
/**
|
||||
* @param int $id
|
||||
* @param string $password
|
||||
* @param string $email
|
||||
*/
|
||||
public function __construct(int $id, string $email, string $password)
|
||||
{
|
||||
$this->id=$id;
|
||||
$this->password=$password;
|
||||
$this->email = $email;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getEmail(): string
|
||||
{
|
||||
return $this->email;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getId(): int
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getPassword(): string
|
||||
{
|
||||
return $this->password;
|
||||
}
|
||||
|
||||
}
|
@ -1,21 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace model;
|
||||
|
||||
class ConfigurationJeu{
|
||||
private Difficulte $difficulte;
|
||||
private Jeu $jeu;
|
||||
|
||||
public function __construct(Jeu $jeu, Difficulte $difficulte){
|
||||
$this->jeu = $jeu;
|
||||
$this->difficulte = $difficulte;
|
||||
}
|
||||
|
||||
public function getDifficulte(): Difficulte{
|
||||
return $this->difficulte;
|
||||
}
|
||||
|
||||
public function getJeu(): Jeu{
|
||||
return $this->jeu;
|
||||
}
|
||||
}
|
@ -1,37 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace model;
|
||||
|
||||
class Difficulte
|
||||
{
|
||||
private int $id;
|
||||
private string $libelle;
|
||||
|
||||
/**
|
||||
* @param int $id
|
||||
* @param string $libelle
|
||||
*/
|
||||
public function __construct(int $id, string $libelle)
|
||||
{
|
||||
$this->id=$id;
|
||||
$this->libelle=$libelle;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getId(): int{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getLibelle(): string{
|
||||
return $this->libelle;
|
||||
}
|
||||
|
||||
public function __toString() {
|
||||
return $this->libelle;
|
||||
}
|
||||
}
|
@ -1,18 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace model;
|
||||
|
||||
class Invite extends Joueur{
|
||||
private string $idSession;
|
||||
|
||||
public function __construct(int $id, string $pseudo, string $idSession)
|
||||
{
|
||||
parent::__construct($id,$pseudo);
|
||||
$this->idSession = $idSession;
|
||||
}
|
||||
|
||||
public function getIdSession(): string
|
||||
{
|
||||
return $this->idSession;
|
||||
}
|
||||
}
|
@ -1,51 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace model;
|
||||
|
||||
class Jeu
|
||||
{
|
||||
private int $id;
|
||||
private string $nom;
|
||||
private int $nbrParties;
|
||||
|
||||
/**
|
||||
* @param int $id
|
||||
* @param string $nom
|
||||
* @param int $nbrParties
|
||||
*/
|
||||
public function __construct(int $id, string $nom, int $nbrParties)
|
||||
{
|
||||
$this->id=$id;
|
||||
$this->nom=$nom;
|
||||
$this->nbrParties=$nbrParties;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getId(): int{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getNom(): string{
|
||||
return $this->nom;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getNbParties():int{
|
||||
return $this->nbrParties;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function incrementNbParties(): int{
|
||||
$this->nbrParties += 1;
|
||||
return $this->nbrParties;
|
||||
}
|
||||
}
|
@ -1,24 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace model;
|
||||
|
||||
|
||||
abstract class Joueur{
|
||||
private int $id;
|
||||
private string $pseudo;
|
||||
|
||||
public function __construct(int $id, string $pseudo){
|
||||
$this->id=$id;
|
||||
$this->pseudo=$pseudo;
|
||||
}
|
||||
|
||||
public function getId(): int
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function getPseudo(): String
|
||||
{
|
||||
return $this->pseudo;
|
||||
}
|
||||
}
|
@ -1,138 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace model;
|
||||
|
||||
use DateTime;
|
||||
|
||||
class Scientifique
|
||||
{
|
||||
private int $id;
|
||||
private string $nom;
|
||||
private string $prenom;
|
||||
private string $photo;
|
||||
private DateTime $dateNaiss;
|
||||
private string $descriptif;
|
||||
private float $ratioTrouvee;
|
||||
private Thematique $thematique;
|
||||
private Difficulte $difficulte;
|
||||
private Sexe $sexe;
|
||||
private array $questions;
|
||||
|
||||
/**
|
||||
* @param int $id
|
||||
* @param string $nom
|
||||
* @param string $prenom
|
||||
* @param string $photo
|
||||
* @param DateTime $dateNaiss
|
||||
* @param string $descriptif
|
||||
* @param float $ratioTrouvee
|
||||
* @param Thematique $thematique
|
||||
* @param Difficulte $difficulte
|
||||
* @param Sexe $sexe
|
||||
* @param array $questions
|
||||
*/
|
||||
public function __construct(int $id,
|
||||
string $nom,
|
||||
string $prenom,
|
||||
string $photo,
|
||||
DateTime $dateNaiss,
|
||||
string $descriptif,
|
||||
float $ratioTrouvee,
|
||||
Thematique $thematique,
|
||||
Difficulte $difficulte,
|
||||
Sexe $sexe,
|
||||
array $questions = [])
|
||||
{
|
||||
$this->id = $id;
|
||||
$this->nom = $nom;
|
||||
$this->prenom = $prenom;
|
||||
$this->photo = $photo;
|
||||
$this->ratioTrouvee = $ratioTrouvee;
|
||||
$this->descriptif = $descriptif;
|
||||
$this->dateNaiss = $dateNaiss;
|
||||
$this->thematique = $thematique;
|
||||
$this->difficulte = $difficulte;
|
||||
$this->sexe = $sexe;
|
||||
$this->questions = $questions;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getId(): int
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getNom(): string
|
||||
{
|
||||
return $this->nom;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getPrenom(): string
|
||||
{
|
||||
return $this->prenom;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getPhoto(): string
|
||||
{
|
||||
return $this->photo;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getDescriptif(): string
|
||||
{
|
||||
return $this->descriptif;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return DateTime
|
||||
*/
|
||||
public function getDateNaiss(): DateTime
|
||||
{
|
||||
return $this->dateNaiss;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return float
|
||||
*/
|
||||
public function getRatioTrouvee(): float
|
||||
{
|
||||
return $this->ratioTrouvee;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Thematique
|
||||
*/
|
||||
public function getThematique(): Thematique
|
||||
{
|
||||
return $this->thematique;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Difficulte
|
||||
*/
|
||||
public function getDifficulte(): Difficulte
|
||||
{
|
||||
return $this->difficulte;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Sexe
|
||||
*/
|
||||
public function getSexe(): Sexe
|
||||
{
|
||||
return $this->sexe;
|
||||
}
|
||||
}
|
@ -1,30 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace model;
|
||||
|
||||
class Sexe
|
||||
{
|
||||
private int $id;
|
||||
private string $libelle;
|
||||
|
||||
public function __construct(int $id, string $libelle)
|
||||
{
|
||||
$this->id=$id;
|
||||
$this->libelle=$libelle;
|
||||
}
|
||||
|
||||
public function getId():int
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function getLibelle(): string
|
||||
{
|
||||
return $this->libelle;
|
||||
}
|
||||
|
||||
public function __toString()
|
||||
{
|
||||
return $this->libelle;
|
||||
}
|
||||
}
|
@ -1,30 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace model;
|
||||
|
||||
class Thematique
|
||||
{
|
||||
private int $id;
|
||||
private string $libelle;
|
||||
|
||||
public function __construct(int $id, string $libelle)
|
||||
{
|
||||
$this->id=$id;
|
||||
$this->libelle=$libelle;
|
||||
}
|
||||
|
||||
public function getId():int
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function getLibelle(): string
|
||||
{
|
||||
return $this->libelle;
|
||||
}
|
||||
|
||||
public function __toString()
|
||||
{
|
||||
return $this->libelle;
|
||||
}
|
||||
}
|
@ -1,25 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace model;
|
||||
|
||||
class Utilisateur extends Joueur{
|
||||
private string $email;
|
||||
private string $motDePasse; #hash du mot de passe
|
||||
|
||||
public function __construct(int $id, string $pseudo, string $email, string $motDePasse)
|
||||
{
|
||||
parent::__construct($id,$pseudo);
|
||||
$this->email = $email;
|
||||
$this->motDePasse = $motDePasse;
|
||||
}
|
||||
|
||||
public function getEmail(): string
|
||||
{
|
||||
return $this->email;
|
||||
}
|
||||
|
||||
public function getMotDePasse(): string
|
||||
{
|
||||
return $this->motDePasse;
|
||||
}
|
||||
}
|
@ -1,44 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="fr">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<link rel="stylesheet" href="../css/bootstrap.min.css">
|
||||
<style>
|
||||
body {
|
||||
margin: 10px;
|
||||
}
|
||||
</style>
|
||||
<title>Accueil</title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<h1>Bienvenue sur Mini-Jeux</h1>
|
||||
<!--TODO A DEPLACER DANS SA PROPRE VUE-->
|
||||
{% if dVue.nomJeu is defined %}
|
||||
<p>Jeu selectionné : {{dVue.nomJeu}}</p>
|
||||
{% endif %}
|
||||
{% if dVue.libelleDifficulte is defined %}
|
||||
<p>Difficulte selectionné : {{dVue.libelleDifficulte}}</p>
|
||||
{% endif %}
|
||||
<!--FIN TODO-->
|
||||
|
||||
<div align="right">
|
||||
{% if dVue.pseudo is defined %}
|
||||
<p><a href="logout">{{dVue.pseudo}}</a></p>
|
||||
<p><a href="historique">Historique</a></p>
|
||||
{% else %}
|
||||
<p><a href="login">Se connecter</a></p>
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
<br><br><br><br>
|
||||
<center>
|
||||
<a href="joinParty">Rejoindre une partie</a>
|
||||
<a href="createParty">Créer une partie</a>
|
||||
</center>
|
||||
|
||||
|
||||
<script src="../js/bootstrap.min.js"></script>
|
||||
</body>
|
||||
</html>
|
@ -1,28 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="fr">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<link rel="stylesheet" href="css/bootstrap.min.css">
|
||||
<style>
|
||||
body {
|
||||
margin: 10px;
|
||||
}
|
||||
</style>
|
||||
<title>Accueil</title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<h1>Bienvenue sur Mini-Console Admin</h1>
|
||||
<p align="right"><a href="logout">{{dVue.pseudo}}</a></p>
|
||||
<br><br><br><br>
|
||||
<center>
|
||||
<a href="admin/ajouterScientifiques">Ajouter Scientifiques</a>
|
||||
<br>
|
||||
<a href="admin/listeScientifiques">Lister les scientifiques</a>
|
||||
</center>
|
||||
|
||||
|
||||
<script src="js/bootstrap.min.js"></script>
|
||||
</body>
|
||||
</html>
|
@ -1,108 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="fr">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Ajouter un(e) scientifique</title>
|
||||
<link rel="stylesheet" href="css/bootstrap.min.css">
|
||||
<style>
|
||||
p,
|
||||
label {
|
||||
font:
|
||||
1rem 'Fira Sans',
|
||||
sans-serif;
|
||||
}
|
||||
|
||||
input {
|
||||
margin: 0.4rem;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<h1>ajouterScientifiques</h1>
|
||||
|
||||
<br><br><br>
|
||||
<center>
|
||||
<form action="" method="post">
|
||||
<div>
|
||||
<label for="name">Nom :</label>
|
||||
<input type="text" id="name" name="name" required minlength="1" maxlength="128"
|
||||
value="{% if scientifique is not null %}{{ scientifique.nom }}{% endif %}"/>
|
||||
</div>
|
||||
<div>
|
||||
<label for="name">Prénom :</label>
|
||||
<input type="text" id="prenom" name="prenom" required minlength="1" maxlength="128"
|
||||
value="{% if scientifique is not null %}{{ scientifique.prenom }}{% endif %}"/>
|
||||
</div>
|
||||
<div>
|
||||
<label for="name">URL de la photo :</label>
|
||||
<input type="text" id="url" name="url" required minlength="1" maxlength="512"
|
||||
value="{% if scientifique is not null %}{{ scientifique.photo }}{% endif %}"/>
|
||||
</div>
|
||||
<div>
|
||||
<label for="name">Date de naissance :</label>
|
||||
<input type="date" id="date" name="date" required
|
||||
value="{% if scientifique is not null %}{{ scientifique.date|date('Y-m-d') }}{% endif %}"/>
|
||||
</div>
|
||||
<div>
|
||||
<label for="name">Description (histoire, accomplissements...) :</label>
|
||||
<textarea name="description" cols="40" rows="5">{% if scientifique is not null %}{{ scientifique.descriptif }}{% endif %}</textarea>
|
||||
</div>
|
||||
<fieldset>
|
||||
<legend>Sexe :</legend>
|
||||
{% for se in sexe %}
|
||||
<div>
|
||||
<input type="radio" id="sexe{{se.id}}" name="sexe" value="{{se.id}}"
|
||||
{% if scientifique is not null %}
|
||||
{% if scientifique.sexe.getId == se.id %}
|
||||
checked
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
|
||||
|
||||
/>
|
||||
<label for="{{se.id}}">{{se.libelle}}</label>
|
||||
</div>
|
||||
{% endfor %}
|
||||
</fieldset>
|
||||
<fieldset>
|
||||
<legend>Thematique :</legend>
|
||||
{% for se in themes %}
|
||||
<div>
|
||||
<input type="radio" id="theme{{se.id}}" name="theme" value="{{se.id}}"
|
||||
{% if scientifique is not null %}
|
||||
{% if scientifique.thematique.getId == se.id %}
|
||||
checked
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
|
||||
/>
|
||||
<label for="{{se.id}}">{{se.libelle}}</label>
|
||||
</div>
|
||||
{% endfor %}
|
||||
</fieldset>
|
||||
<fieldset>
|
||||
<legend>Difficulté :</legend>
|
||||
{% for se in difficultes %}
|
||||
<div>
|
||||
<input type="radio" id="diff{{se.id}}" name="difficulte" value="{{se.id}}"
|
||||
{% if scientifique is not null %}
|
||||
{% if scientifique.difficulte.getId == se.id %}
|
||||
checked
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
|
||||
/>
|
||||
<label for="{{se.id}}">{{se.libelle}}</label>
|
||||
</div>
|
||||
{% endfor %}
|
||||
</fieldset>
|
||||
<input type="submit" value="Envoyer" />
|
||||
|
||||
|
||||
|
||||
</form>
|
||||
</center>
|
||||
|
||||
<script src="js/bootstrap.min.js"></script>
|
||||
</body>
|
||||
</html>
|
@ -1,46 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="fr">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<link rel="stylesheet" href="css/bootstrap.min.css">
|
||||
<style>
|
||||
body {
|
||||
margin: 10px;
|
||||
}
|
||||
</style>
|
||||
<title>Liste des scientifiques</title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<h1>Voici la liste des scientifiques dans la base de données :</h1>
|
||||
<p align="right"><a href="logout">{{dVue.pseudo}}</a></p>
|
||||
|
||||
<br><br><br><br>
|
||||
|
||||
<center>
|
||||
<a href="ajouterScientifiques">Ajouter un(e) scientifique</a>
|
||||
{% for scientifique in dVue.listeScientifiques %}
|
||||
<div>
|
||||
<h2>{{ scientifique.getNom() }} {{ scientifique.getPrenom() }}</h2>
|
||||
<p>Sexe : {{ scientifique.getSexe() }}</p>
|
||||
<p>Né(e) le {{ scientifique.getDateNess() }}</p>
|
||||
<p>Thematique : {{ scientifique.getThematique() }}</p>
|
||||
<p>Difficulté à trouver : {{ scientifique.getDifficulte() }}</p>
|
||||
<a href='ajouterScientifiques?id={{scientifique.getId()}}'>Modifier</a>
|
||||
</div>
|
||||
<br>
|
||||
<br>
|
||||
{% endfor %}
|
||||
<div>
|
||||
<a href="{{ dVue.pagePrec }}"><</a>
|
||||
<a href="1">1</a>
|
||||
<p>{{ dVue.page }}</p>
|
||||
<a href="{{ dVue.pageMax }}">1</a>
|
||||
<a href="{{ dVue.pageSuiv }}">></a>
|
||||
</div>
|
||||
</center>
|
||||
|
||||
<script src="js/bootstrap.min.js"></script>
|
||||
</body>
|
||||
</html>
|
@ -1,66 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="fr">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Créer une partie</title>
|
||||
<link rel="stylesheet" href="../css/bootstrap.min.css">
|
||||
<style>
|
||||
p,
|
||||
label {
|
||||
font:
|
||||
1rem 'Fira Sans',
|
||||
sans-serif;
|
||||
}
|
||||
|
||||
input {
|
||||
margin: 0.4rem;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Créer une partie</h1>
|
||||
|
||||
<br><br><br>
|
||||
|
||||
<center>
|
||||
<p>Pour créer voter partie, merci de faire vos choix et de cliquer sur valider</p>
|
||||
<form action="validationFormulaire" method="post">
|
||||
<fieldset>
|
||||
<legend>Mini-jeux disponibles</legend>
|
||||
{% if dVueErreur|length > 0 %}
|
||||
<div>
|
||||
<h5>Erreur : </h5>
|
||||
{% for erreur in dVueErreur %}
|
||||
<p>{{erreur}}</p>
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% endif %}
|
||||
{% if dVueCreate is defined %}
|
||||
{% if dVueCreate["jeux"] is defined %}
|
||||
{% for value in dVueCreate["jeux"] %}
|
||||
<div>
|
||||
<input required type="radio" name="jeu" id="{{value['id']}}" value="{{value['id']}}">
|
||||
<label for="{{value['id']}}">{{value['nom']}}</label>
|
||||
</div>
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
</fieldset>
|
||||
|
||||
{% if dVueCreate["difficultes"] is defined %}
|
||||
<label for="difficulte">Difficulté</label>
|
||||
<select required name="difficulte" id="difficulte">
|
||||
{% for diff in dVueCreate["difficultes"] %}
|
||||
<option value="{{diff['id']}}">{{diff['libelle']}}</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
{% endif %}
|
||||
|
||||
<input type="submit" value="Valider">
|
||||
{% endif %}
|
||||
|
||||
</form>
|
||||
</center>
|
||||
|
||||
<script src="../js/bootstrap.min.js"></script>
|
||||
</body>
|
||||
</html>
|
@ -1,6 +0,0 @@
|
||||
<h1>Une erreur s'est produite !</h1>
|
||||
{% if dVueErreur is defined %}
|
||||
{% for value in dVueErreur %}
|
||||
<p>{{value}}</p>
|
||||
{% endfor %}
|
||||
{% endif %}
|
@ -1,44 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="fr">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<link rel="stylesheet" href="css/bootstrap.min.css">
|
||||
<style>
|
||||
body {
|
||||
margin: 10px;
|
||||
}
|
||||
</style>
|
||||
<title>Historique des scientifiques découverts :</title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<h1>Voici l'historique des scientifiques découverts :</h1>
|
||||
<p align="right"><a href="logout">{{dVue.pseudo}}</a></p>
|
||||
|
||||
<br><br><br><br>
|
||||
|
||||
<center>
|
||||
{% for scientifique in dVue.listeScientifiques %}
|
||||
<div>
|
||||
<h2>{{ scientifique.getNom() }} {{ scientifique.getPrenom() }}</h2>
|
||||
<p>Sexe : {{ scientifique.getSexe() }}</p>
|
||||
<p>Né(e) le {{ scientifique.getDateNess() }}</p>
|
||||
<p>Thematique : {{ scientifique.getThematique() }}</p>
|
||||
<p>Difficulté à trouver : {{ scientifique.getDifficulte() }}</p>
|
||||
</div>
|
||||
<br>
|
||||
<br>
|
||||
{% endfor %}
|
||||
<div>
|
||||
<a href="{{ dVue.pagePrec }}"><</a>
|
||||
<a href="1">1</a>
|
||||
<p>{{ dVue.page }}</p>
|
||||
<a href="{{ dVue.pageMax }}">1</a>
|
||||
<a href="{{ dVue.pageSuiv }}">></a>
|
||||
</div>
|
||||
</center>
|
||||
|
||||
<script src="js/bootstrap.min.js"></script>
|
||||
</body>
|
||||
</html>
|
@ -1,29 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="fr">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Rejoindre une partie</title>
|
||||
<link rel="stylesheet" href="../css/bootstrap.min.css">
|
||||
</head>
|
||||
<body>
|
||||
<h1>Rejoindre une partie</h1>
|
||||
|
||||
<center>
|
||||
<p>Merci de vous munir de votre code de partie</p>
|
||||
<form action="#" method="post">
|
||||
<label for="codeInvitation">Code de la partie</label>
|
||||
<input type="text" name="codeInvitation" id="codeInvitation">
|
||||
<input type="submit" value="Valider">
|
||||
</form>
|
||||
<div>
|
||||
{% if dErreur is defined %}
|
||||
{% for err in dErreur %}
|
||||
<p>{{ err }}</p>
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
</div>
|
||||
</center>
|
||||
|
||||
<script src="../js/bootstrap.min.js"></script>
|
||||
</body>
|
||||
</html>
|
@ -1,32 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="fr">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Se connecter</title>
|
||||
<link rel="stylesheet" href="../css/bootstrap.min.css">
|
||||
</head>
|
||||
<body>
|
||||
<h1>Se connecter</h1>
|
||||
|
||||
<center>
|
||||
<form action="#" method="post">
|
||||
<label for="login">Login</label><br>
|
||||
<input type="text" name="login" id="login">
|
||||
<br>
|
||||
<label for="password">Mot de passe</label><br>
|
||||
<input type="password" name="password" id="password">
|
||||
<br><br>
|
||||
<input type="submit" value="Valider"><br/>
|
||||
<a href="register">Creer un compte</a>
|
||||
{% for error in dErreur %}
|
||||
<br>
|
||||
<p style="color: red">
|
||||
{{error}}
|
||||
</p>
|
||||
{% endfor %}
|
||||
</form>
|
||||
</center>
|
||||
|
||||
<script src="../js/bootstrap.min.js"></script>
|
||||
</body>
|
||||
</html>
|
@ -1,69 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="fr">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Pendu</title>
|
||||
<link rel="stylesheet" href="../css/bootstrap.min.css">
|
||||
<style>
|
||||
p,
|
||||
label {
|
||||
font:
|
||||
1rem 'Fira Sans',
|
||||
sans-serif;
|
||||
}
|
||||
|
||||
input {
|
||||
margin: 0.4rem;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<br><br><br>
|
||||
|
||||
<center>
|
||||
<p></p>
|
||||
<form action="" method="post">
|
||||
<fieldset>
|
||||
{% if dVue.decouvert is defined %}
|
||||
<div>
|
||||
<h1>
|
||||
{{dVue.decouvert}}
|
||||
</h1>
|
||||
</div>
|
||||
<br>
|
||||
{% endif %}
|
||||
{% if dVue.essaisRestant is defined %}
|
||||
<p>Il vous reste {{dVue.essaisRestant}} essais</p>
|
||||
{% endif %}
|
||||
{% if dVue.lettresUtilisees is defined %}
|
||||
<h5>Lettres utilisées</h5>
|
||||
<div>
|
||||
{%for lettre in dVue.lettresUtilisees %}
|
||||
{{lettre}}
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% endif %}
|
||||
<legend>Votre lettre</legend>
|
||||
{% if dVueErreur|length > 0 %}
|
||||
<div>
|
||||
<h5>Erreur : </h5>
|
||||
{% for erreur in dVueErreur %}
|
||||
<p>{{erreur}}</p>
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% endif %}
|
||||
<div>
|
||||
<label>
|
||||
<input required type="text" name="lettre">
|
||||
</label>
|
||||
</div>
|
||||
</fieldset>
|
||||
<input type="submit" value="Valider">
|
||||
|
||||
</form>
|
||||
</center>
|
||||
|
||||
<script src="../js/bootstrap.min.js"></script>
|
||||
</body>
|
||||
</html>
|
@ -1,49 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="fr">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Pendu - Score</title>
|
||||
<link rel="stylesheet" href="../css/bootstrap.min.css">
|
||||
<style>
|
||||
p,
|
||||
label {
|
||||
font:
|
||||
1rem 'Fira Sans',
|
||||
sans-serif;
|
||||
}
|
||||
|
||||
input {
|
||||
margin: 0.4rem;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<br><br><br>
|
||||
|
||||
<center>
|
||||
{% if dVue.messageScore is defined %}
|
||||
<h1>{{dVue.messageScore}}</h1>
|
||||
{% endif %}
|
||||
|
||||
{% if dVue.nbTours is defined and dVue.nbFails is defined %}
|
||||
<p>Vous avez fais {{dVue.nbTours}} essais et {{dVue.nbFails}} erreur(s)</p>
|
||||
{% endif %}
|
||||
|
||||
{% if dVue.scientifique is defined %}
|
||||
<h2>Le scientifique a trouvé été {{dVue.scientifique.prenom}} {{dVue.scientifique.nom}}</h2>
|
||||
<div>
|
||||
<h3>Voici quelques informations à son sujet</h3>
|
||||
<p>Né(e) le : {{dVue.scientifique.dateNaiss}}</p>
|
||||
<p>Sexe : {{dVue.scientifique.sexe}}</p>
|
||||
<p>Domaine : {{dVue.scientifique.thematique}}</p>
|
||||
<p>{{dVue.scientifique.descriptif}}</p>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
<a href=".">Retour à l'accueil</a>
|
||||
</center>
|
||||
|
||||
<script src="../js/bootstrap.min.js"></script>
|
||||
</body>
|
||||
</html>
|
@ -1,50 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="fr">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Saisir Pseudo</title>
|
||||
<link rel="stylesheet" href="../css/bootstrap.min.css">
|
||||
<style>
|
||||
p,
|
||||
label {
|
||||
font:
|
||||
1rem 'Fira Sans',
|
||||
sans-serif;
|
||||
}
|
||||
|
||||
input {
|
||||
margin: 0.4rem;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<br><br><br>
|
||||
|
||||
<center>
|
||||
<p></p>
|
||||
<form action="" method="post">
|
||||
<fieldset>
|
||||
<legend>Veuillez choisir votre pseudo</legend>
|
||||
{% if dVueErreur|length > 0 %}
|
||||
<div>
|
||||
<h5>Erreur : </h5>
|
||||
{% for erreur in dVueErreur %}
|
||||
<p>{{erreur}}</p>
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% endif %}
|
||||
<div>
|
||||
<label for="txt_pseudo">
|
||||
<input required type="text" name="pseudo" id="txt_pseudo">
|
||||
</label>
|
||||
</div>
|
||||
</fieldset>
|
||||
<input type="submit" value="Valider">
|
||||
|
||||
</form>
|
||||
</center>
|
||||
|
||||
<script src="../js/bootstrap.min.js"></script>
|
||||
</body>
|
||||
</html>
|
@ -1,45 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="fr">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>S'inscrire</title>
|
||||
<link rel="stylesheet" href="../css/bootstrap.min.css">
|
||||
<script>
|
||||
function checkmdp(){
|
||||
if(cpassword.value===password.value){
|
||||
mdpbad.style='';
|
||||
reg.disabled=false;
|
||||
} else {
|
||||
mdpbad.style='visibility: hidden';
|
||||
reg.disabled=true;
|
||||
}
|
||||
}
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<h1>S'inscrire</h1>
|
||||
|
||||
<center>
|
||||
<form action="#" method="post">
|
||||
<label for="login">Login</label><br>
|
||||
<input type="text" name="login" id="login">
|
||||
<br>
|
||||
<label for="password">Mot de passe</label><br>
|
||||
<input type="password" name="password" id="password"><br>
|
||||
<label for="cpassword">Confirmer mot de passe</label><br>
|
||||
<input type="password" name="cpassword" id="cpassword" onchange="">
|
||||
<p id="mdpbad" style="visibility: hidden">Les mots de passe ne correspondent pas!</p>
|
||||
<br><br>
|
||||
<input id="reg" type="submit" value="Valider">
|
||||
{% for error in dErreur %}
|
||||
<br>
|
||||
<p style="color: red">
|
||||
{{error}}
|
||||
</p>
|
||||
{% endfor %}
|
||||
</form>
|
||||
</center>
|
||||
|
||||
<script src="../js/bootstrap.min.js"></script>
|
||||
</body>
|
||||
</html>
|
@ -1,52 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="fr">
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Science Quizz</title>
|
||||
<!-- CSS -->
|
||||
<style>
|
||||
body {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
height: 100vh;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.game-container {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div class="game-container">
|
||||
<h1>Science Quizz</h1>
|
||||
<div>
|
||||
<p>Question {{ dVue.statJeu.numQuestion }}:</p>
|
||||
<p>{{ dVue.statJeu.question }}</p>
|
||||
|
||||
<!-- Boutons quitter -->
|
||||
<button>
|
||||
<a href="defaultAction">Quitter</a>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<!-- Gestion des erreurs -->
|
||||
{% if dVueErreur %}
|
||||
<div style="color: red;">
|
||||
<ul>
|
||||
{% for error in dVueErreur %}
|
||||
<li>{{ error }}</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
<!-- JS -->
|
||||
</body>
|
||||
|
||||
</html>
|