Submit Quote

pull/25/head
kevin.modejar 3 months ago
commit c25b7b5030

@ -18,6 +18,7 @@ $racine='/~kemondejar/WF-Website'; // /~kekentin/WF/WF-Website /~lebeaulato/WF-W
$repImg='/home/UCA/kemondejar/public_html/WF-Website/public/images/'; $repImg='/home/UCA/kemondejar/public_html/WF-Website/public/images/';
//$repImg='/'; //$repImg='/';
//Vues //Vues
$vues['erreur'] = 'vue/erreur.php'; $vues['erreur'] = 'vue/erreur.php';
$vues['accueil'] = 'vue/accueil.php'; $vues['accueil'] = 'vue/accueil.php';

Binary file not shown.

After

Width:  |  Height:  |  Size: 653 KiB

@ -115,3 +115,43 @@ function editFieldPassWd(id) {
inputNewPass.focus();// Mettre le focus sur le premier champ de saisie inputNewPass.focus();// Mettre le focus sur le premier champ de saisie
} }
function editFieldImage(id,path) {
var pElement = document.getElementById('imagePost');
var inputImage = document.createElement('input');
inputImage.type = 'hidden';
inputImage.name='image';
inputImage.value=id;
var buttonSubmit = document.createElement('button');
buttonSubmit.textContent = 'Valider';
buttonSubmit.classList.add('saveButtonPasswd');
buttonSubmit.type ="submit";
pElement.innerHTML = '';
pElement.appendChild(inputImage);
pElement.appendChild(buttonSubmit);
inputImage.focus(); // Mettre le focus sur le champ de saisie
///////////////////////////////////////////////
var pEle = document.getElementById('image');
var image = document.createElement('img');
image.src=path;
image.classList.add('imageProfil');
var popover = document.getElementById("list-ChangeImg");
popover.hidePopover();
var button = document.createElement('button');
button.popoverTargetElement= popover;
button.name="image";
button.classList.add('ChangeImg');
button.appendChild(image);
pEle.innerHTML = '';
pEle.appendChild(button);
}

