diff --git a/config/config.php b/config/config.php index fdd7003..f33490e 100644 --- a/config/config.php +++ b/config/config.php @@ -13,8 +13,8 @@ $login = ''; $mdp = ''; -//$racine='/~kemondejar/WF-Website'; // /~kekentin/WF/WF-Website /~lebeaulato/WF-Website -$racine='/WF-Website'; +$racine='/~lebeaulato/WF-Website'; // /~kekentin/WF/WF-Website /~lebeaulato/WF-Website /~kemondejar/WF-Website +//$racine='/WF-Website'; diff --git a/index.php b/index.php index 2de51d3..3bc9649 100644 --- a/index.php +++ b/index.php @@ -15,8 +15,8 @@ if(!isset($_SESSION['theme'])){ require_once __DIR__ . '/config/config.php'; require __DIR__ . '/vendor/autoload.php'; -$co = new \Gateway\Connection('pgsql:host=localhost;dbname=wikifantasy3;', 'postgres', 'postgres'); -//$co = new \Gateway\Connection('pgsql:host=localhost;dbname=dbkekentin;', 'kekentin', 'passwd'); +//$co = new \Gateway\Connection('pgsql:host=localhost;dbname=wikifantasy3;', 'postgres', 'postgres'); +$co = new \Gateway\Connection('pgsql:host=localhost;dbname=dbkekentin;', 'kekentin', 'passwd'); //twig $loader = new \Twig\Loader\FilesystemLoader('vue/templates'); diff --git a/src/Controleur/VisitorControler.php b/src/Controleur/VisitorControler.php index ad292fe..0b57488 100644 --- a/src/Controleur/VisitorControler.php +++ b/src/Controleur/VisitorControler.php @@ -131,6 +131,7 @@ Class VisitorControler { { $_SESSION['user'] = Verification::verifChar($pseudo); $_SESSION['role'] = 'user'; + //$this->sendEmailLogin($pseudo,$this->uMod->getEmailWithUser($pseudo)); Envoie un email pour chaque connexion header("Location: ". $racine); exit(); }else @@ -195,7 +196,7 @@ Class VisitorControler { exit(); } else echo $this->uMod->insertUser($pseudo, $email, $hmdp); - $this->sendEmail($pseudo,$email); + $this->sendEmailSignin($pseudo,$email); $_SESSION["role"] = Verification::verifChar('user'); $_SESSION["user"] = Verification::verifChar($pseudo); @@ -204,7 +205,7 @@ Class VisitorControler { } } - public function sendEmail(string $pseudo, string $email) : void{ + public function sendEmailSignin(string $pseudo, string $email) : void{ $to = $email; // Adresse email de destination $subject = "What The Fantasy - Création de compte"; // Sujet de l'email $message = " @@ -219,6 +220,22 @@ Class VisitorControler { // Envoyer l'email mail($to, $subject, $message, $headers); + } + public function sendEmailLogin(string $pseudo, string $email) : void{ + $to = $email; // Adresse email de destination + $subject = "What The Fantasy - Connexion à votre compte"; // Sujet de l'email + $message = " + Bonjour $pseudo, + + Nous avons détecté une connexion à votre compte $pseudo. Si cela vient de vous, vous pouvez ignorer ce message. Sinon, nous vous conseillons de changer votre mot de passe. + + + L'équipe du site + "; // Contenu de l'email + $headers = "From: noreply@whatTheFantasy.com"; // Adresse email de l'expéditeur + + // Envoyer l'email + mail($to, $subject, $message, $headers); } } \ No newline at end of file diff --git a/src/Gateway/UserGateway.php b/src/Gateway/UserGateway.php index cee829e..27076f2 100644 --- a/src/Gateway/UserGateway.php +++ b/src/Gateway/UserGateway.php @@ -200,5 +200,11 @@ Class UserGateway extends Gateway{ $query = 'UPDATE Users SET password=:newPassWd WHERE username=:username'; $this->co->executeQuery($query, array(':username'=>array($username, PDO::PARAM_STR), ':newPassWd'=> array($newPassWd, PDO::PARAM_STR))); } + + public function emailWithUser(string $user):array{ + $query = 'SELECT email FROM Users WHERE username = :user'; + $this->co->executeQuery($query, array(':user'=>array($user, PDO::PARAM_STR))); + return $this->co->getResults(); + } } ?> diff --git a/src/Model/UserModel.php b/src/Model/UserModel.php index 28f0c23..0c38d21 100644 --- a/src/Model/UserModel.php +++ b/src/Model/UserModel.php @@ -85,6 +85,11 @@ return $res[0]['id_user']; } + public function getEmailWithUser(string $user){ + $res = $this->gateway->emailWithUser($user); + return $res[0]['email']; + } + // ===================== Bool FUNCTION ===================== public function IsExisteUsername(string $username):bool{