diff --git a/WEB/Config/Config.php b/WEB/Config/Config.php index ac7125f3..b9fb82ab 100644 --- a/WEB/Config/Config.php +++ b/WEB/Config/Config.php @@ -3,8 +3,8 @@ $rep =''; // BD -$dsn = './scripted.db'; -// $dsn = 'C:\\wamp64\\www\\scripted.db'; +// $dsn = './scripted.db'; +$dsn = 'C:\\wamp64\\www\\scripted.db'; //Sel de hashage $sel = "JeSuisUnSeldeHashageEtJeSuisUniqueEtTresSecuriseEtJeSuisTresLong"; @@ -17,8 +17,10 @@ $vues['login'] = 'View/src/pages/LogSign/Login.php'; $vues['signUp'] = 'View/src/pages/LogSign/SignUp.php'; $vues['test'] = 'View/src/pages/FirstTests/FirstTest1.html'; $vues['next'] = 'View/src/pages/FirstTests/FirstTest'; +$vues['admin'] = 'View/src/pages/Admin.php'; // Enigme -$vues['enigme'] = 'View/src/pages/Enigme/Palindrome.html'; +// $vues['enigme'] = 'View/src/pages/Enigme/Palindrome.html'; +$vues['enigme'] = 'View/src/pages/Enigme/EnigmePage.php'; $vues['chouette'] = 'View/src/pages/Enigme/Chouette.html'; $vues['cesarEncrypt'] = 'View/src/pages/Enigme/CesarEncrypt.html'; $vues['cesarDecrypt'] = 'View/src/pages/Enigme/CesarDecrypt.html'; diff --git a/WEB/Controller/AdminController.php b/WEB/Controller/AdminController.php new file mode 100644 index 00000000..1185bf90 --- /dev/null +++ b/WEB/Controller/AdminController.php @@ -0,0 +1,80 @@ +goToHome(); + break; + case "goToHome": + $this->goToHome(); + break; + case "goToAdmin": + $this->goToAdmin(); + break; + case "goToPresentation": + $this->goToPresentation(); + break; + case "goToEnigme": + $this->goToEnigme(); + break; + case "goToTest": + $this->goToTest(); + break; + case "goToChouette": + $this->goToChouette(); + break; + case "goToCesarEncrypt": + $this->goToCesarEncrypt(); + break; + case "goToCesarDecrypt": + $this->goToCesarDecrypt(); + break; + case "goToChuckNorris": + $this->goToChuckNorris(); + break; + case "goToHanoi": + $this->goToHanoi(); + break; + case "goToTrianglePascal": + $this->goToTrianglePascal(); + break; + case "goToDoubleElement": + $this->goToDoubleElement(); + break; + case "goToNext": + $this->goToNext(); + break; + case "goToQueue": + $this->goToQueue()(); + break; + case "logout": + $this->logout(); + break; + default: + $error = "Action non valide"; + require($rep . $vues['erreur']); + break; + } + } catch (PDOException $e) { + $error = $e->getMessage(); + require($rep . $vues['erreur']); + } catch (Exception $e2) { + $error = $e2->getMessage(); + require($rep . $vues['erreur']); + } + } + + function goToAdmin() + { + global $rep, $vues; + require($rep . $vues['admin']); + } +} \ No newline at end of file diff --git a/WEB/Controller/EnigmeGateway.php b/WEB/Controller/EnigmeGateway.php index 7b168d29..b3e3cfde 100644 --- a/WEB/Controller/EnigmeGateway.php +++ b/WEB/Controller/EnigmeGateway.php @@ -35,10 +35,10 @@ class EnigmeGateway */ public function insert(Enigme $enigme) { - $query = "INSERT INTO Enigme VALUES (:id,:admin,:enonce,:aide,:rappel,:solution,:test,:tempsDeResolution,:points)"; + $query = "INSERT INTO Enigme VALUES (:id,:nom,:enonce,:aide,:rappel,:solution,:test,:tempsDeResolution,:points)"; $this->con->executeQuery($query, array( ':id' => array($enigme->getIdEnigme(),SQLITE3_INTEGER), - ':admin' => array($enigme->getAdmin(), SQLITE3_TEXT), + ':nom' => array($enigme->getNom(), SQLITE3_TEXT), ':enonce' => array($enigme->getEnonce(), SQLITE3_TEXT), ':aide' => array($enigme->getAide(), SQLITE3_TEXT), ':rappel' => array($enigme->getRappel(), SQLITE3_TEXT), @@ -102,15 +102,15 @@ class EnigmeGateway return $tabEnigme; } - public function findById(string $idEnigme) : array + public function findById(int $idEnigme) : array { - $query="SELECT * FROM Enigme WHERE idEnigme =:idEnigme"; + $query="SELECT * FROM Enigme WHERE id =:id"; $this->con->executequery($query,array( - ':idEnigme' => array($idEnigme,SQLITE3_INTEGER) + ':id' => array($idEnigme,SQLITE3_INTEGER) )); $results=$this->con->getResults(); - $tabEnigme=EnigmeFactory::create($results); - return $tabEnigme; + $enigme=EnigmeFactory::create($results); + return $enigme; } public function findByTempsDeResolution() : array @@ -129,7 +129,7 @@ class EnigmeGateway $results = $this->con->getResults(); foreach ($results as $row) { echo $row['idEnigme'] . ''; - echo $row['admin'] . ''; + echo $row['nom'] . ''; echo $row['enonce'] . ''; echo $row['aide'] . ''; echo $row['rappel'] . ''; diff --git a/WEB/Controller/FrontController.php b/WEB/Controller/FrontController.php index 8bf4a62c..0f7656ae 100644 --- a/WEB/Controller/FrontController.php +++ b/WEB/Controller/FrontController.php @@ -3,7 +3,7 @@ class FrontController { function __construct() { - try { + try { global $error, $view, $rep; $nettoyage = new Nettoyage(); session_start(); @@ -22,11 +22,22 @@ class FrontController } else if (method_exists('UserController', $action) == false) { $error = "Action non valide " . $action; require($rep . $view['erreur']); - } - else { + } else { $_REQUEST['action'] = $action; new UserController(); } + } + else if ($role == "admin") { + if ($action == NULL) { + $_REQUEST['action'] = $action; + new AdminController(); + } else if (method_exists('UserController', $action) == false) { + $error = "Action non valide " . $action; + require($rep . $view['erreur']); + } else { + $_REQUEST['action'] = $action; + new AdminController(); + } } else { $_REQUEST['action'] = $action; new VisitorController(); diff --git a/WEB/Controller/UserController.php b/WEB/Controller/UserController.php index 4089f825..057d1fc4 100644 --- a/WEB/Controller/UserController.php +++ b/WEB/Controller/UserController.php @@ -77,7 +77,7 @@ class UserController global $rep, $vues; require($rep . $vues['main']); } catch (Exception $e) { - $error = "404"; + $error = $e->getMessage(); require($rep . $vues['erreur']); } } @@ -87,7 +87,7 @@ class UserController global $rep, $vues; require($rep . $vues['presentation']); } catch (Exception $e) { - $error = "404"; + $error = $e->getMessage(); require($rep . $vues['erreur']); } } @@ -97,7 +97,7 @@ class UserController global $rep, $vues; require($rep . $vues['test']); } catch (Exception $e) { - $error = "404"; + $error = $e->getMessage(); require($rep . $vues['erreur']); } } @@ -107,7 +107,7 @@ class UserController global $rep, $vues; require($rep . $vues['enigme']); } catch (Exception $e) { - $error = "404"; + $error = $e->getMessage(); require($rep . $vues['erreur']); } } @@ -117,7 +117,7 @@ class UserController global $rep, $vues; require($rep . $vues['chouette']); } catch (Exception $e) { - $error = "404"; + $error = $e->getMessage(); require($rep . $vues['erreur']); } } @@ -127,7 +127,7 @@ class UserController global $rep, $vues; require($rep . $vues['cesarEncrypt']); } catch (Exception $e) { - $error = "404"; + $error = $e->getMessage(); require($rep . $vues['erreur']); } } @@ -137,7 +137,7 @@ class UserController global $rep, $vues; require($rep . $vues['cesarDecrypt']); } catch (Exception $e) { - $error = "404"; + $error = $e->getMessage(); require($rep . $vues['erreur']); } } @@ -147,7 +147,7 @@ class UserController global $rep, $vues; require($rep . $vues['chuckNorris']); } catch (Exception $e) { - $error = "404"; + $error = $e->getMessage(); require($rep . $vues['erreur']); } } @@ -157,7 +157,7 @@ class UserController global $rep, $vues; require($rep . $vues['hanoi']); } catch (Exception $e) { - $error = "404"; + $error = $e->getMessage(); require($rep . $vues['erreur']); } } @@ -167,7 +167,7 @@ class UserController global $rep, $vues; require($rep . $vues['trianglePascal']); } catch (Exception $e) { - $error = "404"; + $error = $e->getMessage(); require($rep . $vues['erreur']); } } @@ -177,7 +177,7 @@ class UserController global $rep, $vues; require($rep . $vues['doubleElement']); } catch (Exception $e) { - $error = "404"; + $error = $e->getMessage(); require($rep . $vues['erreur']); } } diff --git a/WEB/Factory/EnigmeFactory.php b/WEB/Factory/EnigmeFactory.php index b84fdcae..2ce602a1 100644 --- a/WEB/Factory/EnigmeFactory.php +++ b/WEB/Factory/EnigmeFactory.php @@ -5,7 +5,7 @@ class EnigmeFactory{ $tabEnigme=array(); foreach($results as $row) { - $tabEnigme[]= new Enigme($row['id'],$row['admin'],$row['enonce'],$row['aide'],$row['rappel'],$row['solution'],$row['test'],$row['tempsDeResolution'],$row['points']); + $tabEnigme[]= new Enigme($row['id'],$row['nom'],$row['enonce'],$row['aide'],$row['rappel'],$row['exemple'],$row['solution'],$row['test'],$row['tempsDeResolution'],$row['points']); } return $tabEnigme; } diff --git a/WEB/Metier/Enigme.php b/WEB/Metier/Enigme.php index 72409db5..e5dc3e1a 100644 --- a/WEB/Metier/Enigme.php +++ b/WEB/Metier/Enigme.php @@ -2,87 +2,72 @@ class Enigme { - private string $idEnigme; + private int $idEnigme; + private string $nom; private string $enonce; private string $aide; - private string $admin; private string $rappel; + private string $exemple; private string $solution; private string $test; private int $tempsDeResolution; private int $points; /** - * @param string $idEnigme + * @param int $idEnigme + * @param string $nom * @param string $enonce * @param string $aide * @param string $rappel + * @param string $exemple * @param string $solution * @param string $test * @param int $tempsDeResolution * @param int $points */ - public function __construct() + public function __construct($idEnigme, $nom = "",$enonce = "", $aide = "", $rappel = "", $exemple = "",$solution = "", $test = "", $tempsDeResolution = 0, $points = 0) { - $arguments=func_get_args(); - $index=func_num_args(); - if(method_exists($this,$function='__construct'.$index)); - call_user_func(array(array($this,$function),$arguments)); - } - - public function __constructMulti(string $idEnigme, string $enonce, string $solution, string $test, int $tempsDeResolution,string $admin,int $points){ - $this->idEnigme=$idEnigme; - $this->enonce=$enonce; - $this->solution=$solution; - $this->test=$test; - $this->tempsDeResolution=$tempsDeResolution; - $this->aide=NULL; - $this->rappel=NULL; - $this->admin=$admin; - $this->points=$points; - } - - public function __constructSolo(string $idEnigme, string $enonce, string $aide, string $rappel, string $solution, string $test,string $admin){ - $this->idEnigme=$idEnigme; - $this->enonce=$enonce; - $this->aide=$aide; - $this->rappel=$rappel; - $this->solution=$solution; - $this->test=$test; - $this->tempsDeResolution=0; - $this->admin=$admin; + $this->idEnigme = $idEnigme; + $this->nom = $nom; + $this->enonce = $enonce; + $this->aide = $aide; + $this->rappel = $rappel; + $this->exemple = $exemple; + $this->solution = $solution; + $this->test = $test; + $this->tempsDeResolution = $tempsDeResolution; + $this->points = $points; } - /** - * @return string + * @return int */ - public function getAdmin(): string + public function getIdEnigme(): int { - return $this->admin; + return $this->idEnigme; } /** - * @param string $admin + * @param int $idEnigme */ - public function setAdmin(string $admin): void + public function setIdEnigme(int $idEnigme): void { - $this->admin = $admin; + $this->idEnigme = $idEnigme; } /** * @return string */ - public function getIdEnigme(): string + public function getNom(): string { - return $this->idEnigme; + return $this->nom; } /** - * @param string $idEnigme + * @param string $nom */ - public function setIdEnigme(string $idEnigme): void + public function setNom(string $nom): void { - $this->idEnigme = $idEnigme; + $this->nom = $nom; } /** @@ -133,6 +118,22 @@ class Enigme $this->rappel = $rappel; } + /** + * @return string + */ + public function getExemple(): string + { + return $this->exemple; + } + + /** + * @param string $exemple + */ + public function setExemple(string $exemple): void + { + $this->exemple = $exemple; + } + /** * @return string */ diff --git a/WEB/View/src/pages/Admin.html b/WEB/View/src/pages/Admin.html new file mode 100644 index 00000000..556b4ee5 --- /dev/null +++ b/WEB/View/src/pages/Admin.html @@ -0,0 +1,59 @@ + + +
+