resolution problème merge

pull/22/head
kevin.modejar 5 months ago
commit 9e5131c05f

BIN
.DS_Store vendored

Binary file not shown.

1
.gitignore vendored

@ -0,0 +1 @@
.idea/

@ -9,7 +9,9 @@
"Controleur\\": "src/Controleur/",
"Model\\": "src/Model/",
"Gateway\\": "src/Gateway/",
"Entity\\": "src/Entity/"
"Entity\\": "src/Entity/",
"Verification\\": "src/Verification/",
"Enum\\": "src/Enum"
}
}
}

@ -12,7 +12,7 @@ $base = '';
$login = '';
$mdp = '';
$racine='/~kemondejar/WF-Website';
$racine='/~lebeaulato/WF-Website'; // /~kekentin/WF/WF-Website
//Vues
@ -27,6 +27,7 @@ $vues['favorite'] = 'vue/favorits.php';
$vues['quiz'] = 'vue/quiz.php';
$vues['endQuiz'] = 'vue/endQuiz.php';
$vues['submitQuote'] = 'vue/submitQuote.php';
//Style css

@ -13,10 +13,9 @@ if(!isset($_SESSION['theme'])){
//chargement config
require_once __DIR__ . '/config/config.php';
require __DIR__ . '/vendor/autoload.php';
$co = new \Gateway\Connection('pgsql:host=localhost;dbname=dbkekentin;', 'kekentin', 'passwd');
$co = new \Gateway\Connection('pgsql:host=localhost;dbname=dbkekentin;', 'kekentin', 'passwd');// ('pgsql:host=localhost;dbname=dbkekentin;', 'kekentin', 'passwd')
//twig
$loader = new \Twig\Loader\FilesystemLoader('vue/templates');

@ -1,97 +1,70 @@
var racine = '/~lebeaulato/WF-Website'; //Mettre votre chemin à vous
function editFieldUsername(id) {
var pElement = document.getElementById(id);// Récupérer l'élément <p> via son identifiant
//=============================== USERNAME ===============================
var currentValue = pElement.textContent.trim();// Obtenir le texte actuel du <p>
function editFieldUsername(id) {
var pElement = document.getElementById(id); // Récupérer l'élément <p> via son identifiant
var currentValue = pElement.textContent.trim(); // Obtenir le texte actuel du <p>
// Créer un champ de saisie <input> avec la valeur actuelle
var input = document.createElement('input');
input.type = 'text';
input.value = currentValue
input.class = 'changeValue';
input.value = currentValue;
input.class ='changeValue';
input.name='pseudo';
input.setAttribute('onblur', 'saveFieldUsername("' + id + '", this.value)'); // Sauvegarde lors de la perte de focus
// Créer un bouton de validation
var button = document.createElement('button');
button.textContent = 'Valider';
button.classList.add('saveButtonPasswd');
button.type ="submit";
// Remplacer le <p> par le champ <input>
// Remplacer le contenu du <p> par le champ <input> et le bouton
pElement.innerHTML = '';
pElement.appendChild(input);
pElement.appendChild(button);
input.focus(); // Mettre le focus sur le champ de saisie
}
//Sauvegarder les changements sur la vue pour le username
function saveFieldUsername(id, newValue) {
if (id === 'username') {
if (newValue.trim() === "") {
alert('Le nom d\'utilisateur ne peut pas être vide.');
document.getElementById(id).querySelector('input').focus();
return; // Ne pas sauvegarder si le nom d'utilisateur est vide
}
}
var pElement = document.getElementById(id);// Récupérer l'élément <p> via son identifiant
// Mettre à jour la valeur avec la nouvelle saisie
pElement.innerHTML = '<strong>' + newValue + ' <img class="imgModify" src="../images/modify.svg" onclick="editFieldUsername(\'' + id + '\')"/></strong>';
}
//=============================== EMAIL ===============================
function editFieldEmail(id) {
var pElement = document.getElementById(id);// Récupérer l'élément <p> via son identifiant
var currentValue = pElement.textContent.trim();// Obtenir le texte actuel du <p>
var pElement = document.getElementById(id); // Récupérer l'élément <p> via son identifiant
var currentValue = pElement.textContent.trim(); // Obtenir le texte actuel du <p>
// Créer un champ de saisie <input> avec la valeur actuelle
var input = document.createElement('input');
input.type = 'email';
input.value = currentValue
input.class = 'changeValue';
input.value = currentValue;
input.class= 'changeValue'; // Correction de l'attribut 'class'
input.name='email';
// Créer un bouton de validation
var button = document.createElement('button');
button.textContent = 'Valider';
button.classList.add('saveButtonPasswd');
button.type ="submit";
input.setAttribute('onblur', 'saveFieldEmail("' + id + '", this.value)'); // Sauvegarde lors de la perte de focus
// Remplacer le <p> par le champ <input>
// Remplacer le contenu du <p> par le champ <input> et le bouton
pElement.innerHTML = '';
pElement.appendChild(input);
pElement.appendChild(button);
input.focus(); // Mettre le focus sur le champ de saisie
}
//Sauvegarder les changements sur la vue pour l'email
function saveFieldEmail(id, newValue) {
if (id === 'email') {
if (!validateEmail(newValue)) {
alert('Adresse email invalide. Veuillez entrer un email valide.');
document.getElementById(id).querySelector('input').focus();
return; // Ne pas sauvegarder si l'email n'est pas valide
}
}
var pElement = document.getElementById(id); // Récupérer l'élément <p> via son identifiant
// Mettre à jour la valeur avec la nouvelle saisie
pElement.innerHTML = '<strong>' + newValue + ' <img class="imgModify" src="../images/modify.svg" onclick="editFieldEmail(\'' + id + '\')"/></strong>';
}
//Email valide
function validateEmail(email) {
var re = /^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/;// Regex pour vérifier le format de l'email
return re.test(String(email).toLowerCase());
}
//=============================== PASSWORD ===============================
function editFieldPassWd(id) {
var pElement = document.getElementById(id);// Récupérer l'élément <p> via son identifiant
pElement.innerHTML = '';// Effacer le contenu actuel de <p> pour insérer les inputs
// Créer le champ de saisie pour le nouveau mot de passe
@ -101,6 +74,7 @@ function editFieldPassWd(id) {
inputNewPass.classList.add('changeValue'); // Ajouter une classe CSS pour styliser l'input
inputNewPass.setAttribute('id', 'newPassword'); // Ajouter un ID pour la gestion
inputNewPass.classList.add('inputPasswd'); // Ajouter une classe au input
inputNewPass.name='passwdFirst';
// Créer le champ de saisie pour la confirmation du mot de passe
@ -110,16 +84,13 @@ function editFieldPassWd(id) {
inputConfirmPass.classList.add('changeValue'); // Ajouter une classe CSS pour styliser l'input
inputConfirmPass.setAttribute('id', 'confirmPassword'); // Ajouter un ID pour la gestion
inputConfirmPass.classList.add('inputPasswd'); // Ajouter une classe au input
inputConfirmPass.name='passwdSecond';
// Ajouter un bouton de sauvegarde
var saveButton = document.createElement('button');
saveButton.textContent = 'Sauvegarder le mot de passe';
saveButton.classList.add('saveButtonPasswd'); // Ajouter une classe au bouton
saveButton.onclick = function() {
savePasswordFields(id, inputNewPass.value, inputConfirmPass.value);
};
saveButton.type="submit";
// Ajouter les deux champs de saisie et le bouton dans l'élément <p>
pElement.appendChild(inputNewPass);
@ -130,29 +101,3 @@ function editFieldPassWd(id) {
inputNewPass.focus();// Mettre le focus sur le premier champ de saisie
}
function savePasswordFields(id, newPassword, confirmPassword) {
// Vérification si les champs sont vides
if (newPassword.trim() === "" || confirmPassword.trim() === ""){
alert("Le mot de passe n'a pas changé");
}
// Vérification de la correspondance des deux mots de passe
if (newPassword === confirmPassword) {
var pElement = document.getElementById(id);// Récupérer l'élément <p> via son identifiant
// Remplacer les champs input par le texte masqué
pElement.innerHTML ='<strong>Votre mot de passe</strong><img class="imgModify" src="{{ racine }}/images/modify.svg" onclick="editFieldPassWd(\'' + id + '\')"/>';
alert('Mot de passe mis à jour avec succès');
// fonction pour envoyer les nouveaux mots de passe au serveur
} else {
alert('Les mots de passe ne correspondent pas.');
}
}

@ -0,0 +1,57 @@
@import url(./style.css);
@import url('https://fonts.googleapis.com/css2?family=Lemon&display=swap');
body, html {
height: 100%;
overflow: hidden;
}
/* ====== DARK MODE ====== */
body.dark-mode h1, body.dark-mode h2, body.dark-mode p {
color: white;
font-family: "Lemon", serif;
text-align: center;
}
/* ====== LIGHT MODE ====== */
body.light-mode h1, body.light-mode h2, body.light-mode p {
color: black;
font-family: "Lemon", serif;
text-align: center;
}
/* ====== OTHER ====== */
#form {
width: 80%;
height: 83%;
display: flex;
justify-content: center;
align-items: center;
}
body.dark-mode #box {
background-color: #1b0048;
padding: 20px;
width: 50%;
margin: auto;
border-radius: 15px;
border: 1px solid #6100ff;
}
/* ====== DIVERS ====== */
#contentField, #characterField, #sourceField, #imageField {
}
#contentField p, #characterField p, #sourceField p, #imageField p {
}
#confirm {
}