@ -9,6 +9,10 @@ body.dark-mode p{
color : var(--main-dark-text-color); color : var(--main-dark-text-color);
} }
body.dark-mode :popover-open {
background: var(--main-dark-gradient);
color: var(--main-dark-text-color);
}
body.dark-mode .buttonSudmite{ body.dark-mode .buttonSudmite{
background: var(--main-dark-gradient); background: var(--main-dark-gradient);
@ -49,6 +53,11 @@ body.light-mode p{
} }
body.light-mode :popover-open {
background: var(--main-light-gradient);
color: var(--main-light-text-color);
}
body.light-mode .buttonSubmit{ body.light-mode .buttonSubmit{
background: var(--main-light-gradirent); background: var(--main-light-gradirent);
color: var(--main-light-text-color); color: var(--main-light-text-color);
@ -91,6 +100,17 @@ p{
font-family: "Lemon", serif; font-family: "Lemon", serif;
} }
::backdrop {
backdrop-filter: blur(3px);
}
:popover-open {
width: 70%;
height: 60%;
font-size: 15px;
text-align: center;
font-family: "Lemon", serif;
}
.buttonSudmite{ .buttonSudmite{
font-family: "Lemon", serif; font-family: "Lemon", serif;

@ -49,6 +49,7 @@ class UserControler {
global $vues; global $vues;
$p = $this->uMod->getUsername($_SESSION["user"]); $p = $this->uMod->getUsername($_SESSION["user"]);
$listImg = $this->iMod->getAllImg() ;
// Pour les messages d'erreur // Pour les messages d'erreur
$error_message = null; $error_message = null;
@ -121,8 +122,7 @@ class UserControler {
* @throws RuntimeError * @throws RuntimeError
* @throws LoaderError * @throws LoaderError
*/ */
public function continueQuiz(int $id_quiz, int $total_questions) : void public function continueQuiz(int $id_quiz, int $total_questions) : void{
{
global $racine; global $racine;
$score = $_SESSION['score']; $score = $_SESSION['score'];
$_SESSION['no_question'] = Verification::verifChar( isset($_SESSION['no_question']) ? ($_SESSION['no_question'] + 1) : 1); $_SESSION['no_question'] = Verification::verifChar( isset($_SESSION['no_question']) ? ($_SESSION['no_question'] + 1) : 1);
@ -140,8 +140,7 @@ class UserControler {
* @throws RuntimeError * @throws RuntimeError
* @throws LoaderError * @throws LoaderError
*/ */
public function endQuiz(int $id_quiz, int $score) : void public function endQuiz(int $id_quiz, int $score) : void{
{
global $vues,$co; global $vues,$co;
$gw = new QuizGateway($co); $gw = new QuizGateway($co);
@ -155,8 +154,7 @@ class UserControler {
require_once $vues['endQuiz']; require_once $vues['endQuiz'];
} }
public function CorrectAnswer() : bool public function CorrectAnswer() : bool{
{
$answera = Verification::verifChar($_POST['answera'] ?? null); $answera = Verification::verifChar($_POST['answera'] ?? null);
$answerb = Verification::verifChar($_POST['answerb'] ?? null); $answerb = Verification::verifChar($_POST['answerb'] ?? null);
$answerc = Verification::verifChar($_POST['answerc'] ?? null); $answerc = Verification::verifChar($_POST['answerc'] ?? null);
@ -182,8 +180,7 @@ class UserControler {
return $answer == $res->getCanswer(); return $answer == $res->getCanswer();
} }
public function GetQuestion(int $id): array public function GetQuestion(int $id): array{
{
global $co; global $co;
$gw = new QuizQuestionGateway($co); $gw = new QuizQuestionGateway($co);
$mdl = new QuizQuestionModel($gw); $mdl = new QuizQuestionModel($gw);
@ -195,8 +192,7 @@ class UserControler {
* @throws SyntaxError * @throws SyntaxError
* @throws LoaderError * @throws LoaderError
*/ */
public function showQuestion(int $id, int $num) : void public function showQuestion(int $id, int $num) : void{
{
global $vues,$twig; global $vues,$twig;
$q = $this->GetQuestion($id); $q = $this->GetQuestion($id);
$question = $q[$num] ?? $q[0]; $question = $q[$num] ?? $q[0];
@ -208,8 +204,7 @@ class UserControler {
} }
public function getNumberOfQuestion(int $id) : int public function getNumberOfQuestion(int $id) : int{
{
global $co; global $co;
$gw = new QuizGateway($co); $gw = new QuizGateway($co);
$mdl = new QuizModel($gw); $mdl = new QuizModel($gw);
@ -232,8 +227,8 @@ class UserControler {
} }
// ===================== UPDATE DATA USER FUNCTION =====================
// ===================== UPDATE DATA USER FUNCTION =====================
public function changedata() : void{ public function changedata() : void{
global $vues, $racine; global $vues, $racine;
if ($_POST) if ($_POST)
@ -251,12 +246,13 @@ class UserControler {
} }
else if($newEmail){//Modif l'email else if($newEmail){//Modif l'email
$this->updateEmail($newEmail); $this->updateEmail($newEmail);
$this->sendEmailChangeLogin($newEmail); //Envoie un email confirmant le changement d'email
} }
else if($newMdpFirst && $newMdpSecond){ //Modif le mot de passe else if($newMdpFirst && $newMdpSecond){ //Modif le mot de passe
$this->updatePassWd($oldPasswd, $newMdpFirst,$newMdpSecond); $this->updatePassWd($oldPasswd, $newMdpFirst,$newMdpSecond);
} }
else if($newImage){//Modif l'image else if($newImage){//Modif l'image
$this->updateImg(); $this->updateImg($newImage);
} }
} }
header("Location: ". $racine."/profil"); header("Location: ". $racine."/profil");
@ -313,8 +309,8 @@ class UserControler {
} }
} }
public function updateImg(){ public function updateImg(string $newImage){
$user = $this->uMod->setImage($_SESSION['user']); $user = $this->uMod->setImage($_SESSION['user'],$newImage);
} }
@ -328,8 +324,7 @@ class UserControler {
* @throws RuntimeError * @throws RuntimeError
* @throws LoaderError * @throws LoaderError
*/ */
public function submit() : void public function submit() : void{
{
global $vues; global $vues;
$p = $this->caMod->getAllPerso(); $p = $this->caMod->getAllPerso();
$s = $this->srcMod->getAllSources(); $s = $this->srcMod->getAllSources();
@ -341,6 +336,7 @@ class UserControler {
* @throws RuntimeError * @throws RuntimeError
* @throws LoaderError * @throws LoaderError
*/ */
public function toSubmit(string $content,string $character, string $source) public function toSubmit(string $content,string $character, string $source)
{ {
global $co; global $co;
@ -539,4 +535,21 @@ class UserControler {
public function questionSuivantAleatoire(){ public function questionSuivantAleatoire(){
} }
public function sendEmailChangeLogin(string $email) : void{
$to = $email; // Adresse email de destination
$subject = "What The Fantasy - Changement d'Email"; // Sujet de l'email
$message = "
Bonjour,
L'adresse mail $email est désormais votre nouvelle adresse.
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);
}
} }

@ -117,6 +117,7 @@ Class VisitorControler {
public function validlogin() : void public function validlogin() : void
{ {
global $vues,$racine; global $vues,$racine;
if ($_POST) if ($_POST)
{ {
@ -131,7 +132,6 @@ Class VisitorControler {
{ {
$_SESSION['user'] = Verification::verifChar($pseudo); $_SESSION['user'] = Verification::verifChar($pseudo);
$_SESSION['role'] = 'user'; $_SESSION['role'] = 'user';
//$this->sendEmailLogin($pseudo,$this->uMod->getEmailWithUser($pseudo)); Envoie un email pour chaque connexion
header("Location: ". $racine); header("Location: ". $racine);
exit(); exit();
}else }else
@ -161,6 +161,7 @@ Class VisitorControler {
{ {
global $vues,$racine; global $vues,$racine;
if ($_POST) { if ($_POST) {
$pseudo = Verification::verifChar($_POST['pseudo'] ?? null); $pseudo = Verification::verifChar($_POST['pseudo'] ?? null);
$email = Verification::verifChar($_POST['email'] ?? null); $email = Verification::verifChar($_POST['email'] ?? null);
@ -196,7 +197,9 @@ Class VisitorControler {
exit(); exit();
} }
else echo $this->uMod->insertUser($pseudo, $email, $hmdp); else echo $this->uMod->insertUser($pseudo, $email, $hmdp);
$this->sendEmailSignin($pseudo,$email);
$this->sendEmailSubmit($email, $pseudo);
$_SESSION["role"] = Verification::verifChar('user'); $_SESSION["role"] = Verification::verifChar('user');
$_SESSION["user"] = Verification::verifChar($pseudo); $_SESSION["user"] = Verification::verifChar($pseudo);
@ -205,37 +208,58 @@ Class VisitorControler {
} }
} }
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 = "
Bonjour $pseudo,
Merci de vous être inscrit sur notre site What The Fantasy. Cest avec grande joie que nous vous accueillons au sein de notre confrérie, pour découvrir ensemble... function sendEmailSubmit(string $email, string $pseudo) {
// Génère les données du message
$sujet = "What The Fantasy - Création de compte";
$urlImage = "public/images/Baneer.png";
// Génère une frontière unique pour l'email
$boundary = "-----=" . md5(uniqid(mt_rand()));
//Instancie les headers
$headers = "From: noreply@whatTheFantasy.com\r\n";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: multipart/related; boundary=\"$boundary\"\r\n";
// Corps de l'email HTML avec l'image intégrée
$corpsMessage = "--$boundary\r\n";
$corpsMessage .= "Content-Type: text/html; charset=UTF-8\r\n";
$corpsMessage .= "Content-Transfer-Encoding: 8bit\r\n\r\n";
// Ajoute le message HTML
$corpsMessage .= "<html>
<body>
<img src=\"cid:image1\" alt=\"Image\" style=\"width: 400px; height: auto;\" />
<p>Bonjour $pseudo,</p>
<p>Merci de vous être inscrit sur notre site What The Fantasy. Cest avec grande joie que nous vous accueillons au sein de notre confrérie, pour découvrir ensemble...
</p>
<p>À bientôt !</p>
<p>L'équipe du site</p>
</body>
</html>\r\n";
// Ajoute l'image en pièce jointe avec un CID
$corpsMessage .= "--$boundary\r\n";
$corpsMessage .= "Content-Type: image/jpeg; name=\"image.jpg\"\r\n";
$corpsMessage .= "Content-Transfer-Encoding: base64\r\n";
$corpsMessage .= "Content-ID: <image1>\r\n\r\n";
À bientôt !
L'équipe du site
"; // Contenu de l'email
$headers = "From: noreply@whatTheFantasy.com"; // Adresse email de l'expéditeur
// Envoyer l'email $imageContent = file_get_contents($urlImage);// Lecture et encodage de l'image en base64
mail($to, $subject, $message, $headers); if ($imageContent === false) {
return "Impossible de charger l'image spécifiée.";
} }
$corpsMessage .= chunk_split(base64_encode($imageContent)) . "\r\n";
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. $corpsMessage .= "--$boundary--";// Fin du corps de l'email
L'équipe du site mail($email, $sujet, $corpsMessage, $headers);// Envoi de l'email
"; // Contenu de l'email
$headers = "From: noreply@whatTheFantasy.com"; // Adresse email de l'expéditeur
// Envoyer l'email
mail($to, $subject, $message, $headers);
} }
} }

@ -70,8 +70,5 @@ class CharacterEntity
$this->img_path = $img_path; $this->img_path = $img_path;
} }
} }

@ -5,18 +5,16 @@ class ImageEntity
{ {
private int $idImg; private int $idImg;
private string $imgPath; private string $imgPath;
private string $isImgProfile;
/** /**
* @param int $idImg * @param int $idImg
* @param string $imgPath * @param string $imgPath
* @param string $isImgProfile * @param string $isImgProfile
*/ */
public function __construct(int $idImg, string $imgPath, string $isImgProfile) public function __construct(int $idImg, string $imgPath)
{ {
$this->idImg = $idImg; $this->idImg = $idImg;
$this->imgPath = $imgPath; $this->imgPath = $imgPath;
$this->isImgProfile = $isImgProfile;
} }
public function getIdImg(): int public function getIdImg(): int
@ -39,15 +37,5 @@ class ImageEntity
$this->imgPath = $imgPath; $this->imgPath = $imgPath;
} }
public function getIsImgProfile(): string
{
return $this->isImgProfile;
}
public function setIsImgProfile(string $isImgProfile): void
{
$this->isImgProfile = $isImgProfile;
}
} }

@ -6,7 +6,7 @@ use PDO;
class ImageGateway extends Gateway class ImageGateway extends Gateway
{ {
public function createImgGateway(int $idImg, string $imgPath, bool $isImgProfile) : bool public function createImgGateway(int $idImg, string $imgPath) : bool
{ {
$query = " $query = "
INSERT INTO Image INSERT INTO Image
@ -22,8 +22,8 @@ class ImageGateway extends Gateway
public function findImgById(int $idImg) : array public function findImgById(int $idImg) : array
{ {
$query = " $query = "
SELECT * FROM Images SELECT * FROM Image
WHERE id_image = :id_img WHERE id_img = :id_img
"; ";
$this -> co -> executeQuery($query, ['id_img' => array($idImg, PDO::PARAM_INT)]); $this -> co -> executeQuery($query, ['id_img' => array($idImg, PDO::PARAM_INT)]);
@ -34,19 +34,7 @@ class ImageGateway extends Gateway
public function findAllImg() : array public function findAllImg() : array
{ {
$query = " $query = "
SELECT * FROM Images SELECT * FROM Image
";
$this -> co -> executeQuery($query);
return $this -> co -> getResults();
}
public function findAllImgProfile() : array
{
$query = "
SELECT * FROM Images
WHERE is_img_prfl
"; ";
$this -> co -> executeQuery($query); $this -> co -> executeQuery($query);
@ -57,8 +45,8 @@ class ImageGateway extends Gateway
public function deleteImgGateway(int $idImg) : bool public function deleteImgGateway(int $idImg) : bool
{ {
$query = " $query = "
DELETE FROM Images DELETE FROM Image
WHERE id_image = :id_img WHERE id_img = :id_img
"; ";
return $this -> co -> executeQuery($query, ['id_img' => array($idImg, PDO::PARAM_INT)]); return $this -> co -> executeQuery($query, ['id_img' => array($idImg, PDO::PARAM_INT)]);
@ -67,8 +55,8 @@ class ImageGateway extends Gateway
public function updateImgGateway(int $idImg, string $imgPath) : bool public function updateImgGateway(int $idImg, string $imgPath) : bool
{ {
$query = " $query = "
UPDATE Images UPDATE Image
SET img_path = :img_path SET imgPath = :img_path
WHERE id_image = :id_img WHERE id_image = :id_img
"; ";

@ -182,8 +182,18 @@ Class UserGateway extends Gateway{
} }
public function updateImg(string $username):array{ public function updateImg(string $username,string $newImage):array{
if($newImage==null){
$id_image = $this->randomImg(); $id_image = $this->randomImg();
}
else if(is_int((int)$newImage)){
$id_image=(int)$newImage;
}
else{
$id_image = $this->randomImg();
}
//Update l'image du user passé en paramètre //Update l'image du user passé en paramètre
$query = 'UPDATE Users SET img=:id_image WHERE username=:username'; $query = 'UPDATE Users SET img=:id_image WHERE username=:username';
$this->co->executeQuery($query, array(':username'=>array($username, PDO::PARAM_STR), ':id_image'=> array($id_image, PDO::PARAM_INT))); $this->co->executeQuery($query, array(':username'=>array($username, PDO::PARAM_STR), ':id_image'=> array($id_image, PDO::PARAM_INT)));

@ -8,9 +8,9 @@ use Gateway\Gateway;
class ImageModel extends Model class ImageModel extends Model
{ {
public function createImgModel(int $idImg, string $imgPath, bool $isImgProfile) : bool public function createImgModel(int $idImg, string $imgPath) : bool
{ {
return $this -> gateway -> createImgGateway($idImg, $imgPath, $isImgProfile); return $this -> gateway -> createImgGateway($idImg, $imgPath);
} }
public function createImgModelWithoutId (string $imgPath) : int public function createImgModelWithoutId (string $imgPath) : int
@ -27,9 +27,8 @@ class ImageModel extends Model
if ($res) if ($res)
{ {
return new ImageEntity( return new ImageEntity(
$res[0]['id_image'], $res[0]['id_img'],
$res[0]['img_path'], $res[0]['imgpath']
$res[0]['is_img_prfl']
); );
} }
return null; return null;
@ -44,30 +43,13 @@ class ImageModel extends Model
foreach ($res as $img) foreach ($res as $img)
{ {
$images[] = new ImageEntity( $images[] = new ImageEntity(
$img['id_image'], $img['id_img'],
$img['img_path'], $img['imgpath']
$img['is_img_prfl']
); );
} }
return $images; return $images;
} }
public function getAllImgProfile() : array
{
$res = $this -> gateway -> findAllImgProfile();
$images = [];
foreach ($res as $img)
{
$images[] = new ImageEntity(
$img['id_image'],
$img['img_path'],
$img['is_img_prfl']
);
}
return $images;
}
public function deleteImgModel(int $idImg) : bool public function deleteImgModel(int $idImg) : bool
{ {

@ -150,8 +150,8 @@
} }
public function setImage(string $username){ public function setImage(string $username,string $newImage){
$res = $this->gateway->updateImg($username); $res = $this->gateway->updateImg($username,$newImage);
$src[] = $res[0]['img']; $src[] = $res[0]['img'];
return $src; return $src;
} }

@ -17,5 +17,6 @@
'srcEmail' => $p->getEmail(), 'srcEmail' => $p->getEmail(),
'srcImg' => $p->getImgPrfl(), 'srcImg' => $p->getImgPrfl(),
'error_message' => $error_message, 'error_message' => $error_message,
'images' => $listImg,
)); ));
?> ?>

@ -2,8 +2,26 @@
<div class="login"> <div class="login">
<h1>▶ Profil ◀</h1> <h1>▶ Profil ◀</h1>
<p name="image" id="image">
<button popovertarget="list-ChangeImg" name="image" class="ChangeImg"><img src="{{ srcImg }}" class="imageProfil"/></button>
</p>
<form method="post" action="{{ racine }}/changedata"> <form method="post" action="{{ racine }}/changedata">
<button name="image" class="ChangeImg" value="1" type="Submit"><img src="{{ srcImg }}" class="imageProfil" onmousedown="return false"/></button>
<p name="imagePost" id="imagePost">
</p>
<div popover id="list-ChangeImg" >
{% if images|length > 0 %}
{% for image in images %}
<p class="ChangeImg" onclick="editFieldImage({{ image.idImg }},'{{ image.imgPath }}')">
<img src="{{ image.imgPath }}" class="imageProfil" />
</p>
{% endfor %}
{% else %}
<p>Aucune images n'a été trouvée.</p>
{% endif %}
</div>
{% if error_message is defined and error_message is not empty %} {% if error_message is defined and error_message is not empty %}
<p style="color: red">{{ error_message }}</p> <p style="color: red">{{ error_message }}</p>
@ -11,7 +29,9 @@
<p class="infoProfil" name="pseudo" id="username"> <strong>{{ srcUsername }}</strong><img class='imgModify' src='{{ racine }}/images/modify.svg' onclick="editFieldUsername('username')"/></p> <p class="infoProfil" name="pseudo" id="username"> <strong>{{ srcUsername }}</strong><img class='imgModify' src='{{ racine }}/images/modify.svg' onclick="editFieldUsername('username')"/></p>
<p class="infoProfil" name="email" id="email"> <strong> {{ srcEmail }}</strong><img class='imgModify' src='{{ racine }}/images/modify.svg' onclick="editFieldEmail('email')"/></p> <p class="infoProfil" name="email" id="email"> <strong> {{ srcEmail }}</strong>
<img class='imgModify' src='{{ racine }}/images/modify.svg' onclick="editFieldEmail('email')"/>
</p>
<p class="infoProfil" name="mdp" id="passwd"> <strong>Votre mot de passe</strong><img class='imgModify' src='{{ racine }}/images/modify.svg' onclick="editFieldPassWd('passwd')"/></p> <p class="infoProfil" name="mdp" id="passwd"> <strong>Votre mot de passe</strong><img class='imgModify' src='{{ racine }}/images/modify.svg' onclick="editFieldPassWd('passwd')"/></p>

Loading…
Cancel
Save