con=$con; session_start(); try{ global $rep, $vues; $action=$_REQUEST['action']; switch($action) { case NULL: require ('./View/src/pages/Main.php'); //header('Location: http://londres.uca.local/~nogarnier1/Scripted/WEB/View/src/pages/Main.html'); break; case "signUp": $this->signUp(); break; case "login": $this->login(); break; case "goToPresentation": $this->goToPresentation(); break; case "goToHome": $this->goToHome(); break; case "goToLogin": $this->goToLogin(); break; case "goToSignUp": $this->goToSignUp(); break; } } catch (PDOException $e) { require ($rep.$vues['erreurBd']); } } private function signUp() { global $rep, $vues; try { $gateway = new JoueurGateway($this->con); $validation = new Validation(); if (! $validation->ValidateEmail($_REQUEST['email'])) { throw (new Exception("Email non valide")); } $joueur = new Joueur($_REQUEST['email'], $_REQUEST['username'], $_REQUEST['password']); $gateway->insert($joueur); $_SESSION['connected'] = 'true'; require ('./View/src/pages/Main.php'); }catch (Exception $e){ require($rep.$vues['erreurSignUp']); } } private function login(){ global $rep, $vues; try { $gateway = new JoueurGateway($this->con); $joueur = $gateway->getJoueurByEmail($_REQUEST['email']); if ($joueur->getEmail() == null){ throw new JoueurNotFoundException("Joueur introuvable"); } $mdp = $gateway->getMdpByEmail($_REQUEST['email']); if ($mdp != $_REQUEST['password']){ throw new InvalidMdpException("Mot de passe invalide"); } $_SESSION['connected'] = 'true'; require ('./View/src/pages/Main.php'); }catch (JoueurNotFoundException $e){ require($rep.$vues['erreurLoginEmail']); }catch (InvalidMdpException $m) { require($rep . $vues['erreurLoginMdp']); } } private function goToPresentation() { global $rep, $vues; try { require ('./View/src/pages/Presentation.html'); }catch (Exception $e){ require($rep.$vues['erreur404']); } } private function goToHome() { global $rep, $vues; try { require ('./View/src/pages/Main.php'); }catch (Exception $e){ require($rep.$vues['erreur404']); } } private function goToLogin() { global $rep, $vues; try { require ('./View/src/pages/LogSign/Login.php'); }catch (Exception $e){ require($rep.$vues['erreur404']); } } private function goToSignUp() { global $rep, $vues; try { require ('./View/src/pages/LogSign/SignUp.php'); }catch (Exception $e){ require($rep.$vues['erreur404']); } } }