@ -9,11 +9,14 @@ Class FrontControler{
private Connection $co;
/**
* @throws \Exception
*/
public function __construct($co){
global $twig,$racine;
$this->listAction = ['visitor' => array('accueil','search','quote','login','signin','validlogin','validsignin'),
'user' => array('quiz','commentary','logout','addComment','favorite','profil','addFav','supFav'),
'user' => array('quiz','commentary','logout','addComment','favorite','profil','addFav','supFav','changedata', 'submit', 'validsubmit'),
'admin' => array('null')];
$dVueEreur = [];
@ -47,6 +50,9 @@ Class FrontControler{
$router->map('GET|POST', '/validsignin', 'VisitorControler','validsignin');
$router->map('GET|POST', '/addFav/[i:id]', 'UserControler','addFav');
$router->map('GET|POST', '/supFav/[i:id]', 'UserControler','supFav');
$router->map('GET|POST', '/changedata', 'UserControler','changedata');
$router->map('GET|POST', '/submit', 'UserControler', 'submit');
$router->map('GET|POST', '/validsubmit', 'UserControler', 'validsubmit');
$match = $router->match();

@ -1,26 +1,26 @@
<?php
namespace Controleur;
use Gateway\CharacterGateway;
use Gateway\SourceGateway;
use Model\CharacterModel;
use Model\CommentaryModel;
use Gateway\CommentaryGateway;
use Model\SourceModel;
use Model\UserModel;
use Gateway\UserGateway;
use Model\QuoteModel;
use Gateway\QuoteGateway;
use Entity\QuestionEntity;
use Gateway\Connection;
use Gateway\QuestionGateway;
use Gateway\QuizGateway;
use Gateway\QuizQuestionGateway;
use Model\QuestionModel;
use Model\QuizModel;
use Model\QuizQuestionModel;
use Twig\Environment;
use Twig\Error\LoaderError;
use Twig\Error\RuntimeError;
use Twig\Error\SyntaxError;
use Twig\Loader\FilesystemLoader;
use Verification\Verification;
use Enum\TypeSourceEnum;
class UserControler {
@ -49,7 +49,9 @@ class UserControler {
public function addComment(){
global $racine;
$id = $_POST['idQuote'];
$this->cMod->createComment($_POST['content'],$_POST['idQuote'],$this->uMod->getIdByUsername($_SESSION['user']));
$this->cMod->createComment(Verification::verifChar($_POST['content']),
Verification::verifChar($_POST['idQuote']),
$this->uMod->getIdByUsername(Verification::verifChar($_SESSION['user'])));
header("Location:".$racine."/quote/$id");
}
@ -81,7 +83,7 @@ class UserControler {
switch ($action) {
case 'canswer':
if ($this->CorrectAnswer())
$_SESSION['score'] = isset($_SESSION['score']) ? ($_SESSION['score'] + 1) : 1;
$_SESSION['score'] = Verification::verifChar( isset( $_SESSION['score']) ? ($_SESSION['score'] + 1) : 1 ) ;
$this->continueQuiz($id, $nb_questions);
break;
default:
@ -91,8 +93,8 @@ class UserControler {
// page erreur
break;
default:
$_SESSION['score'] = $_SESSION['score'] ?? 0;
$this->showQuestion($id, $_SESSION['no_question'] ?? 0);
$_SESSION['score'] = Verification::verifChar($_SESSION['score'] ?? 0);
$this->showQuestion($id, Verification::verifChar($_SESSION['no_question'] ?? 0));
break;
}
}
@ -107,9 +109,8 @@ class UserControler {
{
global $racine;
$score = $_SESSION['score'];
$_SESSION['no_question'] = isset($_SESSION['no_question']) ? ($_SESSION['no_question'] + 1) : 1;
$_SESSION['no_question'] = Verification::verifChar( isset($_SESSION['no_question']) ? ($_SESSION['no_question'] + 1) : 1);
if ($_SESSION['no_question'] >= $total_questions) {
// session_destroy();
$_SESSION['no_question'] = 0;
$this->endQuiz($id_quiz, $score);
}
@ -137,10 +138,10 @@ class UserControler {
public function CorrectAnswer() : bool
{
$answera = $_POST['answera'] ?? null;
$answerb = $_POST['answerb'] ?? null;
$answerc = $_POST['answerc'] ?? null;
$answerd = $_POST['answerd'] ?? null;
$answera = Verification::verifChar($_POST['answera'] ?? null);
$answerb = Verification::verifChar($_POST['answerb'] ?? null);
$answerc = Verification::verifChar($_POST['answerc'] ?? null);
$answerd = Verification::verifChar($_POST['answerd'] ?? null);
$id= null;
$answer = null;
@ -178,7 +179,7 @@ class UserControler {
*/
public function showQuestion(int $id, int $num) : void
{
global $vues;
global $vues,$twig;
$q = $this->GetQuestion($id);
$question = $q[$num] ?? $q[0];
$idquestion = $question->getIdQuestion();
@ -199,7 +200,7 @@ class UserControler {
public function addFav(array $arg){
global $racine;
$id= $arg['id'] ?? 1;
$this->uMod->addFavorite($_SESSION["user"],$id);
$this->uMod->addFavorite(Verification::verifChar($_SESSION["user"]),$id);
header("Location:" . $racine . "/quote/$id");
}
@ -207,7 +208,145 @@ class UserControler {
public function supFav(array $arg){
global $racine;
$id= $arg['id'] ?? 1;
$this->uMod->supFavorite($_SESSION["user"],$id);
$this->uMod->supFavorite(Verification::verifChar($_SESSION["user"]),$id);
header("Location:". $racine ."/quote/$id");
}
public function changedata() : void
{
global $vues, $racine;
if ($_POST)
{
$newImage = $_POST['image'] ?? null;
$newPseudo = $_POST['pseudo'] ?? null;
$newEmail = $_POST['email'] ?? null;
$newMdpFirst = $_POST['passwdFirst'] ?? null;
$newMdpSecond = $_POST['passwdSecond'] ?? null;
//Modif le pseudo
if($newPseudo){
$user = $this-> uMod->setUsername($_SESSION['user'], $newPseudo);
if($user == $newPseudo){ //Si le pseudo existe déjà
$_SESSION['user'] = $newPseudo;
}
}
else if($newEmail){
$user = $this-> uMod->setEmail($_SESSION['user'], $newEmail);
}
else if($newMdpFirst && $newMdpSecond){
if($newMdpFirst == $newMdpSecond){
$option = ['cost' => 12];
$newPassWd = password_hash($newMdpFirst, PASSWORD_BCRYPT, $option);
$user = $this-> uMod->setPassWd($_SESSION['user'], $newPassWd);
}
}
else if($newImage){
$user = $this->uMod->setImage($_SESSION['user']);
}
}
header("Location: ". $racine."/profil");
}
/**
* @throws SyntaxError
* @throws RuntimeError
* @throws LoaderError
*/
public function submit() : void
{
global $vues;
require_once $vues['submitQuote'];
}
/**
* @throws SyntaxError
* @throws RuntimeError
* @throws LoaderError
*/
public function toSubmit() : ?array
{
global $co;
if ($_POST)
{
$content = $_POST['content'] ?? null;
$character = $_POST['character'] ?? null;
$source = $_POST['source'] ?? null;
//$img = $_POST['img'] ?? null;
$errors = [null, null];
$gw = new CharacterGateway($co);
$mdl = new CharacterModel($gw);
$character = $mdl -> getCharacterByName($character);
$gw = new SourceGateway($co);
$mdl = new SourceModel($gw);
$source = $mdl -> getSourceByTitle($source);
if (!$character)
$errors[0] = "Personnage inexistant";
if (!$source)
$errors[1] = "Source inexistante";
if ($errors[0] || $errors[1])
{
global $twig;
echo $twig->render("submitQuote.html.twig", ['errors' => $errors]);
exit();
}
$gw = new QuoteGateway($co);
$mdl = new QuoteModel($gw);
$mdl -> insert4User($content, '/imgPath', 'fr', $this -> getIdOfUser(), $source->getIdSource(), $character->getIdCharacter());
return [$content, $_POST['character'], $_POST['source']];
}
return null;
}
/**
* @throws SyntaxError
* @throws RuntimeError
* @throws LoaderError
*/
public function validsubmit() : void
{
$recap = $this -> toSubmit();
if ($recap)
{
$this -> recapSubmitQuote($recap);
}
}
/**
* @throws RuntimeError
* @throws SyntaxError
* @throws LoaderError
*/
public function recapSubmitQuote(?array $recap) : void
{
global $twig;
echo $twig -> render("recapSubmitQuote.html.twig", ['content' => $recap[0], 'character' => $recap[1], 'source' => $recap[2]]);
}
public function getIdOfUser() : ?int
{
if (isset($_SESSION['user']))
{
global $co;
$gw = new UserGateway($co);
$mdl = new UserModel($gw);
return $mdl -> getUsername($_SESSION['user']) -> getId();
}
return null;
}
}

@ -13,6 +13,7 @@ use Twig\Error\LoaderError;
use Twig\Error\RuntimeError;
use Twig\Error\SyntaxError;
use Verification\Verification;
Class VisitorControler {
@ -27,6 +28,7 @@ Class VisitorControler {
private array $errors;
/**
* @throws SyntaxError
* @throws RuntimeError
@ -68,9 +70,9 @@ Class VisitorControler {
public function search(array $arg){
global $vues;
$type = ($_POST['type'] ?? "");
$search = ( $_POST['search'] ?? NULL);
$filtre = ($arg['filtre'] ?? []);
$type = ( Verification::verifChar( $_POST['type'] ?? ""));
$search = ( Verification::verifChar( $_POST['search'] ?? NULL));
$filtre = ( Verification::verifArrayChar( $arg['filtre'] ?? []));
$tq=$this->sMod->searchQuote($type,$search,$filtre);
@ -88,9 +90,9 @@ Class VisitorControler {
global $vues;
require_once $vues['login'];
// global $twig;
//global $twig;
// echo $twig->render("login.html.twig");
//echo $twig->render("login.html.twig");
//$this -> toLogIn();
}
@ -104,10 +106,13 @@ Class VisitorControler {
{
global $vues;
require_once $vues['signin'];
}
//global $twig;
//echo $twig->render("login.html.twig");
//$this -> signin();
}
public function validlogin() : void
@ -115,8 +120,8 @@ Class VisitorControler {
global $vues,$racine;
if ($_POST)
{
$pseudo = $_POST['pseudo'] ?? null;
$mdp = $_POST['mdp'] ?? null;
$pseudo = Verification::verifChar($_POST['pseudo'] ?? null);
$mdp = Verification::verifChar($_POST['mdp'] ?? null);
$user = $this -> uMod -> getUsername($pseudo);
@ -124,9 +129,9 @@ Class VisitorControler {
{
if (password_verify($mdp, $user->getPassword()))
{
$_SESSION['user'] = $pseudo;
$_SESSION['user'] = Verification::verifChar($pseudo);
$_SESSION['role'] = 'user';
header("Location: ". $racine); ///~kekentin/WF/WF-Website/
header("Location: ". $racine);
exit();
}else
{
@ -156,10 +161,10 @@ Class VisitorControler {
global $vues,$racine;
if ($_POST) {
$pseudo = $_POST['pseudo'] ?? null;
$email = $_POST['email'] ?? null;
$mdp = $_POST['mdp'] ?? null;
$cmdp = $_POST['cmdp'] ?? null;
$pseudo = Verification::verifChar($_POST['pseudo'] ?? null);
$email = Verification::verifChar($_POST['email'] ?? null);
$mdp = Verification::verifChar($_POST['mdp'] ?? null);
$cmdp = Verification::verifChar($_POST['cmdp'] ?? null);
if ($mdp != $cmdp) {
$errors[2] = "Mots de passe incorrects";
@ -191,8 +196,8 @@ Class VisitorControler {
}
else echo $this->uMod->insertUser($pseudo, $email, $hmdp);
$_SESSION["role"] = 'user';
$_SESSION["user"] = $pseudo;
$_SESSION["role"] = Verification::verifChar('user');
$_SESSION["user"] = Verification::verifChar($pseudo);
header("Location: ". $racine);
}

@ -1,6 +1,8 @@
<?php
namespace Entity;
use Enum\TypeSourceEnum;
class SourceEntity
{
private int $id_source;
@ -9,16 +11,19 @@ class SourceEntity
private string $date;
private TypeSourceEnum $type;
/**
* @param int $id_source
* @param string $title
* @param string $date
*/
public function __construct(int $id_source, string $title, string $date)
public function __construct(int $id_source, string $title, string $date, TypeSourceEnum $type)
{
$this->id_source = $id_source;
$this->title = $title;
$this->date = $date;
//$this->type = $type;
}
/**
@ -70,8 +75,16 @@ class SourceEntity
}
public function getType(): TypeSourceEnum
{
return $this->type;
}
public function setType(TypeSourceEnum $type): void
{
$this->type = $type;
}
}

@ -0,0 +1,9 @@
<?php
namespace Enum;
enum TypeSourceEnum : string {
case Movie = 'movie';
case VideoGame = 'video-game';
case Anime = 'anime';
case TV = 'tv';
}

@ -11,56 +11,56 @@ class CharacterGateway extends Gateway
public function create(int $id_character, string $name , string $img_char) : bool
{
$query = "
INSERT INTO Characters
VALUES(:id_char, :name, :img_char)
INSERT INTO caracter
VALUES(:id_caracter, :caracter, :id_img)
";
return $this -> co -> executeQuery($query, [
'id_char' => array($id_character, PDO::PARAM_INT),
'name' => array($name, PDO::PARAM_STR),
'img_char' => array($img_char, PDO::PARAM_STR)
'id_caracter' => array($id_character, PDO::PARAM_INT),
'caracter' => array($name, PDO::PARAM_STR),
'id_img' => array($img_char, PDO::PARAM_STR)
]);
}
public function findById(int $id) : array
{
$query = "SELECT * FROM Characters WHERE id_char = :id_c";
$query = "SELECT * FROM caracter WHERE id_caracter = :id_c";
$this -> co -> executeQuery($query, ["id_c" => array($id, PDO::PARAM_INT)]);
return $this -> co -> getResults();
}
public function findByName(string $name) : array
{
$query = "SELECT * FROM Characters WHERE name = :n";
$query = "SELECT * FROM caracter WHERE caracter = :n";
$this -> co -> executeQuery($query, ["n" => array($name, PDO::PARAM_STR)]);
return $this -> co -> getResults();
}
public function findAll() : array
{
$query = "SELECT * FROM Characters";
$query = "SELECT * FROM caracter";
$this -> co -> executeQuery($query);
return $this -> co -> getResults();
}
public function delete(int $id) : bool
{
$query = "DELETE FROM Characters WHERE id_char = :id_c";
$query = "DELETE FROM caracter WHERE id_caracter = :id_c";
return $this -> co -> executeQuery($query, ["id_c" => array($id, PDO::PARAM_INT)]);
}
public function update(int $id_char, string $name, string $img_char) : bool
{
$query = "
UPDATE Characters
SET name = :n, img_char = :i
WHERE id_char = :id_c
UPDATE caracter
SET caracter = :n, id_img = :i
WHERE id_caracter = :id_c
";
return $this -> co -> executeQuery($query, [
"id_c" => array($id_char, PDO::PARAM_INT),
"name" => array($name, PDO::PARAM_STR),
"caracter" => array($name, PDO::PARAM_STR),
"i" => array($img_char, PDO::PARAM_STR)
]);
}

@ -1,22 +1,30 @@
<?php
namespace Gateway;
use PDO;
use PDOException;
Class QuoteGateway extends Gateway{
public function searchQuote(string $quote,int $numpage,string $language):array{
//recherche par citation
$query="SELECT q.id_quote, q.content, c.caracter, c.img_path, s.title, s.date, q.like, q.language FROM Quote q JOIN Caracter c ON c.id_caracter = q.id_caracter JOIN Source s ON s.id_source = q.id_source WHERE content LIKE '%:quote%' AND isValid = true AND language = :language LIMIT 20 OFFSET :page*20;";
$this->co->executeQuery($query,array(':quote' => array($quote,PDO::PARAM_STR),':page' => array($numpage,PDO::PARAM_INT),':language' => array($language,PDO::PARAM_STR)));
$result=$this->co->getResults();
return $result;
$query="SELECT q.id_quote, q.content, q.id_caracter, c.img_char, s.title, s.date, q.likes, q.langue
FROM Quote q
JOIN Source s ON s.id_source = q.id_source
WHERE content LIKE '%:quote%' AND is_valid = true AND langue = :langue
LIMIT 20 OFFSET :page*20;";
$this->co->executeQuery($query,array(':quote' => array($quote,PDO::PARAM_STR),':page' => array($numpage,PDO::PARAM_INT),':langue' => array($language,PDO::PARAM_STR)));
return $this->co->getResults();
}
public function searchSource(string $source,int $numpage,string $language):array{
//recherche par source
$query="SELECT q.id_quote, q.content, c.caracter, c.img_path, s.title, s.date, q.like, q.language FROM Quote q JOIN Caracter c ON c.id_caracter = q.id_caracter JOIN Source s ON s.id_source = q.id_source WHERE s.title LIKE '%:source%' AND q.isValid = true AND language = :language LIMIT 20 OFFSET :page*20;";
$this->co->executeQuery($query,array(':source' => array($source,PDO::PARAM_STR),':page' => array($numpage,PDO::PARAM_INT),':language' => array($language,PDO::PARAM_STR)));
$query="SELECT q.id_quote, q.content, c.character, c.img_path, s.title, s.date, q.likes, q.langue
FROM Quote q
JOIN Caracter c ON c.id_caracter = q.character
JOIN Source s ON s.id_source = q.id_source
WHERE s.title LIKE '%:source%' AND q.is_valid = true AND langue = :langue
LIMIT 20 OFFSET :page*20;";
$this->co->executeQuery($query,array(':source' => array($source,PDO::PARAM_STR),':page' => array($numpage,PDO::PARAM_INT),':langue' => array($language,PDO::PARAM_STR)));
$result=$this->co->getResults();
return $result;
}
@ -24,8 +32,13 @@ Class QuoteGateway extends Gateway{
public function searchPers(string $Carac,int $numpage,string $language):array{
//recherche par personnage
$query="SELECT q.id_quote, q.content, c.caracter, c.img_path, s.title, s.date, q.like, q.language FROM Quote q JOIN Caracter c ON c.id_caracter = q.id_caracter JOIN Source s ON s.id_source = q.id_source WHERE c.caracter LIKE '%:pers%' AND q.isValid = true AND language = :language LIMIT 20 OFFSET :page*20;";
$this->co->executeQuery($query,array(':pers' => array($Pers,PDO::PARAM_STR),':page' => array($numpage,PDO::PARAM_INT),':language' => array($language,PDO::PARAM_STR)));
$query="SELECT q.id_quote, q.content, c.character, c.img_path, s.title, s.date, q.likes, q.langue
FROM Quote q
JOIN Caracter c ON c.id_caracter = q.character
JOIN Source s ON s.id_source = q.id_source
WHERE c.character LIKE '%:pers%' AND q.is_valid = true AND langue = :langue
LIMIT 20 OFFSET :page*20;";
$this->co->executeQuery($query,array(':pers' => array($Pers,PDO::PARAM_STR),':page' => array($numpage,PDO::PARAM_INT),':langue' => array($language,PDO::PARAM_STR)));
$result=$this->co->getResults();
return $result;
}
@ -33,7 +46,12 @@ Class QuoteGateway extends Gateway{
public function searchId(string $id):array{
//recherche par id
$query="SELECT q.id_quote, q.content, c.caracter, i.imgPath, s.title, s.dates, q.likes, q.langue FROM Quote q JOIN Caracter c ON c.id_caracter = q.id_caracter JOIN Source s ON s.id_source = q.id_source JOIN Image i ON c.id_img = i.id_img WHERE q.id_quote = :id AND q.isvalide = true;";
$query="SELECT q.id_quote, q.content, c.caracter, i.imgPath, s.title, s.dates, q.likes, q.langue
FROM Quote q
JOIN Caracter c ON c.id_caracter = q.id_caracter
JOIN Source s ON s.id_source = q.id_source
JOIN Image i ON c.id_img = i.id_img
WHERE q.id_quote = :id AND q.isvalide = true;";
$this->co->executeQuery($query,array(':id' => array($id,PDO::PARAM_STR)));
$result=$this->co->getResults();
return $result;
@ -126,6 +144,32 @@ Class QuoteGateway extends Gateway{
}
}
public function autoincrement() : int
{
$query = "SELECT Max(id_quote) + 1 as id FROM Quote;";
$this->co->executeQuery($query);
return ($this -> co ->getResults())[0]['id'];
}
public function insert4User(string $content, string $img_path, string $langage, int $user, int $source, int $character) : bool
{
$query = "
INSERT INTO Quote (id_quote, content, langue, reason, id_source, id_caracter, id_user_verif, img_path)
VALUES (:id, :content, :langage, :reason, :source, :character, :user, :img_path)
";
return $this->co->executeQuery($query, [
':id' => array($this->autoincrement(), PDO::PARAM_INT),
':content' => array($content, PDO::PARAM_STR),
':img_path' => array($img_path, PDO::PARAM_STR),
':langage' => array($langage, PDO::PARAM_STR),
':user' => array($user, PDO::PARAM_INT),
':reason' => array('À vérifier', PDO::PARAM_STR),
':source' => array($source, PDO::PARAM_STR),
':character' => array($character, PDO::PARAM_STR)
]);
}
//======================== PARTI ADMIN ========================
//Probablement à déplacer dans un autre fichier
@ -133,8 +177,7 @@ Class QuoteGateway extends Gateway{
//obtenir les quotes en attentes de validation par l'admin
$query = 'SELECT * FROM Quote WHERE isValid=:bool';
$this->co->executeQuery($query,array(':bool' => array(false, PDO::PARAM_BOOL)));
$result=$this->co->getResults();
return $result;
return $this->co->getResults();
}
public function validQuote(int $id){
@ -152,61 +195,56 @@ Class QuoteGateway extends Gateway{
public function updateContent(int $id, string $newContent):array{
//Update le contexte de quote passé en paramètre
$queryUpdate = 'UPDATE Quote SET content=:newContent WHERE id_quote=:idQuote';
$con->executeQuery($queryUpdate, array(':idQuote'=>array($id, PDO::PARAM_STR), ':newContent'=> array($newContent, PDO::PARAM_STR)));
$this->co->executeQuery($queryUpdate, array(':idQuote'=>array($id, PDO::PARAM_STR), ':newContent'=> array($newContent, PDO::PARAM_STR)));
//Renvoie le nouveau contexte de quote
$queryReponse = 'SELECT content FROM Quote WHERE id_quote=:idQuote';
$con->executeQuery($queryReponse, array(':idQuote'=>array($id, PDO::PARAM_STR)));
$result = $con->getResults();
return $result;
$this->co->executeQuery($queryReponse, array(':idQuote'=>array($id, PDO::PARAM_STR)));
return $this->co->getResults();
}
public function updateTimeCode(int $id, string $newTimeCode):array{
//Update le time code de quote passé en paramètre
$queryUpdate = 'UPDATE Quote SET timecode=:newTimeCode WHERE id_quote=:idQuote';
$con->executeQuery($queryUpdate, array(':idQuote'=>array($id, PDO::PARAM_STR), ':newTimeCode'=> array($newTimeCode, PDO::PARAM_STR)));
$this->co->executeQuery($queryUpdate, array(':idQuote'=>array($id, PDO::PARAM_STR), ':newTimeCode'=> array($newTimeCode, PDO::PARAM_STR)));
//Renvoie le nouveau contexte de quote
$queryReponse = 'SELECT timecode FROM Quote WHERE id_quote=:idQuote';
$con->executeQuery($queryReponse, array(':idQuote'=>array($id, PDO::PARAM_STR)));
$result = $con->getResults();
return $result;
$this->co->executeQuery($queryReponse, array(':idQuote'=>array($id, PDO::PARAM_STR)));
return $this->co->getResults();
}
public function updateDate(int $id, int $newDate):array{
//Update la date de quote passé en paramètre
$queryUpdate = 'UPDATE Source SET dateSource =:newdate WHERE idSource = (SELECT idSource FROM Quote WHERE idQuote =:idQuote)';
$con->executeQuery($queryUpdate, array(':idQuote'=>array($id, PDO::PARAM_STR), ':newDate'=> array($newDate, PDO::PARAM_INT)));
$this->co->executeQuery($queryUpdate, array(':idQuote'=>array($id, PDO::PARAM_STR), ':newDate'=> array($newDate, PDO::PARAM_INT)));
//Renvoie la nouvelle date de quote
$queryReponse = 'SELECT s.dateSource FROM Source s, Quote q WHERE id_quote=:idQuote AND s.idSource = q.idSource';
$con->executeQuery($queryReponse, array(':idQuote'=>array($id, PDO::PARAM_STR)));
$result = $con->getResults();
return $result;
$this->co->executeQuery($queryReponse, array(':idQuote'=>array($id, PDO::PARAM_STR)));
return $this->co->getResults();
}
public function updateTitle(int $id, string $newTitle):array{
//Update le titre de l'oeuvre de quote passé en paramètre
$queryUpdate = 'UPDATE Source SET title =:newTitle WHERE idSource = (SELECT idSource FROM Quote WHERE idQuote =:idQuote)';
$con->executeQuery($queryUpdate, array(':idQuote'=>array($id, PDO::PARAM_STR), ':newTitle'=> array($newTitle, PDO::PARAM_STR)));
$this->co->executeQuery($queryUpdate, array(':idQuote'=>array($id, PDO::PARAM_STR), ':newTitle'=> array($newTitle, PDO::PARAM_STR)));
//Renvoie le nouveau titre de quote
$queryReponse = 'SELECT s.title FROM Source s, Quote q WHERE id_quote=:idQuote AND s.idSource = q.idSource';
$con->executeQuery($queryReponse, array(':idQuote'=>array($id, PDO::PARAM_STR)));
$result = $con->getResults();
return $result;
$this->co->executeQuery($queryReponse, array(':idQuote'=>array($id, PDO::PARAM_STR)));
return $this->co->getResults();
}
public function updateNameCharacter(int $id, string $newNameCharacter):array{
//Update le personnage de l'oeuvre de quote passé en paramètre
$queryUpdate = 'UPDATE Character SET name =:newNameCharacter WHERE idCharacter = (SELECT idCharacter FROM Quote WHERE idQuote =:idQuote)';
$con->executeQuery($queryUpdate, array(':idQuote'=>array($id, PDO::PARAM_STR), ':newNameCharacter'=> array($newNameCharacter, PDO::PARAM_STR)));
$this->co->executeQuery($queryUpdate, array(':idQuote'=>array($id, PDO::PARAM_STR), ':newNameCharacter'=> array($newNameCharacter, PDO::PARAM_STR)));
//Renvoie le nouveau personnage de quote
$queryReponse = 'SELECT c.title FROM Character c, Quote q WHERE id_quote=:idQuote AND c.idCharacter = q.idCharacter';
$con->executeQuery($queryReponse, array(':idQuote'=>array($id, PDO::PARAM_STR)));
$result = $con->getResults();
return $result;
$this->co->executeQuery($queryReponse, array(':idQuote'=>array($id, PDO::PARAM_STR)));
return $this->co->getResults();
}
}

@ -1,6 +1,8 @@
<?php
namespace Gateway;
use Connection;
use Enum\TypeSourceEnum;
use Entity\SourceEntity;
use PDO;
class SourceGateway extends Gateway{
@ -8,13 +10,13 @@ class SourceGateway extends Gateway{
{
$query = "
INSERT INTO Source
VALUES(:id_source, :title, :date)
VALUES( :title, :date)
";
return $this -> co -> executeQuery($query, [
"id_source" => array($s->getIdSource(), PDO::PARAM_INT),
"title" => array($s->getTitle(), PDO::PARAM_STR),
"date" => array($s->getDate(), PDO::PARAM_STR)
"date" => array($s->getDate(), PDO::PARAM_STR),
"type" => array($s->getType(), PDO::PARAM_STR)
]);
}
@ -30,7 +32,7 @@ class SourceGateway extends Gateway{
{
$query = "SELECT * FROM Source WHERE title = :t";
$this -> co -> executeQuery($query, ["title" => array($t, PDO::PARAM_STR)]);
$this -> co -> executeQuery($query, ["t" => array($t, PDO::PARAM_STR)]);
return $res = $this -> co -> getResults();
// if ($res)
@ -44,19 +46,21 @@ class SourceGateway extends Gateway{
public function findByDate(string $d) : array
{
$query = "SELECT * FROM Source WHERE date = :d";
$query = "SELECT * FROM Source WHERE dates = :d";
$this -> co -> executeQuery($query, ["date" => array($d, PDO::PARAM_STR)]);
$res = $this -> co -> getResults();
$this -> co -> executeQuery($query, ["d" => array($d, PDO::PARAM_STR)]);
return $this -> co -> getResults();
}
if ($res)
return new sourceEntity(
$res["id_source"],
$res["title"],
$res["date"]
);
return null;
/*
public function findByType(TypeSourceEnum $type) : array
{
$query = "SELECT * FROM Source WHERE type = :t";
$this -> co -> executeQuery($query, ["t" => array($type, PDO::PARAM_STR)]);
return $this -> co -> getResults();
}
*/
public function findAll() : array
{
@ -71,7 +75,8 @@ class SourceGateway extends Gateway{
$sources[] = new sourceEntity(
$source["id_source"],
$source["title"],
$source["date"]
$source["date"],
TypeSourceEnum::Movie//$res["source"]
);
}
return $sources;

@ -70,7 +70,7 @@ Class UserGateway extends Gateway{
//obtenir les information d'un user
public function findDataUser(int $id):array{
$query = 'SELECT * FROM Users WHERE id_user=:idUser';
$query = 'SELECT u.id_user , u.username , u.email , u.password , i.imgPath , u.creation FROM Users WHERE id_user=:idUser';
$this->co->executeQuery($query, array(':idUser'=>array($id, PDO::PARAM_STR)));
$result = $this->co->getResults();
return $result;
@ -78,7 +78,7 @@ Class UserGateway extends Gateway{
// obtenir les informations d'un user selon son pseudo
public function findUsername(string $username):array{
$query = 'SELECT u.id_user , u.username , u.email , u.password , i.imgPath , u.creation FROM Users u Join Image i on i.id_img=u.img WHERE username= :username';
$query = 'SELECT * FROM Users u Join Image i on i.id_img=u.img WHERE username= :username';
$this->co->executeQuery($query, array(':username'=>array($username, PDO::PARAM_STR)));
return $this->co->getResults();
}
@ -89,47 +89,76 @@ Class UserGateway extends Gateway{
return $this->co->getResults();
}
public function IsExisteUsername(string $username): bool {
$query = 'SELECT COUNT(*) as count FROM Users WHERE username = :username';
$this->co->executeQuery($query, array(':username' => array($username, PDO::PARAM_STR)));
$results = $this->co->getResults();
return $results[0]['count'] > 0; // retourne true si "count" > 0)
}
public function IsExisteEmail(string $email): bool {
$query = 'SELECT COUNT(*) as count FROM Users WHERE email = :email';
$this->co->executeQuery($query, array(':email' => array($email, PDO::PARAM_STR)));
$results = $this->co->getResults();
return $results[0]['count'] > 0; // retourne true si "count" > 0)
}
// ===================== UPDATE FUNCTION =====================
public function updateUsername(int $id, string $newUsername):bool{
//Update Username
public function updateUsername(string $username, string $newUsername):array{
//Update le nom du user passé en paramètre
$queryUpdate = 'UPDATE Users SET username=:newUsername WHERE id_user=:idUser';
$this->co->executeQuery($queryUpdate, array(':idUser'=>array($id, PDO::PARAM_STR), ':newUsername'=> array($newUsername, PDO::PARAM_STR)));
$queryUpdate = 'UPDATE Users SET username=:newUsername WHERE username=:username';
$this->co->executeQuery($queryUpdate, array(':username'=>array($username, PDO::PARAM_STR), ':newUsername'=> array($newUsername, PDO::PARAM_STR)));
//Renvoie le nouveau nom du user
$queryReponse = 'SELECT username FROM Users WHERE id_user=:idUser';
$queryReponse = 'SELECT username FROM Users WHERE username=:idUser';
return $this->co->executeQuery($queryReponse, array($id=>array($newUsername, PDO::PARAM_STR)));
$this->co->executeQuery($queryReponse, array(':idUser'=>array($newUsername, PDO::PARAM_STR)));
return $this->co->getResults();
}
public function updateEmail(int $id, string $newEmail):bool{
//Update Email
public function updateEmail(string $username, string $newEmail):array{
//Update le email du user passé en paramètre
$queryUpdate = 'UPDATE Users SET email=:newEmail WHERE id_user=:idUser';
$this->co->executeQuery($queryUpdate, array(':idUser'=>array($id, PDO::PARAM_STR), ':newEmail'=> array($newEmail, PDO::PARAM_STR)));
$queryUpdate = 'UPDATE Users SET email=:newEmail WHERE username=:username';
$this->co->executeQuery($queryUpdate, array(':username'=>array($username, PDO::PARAM_STR), ':newEmail'=> array($newEmail, PDO::PARAM_STR)));
//Renvoie le nouveau email du user
$queryReponse = 'SELECT email FROM Users WHERE id_user=:idUser';
return $this->co->executeQuery($queryReponse, array(':idUser'=>array($id, PDO::PARAM_STR)));
$queryReponse = 'SELECT email FROM Users WHERE username=:username';
$this->co->executeQuery($queryReponse, array(':username'=>array($username, PDO::PARAM_STR)));
return $this->co->getResults();
}
public function updateImg(int $id, int $newImg):array{
public function updateImg(string $username):array{
$id_image = $this->randomImg();
//Update l'image du user passé en paramètre
$query = 'UPDATE Users SET img_prfl=:newImg WHERE id_user=:idUser';
$this->co->executeQuery($query, array(':idUser'=>array($id, PDO::PARAM_STR), ':newImg'=> array($newImg, PDO::PARAM_STR)));
$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)));
//Renvoie la nouvelle image du user
$queryReponse = 'SELECT img_prfl FROM Users WHERE id_user=:idUser';
$this->co->executeQuery($queryReponse, array(':idUser'=>array($id, PDO::PARAM_STR)));
$result = $this->co->getResults();
return $result;
$queryReponse = 'SELECT img FROM Users WHERE username=:username';
$this->co->executeQuery($queryReponse, array(':username'=>array($username, PDO::PARAM_STR)));
return $this->co->getResults();
}
public function updatePasswd(int $id, string $newPassWd):array{
public function updatePasswd(string $username, string $newPassWd):void{
//Update le passwd du user passé en paramètre
$query = 'UPDATE Users SET pssword=:newPassWd WHERE id_user=:idUser';
$this->co->executeQuery($query, array(':idUser'=>array($id, PDO::PARAM_STR), ':newPassWd'=> array($newPassWd, PDO::PARAM_STR)));
$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 getIdUser(string $username):array{
$query = 'SELECT id_user FROM Users WHERE username=:username';
$this->co->executeQuery($query, array(':username'=>array($username, PDO::PARAM_STR)));

@ -19,9 +19,9 @@ class CharacterModel extends Model
$c = $this -> gateway -> findById($id_character);
if ($c)
return new CharacterEntity(
$c['id_character'],
$c['name'],
$c['img_path']
$c['id_caracter'],
$c['caracter'],
$c['id_img']
);
return null;
}
@ -31,9 +31,9 @@ class CharacterModel extends Model
$c = $this -> gateway -> findByName($name);
if ($c)
return new CharacterEntity(
$c[0]['id_character'],
$c[0]['name'],
$c[0]['img_path']
$c[0]['id_caracter'],
$c[0]['caracter'],
$c[0]['id_img']
);
return null;
}
@ -47,9 +47,9 @@ class CharacterModel extends Model
foreach ($c as $character)
{
$characters[] = new CharacterEntity(
$character['id_character'],
$character['name'],
$character['img_path']
$character['id_caracter'],
$character['caracter'],
$character['id_img']
);
}
return $characters;

@ -45,6 +45,12 @@
}
return $tabQ;
}
public function insert4User(string $content, string $img_path, string $langage, int $user, int $source, int $character) : bool
{
return $this->gateway->insert4User($content, $img_path, $langage, $user, $source, $character);
}
}
?>

@ -76,39 +76,60 @@
return null;
}
public function setUsername(int $id, string $newUsername){
$res = $this->gateway->updateUsername($id,$newUsername);
$src[] = $res[0]['username'];
public function IsExisteUsername(string $username):bool{
return $this->gateway->IsExisteUsername($username);
}
return $src;
public function IsExisteEmail(string $email):bool{
return $this->gateway->IsExisteEmail($email);
}
public function setEmail(int $id, string $newEmail){
$res = $this->gateway->updateEmail($id,$newEmail);
$src[] = $res[0]['email'];
return $src;
public function setUsername(string $username, string $newUsername): string {
if ($this->IsExisteUsername($newUsername)) {// Vérifier si le nouveau nom d'utilisateur existe déjà
return $username;// Retourne l'ancien nom d'utilisateur sans modification
}
public function setImg(int $id, int $newImg){
$res = $this->gateway->updateImg($id,$newImg);
$src[] = $res[0]['img'];
$res = $this->gateway->updateUsername($username, $newUsername);// Sinon, mettre à jour le nom d'utilisateur
return $src;
// Retourner le nouveau nom d'utilisateur après modification
if (!empty($res) && isset($res[0]['username'])) {
return $res[0]['username'];
}
// En cas d'échec, retourne l'ancien nom d'utilisateur
return $username;
}
public function setEmail(string $username, string $newEmail){
if ($this->IsExisteEmail($newEmail)) {
return $email;
}
$res = $this->gateway->updateEmail($username,$newEmail);
if (!empty($res) && isset($res[0]['email'])) {
return $res[0]['email'];
}
return $username;// En cas d'échec, retourne l'ancien email
}
public function setPassWd(int $id, string $newPassWd){
$res = $this->gateway->updatePasswd($id,$newPassWd);
$src[] = $res[0]['pssword'];
public function setImage(string $username){
$res = $this->gateway->updateImg($username);
$src[] = $res[0]['img'];
return $src;
}
public function getIdByUsername(string $username){
$res = $this->gateway->getIdUser($username);
return $res[0]['id_user'];
public function setPassWd(string $username, string $newPassWd):void{
$res = $this->gateway->updatePasswd($username,$newPassWd);
}
public function isFavorite(?string $username, int $idq): bool {
if($_SESSION["user"] == NULL){
return false;
@ -119,6 +140,7 @@
}
}
public function addFavorite(string $username, int $id){
$this->gateway->addFavorite($username,$id);
}
@ -126,6 +148,11 @@
public function supFavorite(string $username, int $id){
$this->gateway->supFavorite($username,$id);
}
public function getIdByUsername(string $username){
$res = $this->gateway->getIdUser($username);
return $res[0]['id_user'];
}
}
?>

@ -1,17 +1,17 @@
<?php
namespace Model;
use Entity\SourceEntity;
use Gateway\SourceGateway;
use Gateway\Gateway;
use Enum\TypeSourceEnum;
class SourceModel extends Model
{
public function createSource(int $id_source, string $title, string $date) : bool
public function createSource(string $title, string $date, TypeSourceEnum $type) : bool
{
$q = new SourceEntity($id_source , $title, $date);
$q = new SourceEntity(-1,$title, $date, TypeSourceEnum::Movie/*$type*/);
return $this -> gateway -> create($q);
}
public function getSourceById(int $id_source) : ?SourceEntity
@ -22,40 +22,68 @@ class SourceModel extends Model
return new sourceEntity(
$res[0]["id_source"],
$res[0]["title"],
$res[0]["date"]
$res[0]["dates"],
TypeSourceEnum::Movie//from($res[0]["type"])
);
return null;
}
public function getSourceByTitle(string $title) : array
public function getSourceByTitle(string $title) : ?SourceEntity
{
$res = $this->gateway->findByTitle($title);
if ($res)
return new sourceEntity(
$res[0]["id_source"],
$res[0]["title"],
$res[0]["dates"],
TypeSourceEnum::Movie//from($res[0]["type"])
);
return null;
}
public function getSourceByDate(string $date) : array
{
$res = $this->gateway->findByDate($date);
$src = [];
foreach ($res as $sources) {
$src[] = new sourceEntity(
$sources["id_source"],
$sources["title"],
$sources["date"]
$sources["dates"],
TypeSourceEnum::from($sources["type"])
);
}
return $src;
}
public function getSourceByDate(string $date) : array
public function getSourceByType(TypeSourceEnum $type) : array
{
$res = $this->gateway->findByDate($date);
$res = $this->gateway->findByType($type);
$src = [];
foreach ($res as $sources) {
$src[] = new sourceEntity(
$sources["id_source"],
$sources["title"],
$sources["date"]
$sources["dates"],
TypeSourceEnum::from($sources["type"])
);
}
return $src;
}
public function getSources() : array
public function getAllSources() : array
{
return $this -> gateway -> findAll();
$res = $this -> gateway -> findAll();
$src = [];
foreach ($res as $sources) {
$src[] = new sourceEntity(
$sources["id_source"],
$sources["title"],
$sources["dates"],
TypeSourceEnum::from($sources["type"])
);
}
return $src;
}
public function deleteSource(int $id_source) : bool

@ -1,18 +1,44 @@
<?php
namespace Verification;
class Verification
{
public static function verifChar(string $text) : string{
$charInterdi=['&','|','/','\\','%','$'];
class Verification
{
public static function verifChar(?string $text) : ?string{
if($text==NULL){
return NULL;
}
$charInterdi=['|','/','\\','%','$','=','<','>','(',')'];
$chaineInterdi=["AND","OR","WHERE","FROM","SELECT"];
$textVerif="";
foreach( $text as $char){
foreach( str_split($text,1) as $char){
if( !in_array($char,$charInterdi) ){
$textVerif=$textVerif+$char;
$textVerif=$textVerif.$char;
}
}
$text=$textVerif;
$textVerif="";
$tabText=explode(" ",$text);
for( $i=0 ; $i<count($tabText) ; $i++){
if( !in_array( strtoupper($tabText[$i]) , $chaineInterdi )){
$textVerif=$textVerif.$tabText[$i];
if($i != count($tabText)-1){
$textVerif=$textVerif." ";
}
}
}
return $textVerif;
}
}
public static function verifArrayChar(?array $tabText) : ?array{
for( $i=0 ; $i<count($tabText) ; $i++){
$tabText[$i]=$this->verifChar($tabText[$i]);
}
return $tabText;
}
}
?>

@ -6,12 +6,14 @@ $vendorDir = dirname(__DIR__);
$baseDir = dirname($vendorDir);
return array(
'Verification\\' => array($baseDir . '/src/Verification'),
'Twig\\' => array($vendorDir . '/twig/twig/src'),
'Symfony\\Polyfill\\Php81\\' => array($vendorDir . '/symfony/polyfill-php81'),
'Symfony\\Polyfill\\Mbstring\\' => array($vendorDir . '/symfony/polyfill-mbstring'),
'Symfony\\Polyfill\\Ctype\\' => array($vendorDir . '/symfony/polyfill-ctype'),
'Model\\' => array($baseDir . '/src/Model'),
'Gateway\\' => array($baseDir . '/src/Gateway'),
'Enum\\' => array($baseDir . '/src/Enum'),
'Entity\\' => array($baseDir . '/src/Entity'),
'Controleur\\' => array($baseDir . '/src/Controleur'),
);

@ -18,6 +18,10 @@ class ComposerStaticInit68804b2111cb6b8bf6edf66cb2b4669c
);
public static $prefixLengthsPsr4 = array (
'V' =>
array (
'Verification\\' => 13,
),
'T' =>
array (
'Twig\\' => 5,
@ -38,6 +42,7 @@ class ComposerStaticInit68804b2111cb6b8bf6edf66cb2b4669c
),
'E' =>
array (
'Enum\\' => 5,
'Entity\\' => 7,
),
'C' =>
@ -47,6 +52,10 @@ class ComposerStaticInit68804b2111cb6b8bf6edf66cb2b4669c
);
public static $prefixDirsPsr4 = array (
'Verification\\' =>
array (
0 => __DIR__ . '/../..' . '/src/Verification',
),
'Twig\\' =>
array (
0 => __DIR__ . '/..' . '/twig/twig/src',
@ -71,6 +80,10 @@ class ComposerStaticInit68804b2111cb6b8bf6edf66cb2b4669c
array (
0 => __DIR__ . '/../..' . '/src/Gateway',
),
'Enum\\' =>
array (
0 => __DIR__ . '/../..' . '/src/Enum',
),
'Entity\\' =>
array (
0 => __DIR__ . '/../..' . '/src/Entity',

@ -0,0 +1,18 @@
<?php
global $twig;
echo $twig->render('head.html.twig', [
'title' => "Submit Quote",
'style' => "public/styles/styleSubmitQuote.css",
'scripts' => array("public/script/theme-toggle.js")
]);
// Rendu du bandeau
echo $twig->render('bandeau.html.twig');
echo $twig -> render("submitQuote.html.twig");
?>

@ -2,14 +2,16 @@
<div class="login">
<h1>▶ Profil ◀</h1>
<form method="post" action="{{ racine }}/changedata">
<img src="{{ srcImg }}" class="imageProfil" onmousedown="return false"/>
<p class="infoProfil" id="username"> <strong>{{ srcUsername }}</strong><img class='imgModify' src='{{ racine }}/images/modify.svg' onclick="editFieldUsername('username')"/></p>
<button name="image" class="saveButtonPasswd" value="1" type="Submit">Changer l'image de profil</button>
<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" 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" 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>
@ -18,8 +20,10 @@
</div>
<img class="languageImage" src="{{ racine }}/images/drapeauFrance.png" onmousedown="return false"/>
</form>
<div class="createQuote">
<a href="" class="createQuote">Ajouter une citation</a>
<a href="{{racine}}/submit" class="createQuote">Ajouter une citation</a>
</div>

@ -0,0 +1,51 @@
<!DOCTYPE html>
<html lang="fr">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Wiki Fantasy : Submit Quote</title>
<link id="favicon" rel="icon" href="../../images/iconeSombre.ico"> <!-- Par défaut sombre -->
<link rel="stylesheet" href="../../public/styles/styleSubmitQuote.css">
<script defer src="../../public/script/theme-toggle.js"></script>
</head>
<body>
{% include "bandeau.html.twig" %}
<h1>▶ Your quote has been submitted successfully ◀</h1>
<div>
<div id="box">
<div id="contentField">
<p>Contenu *</p>
<h2>{{ content }}</h2>
</div>
<div id="characterField">
<p>Personnage *</p>
<h2>{{ character }}</h2>
</div>
<div id="sourceField">
<p>Source *</p>
<h2>{{ source }}</h2>
</div>
<div>
<button onclick="window.location.href='/';"> Revenir à l'acceuil</button>
</div>
</div>
</div>
</body>
</html>

@ -0,0 +1,48 @@
<h1>▶ Submit a Quote ◀</h1>
<form id="form" method="post" action="/validsubmit">
<div id="box">
<div id="contentField">
<p>Contenu *</p>
<input type="text" id="content" name="content" placeholder="Entrez le contenu de la citation" required/>
</div>
<div id="characterField">
<p>Personnage *</p>
<input type="text" id="character" name="character" placeholder="Entrez le/la personnage de la citation" required/>
{% if errors[0] is defined and errors[0] is not empty %}
<p style="color: red">{{ errors[0] }}</p>
{% endif %}
</div>
<div id="sourceField">
<p>Source *</p>
<input type="text" id="source" name="source" placeholder="Entrez la source de la citation" required/>
{% if errors[1] is defined and errors[1] is not empty %}
<p style="color: red">{{ errors[1] }}</p>
{% endif %}
</div>
<div id="imageField">
<p>Image *</p>
</div>
<div id="confirm">
<input type="submit" class="btn" name="action" value="Soumettre"/>
</div>
</div>
</form>
</body>
</html>
Loading…
Cancel
Save