pull/20/head
tomivt 5 months ago
parent ba32f10976
commit 8eb7e76e9d

@ -3,7 +3,9 @@
<component name="MaterialThemeProjectNewConfig">
<option name="metadata">
<MTProjectMetadataState>
<option name="userId" value="5c5a39c9:192fb929d1e:-7ffa" />
<option name="migrated" value="true" />
<option name="pristineConfig" value="false" />
<option name="userId" value="-1562669c:19061473cbf:-7ffe" />
</MTProjectMetadataState>
</option>
</component>

@ -5,19 +5,21 @@
</component>
<component name="ChangeListManager">
<list default="true" id="afa12d51-331f-4dbc-a297-7289ad4e396d" name="Changes" comment="">
<change beforePath="$PROJECT_DIR$/composer.json" beforeDir="false" afterPath="$PROJECT_DIR$/composer.json" afterDir="false" />
<change beforePath="$PROJECT_DIR$/index.php" beforeDir="false" afterPath="$PROJECT_DIR$/index.php" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/material_theme_project_new.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/material_theme_project_new.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/config/config.php" beforeDir="false" afterPath="$PROJECT_DIR$/config/config.php" afterDir="false" />
<change beforePath="$PROJECT_DIR$/public/styles/styleLogin.css" beforeDir="false" afterPath="$PROJECT_DIR$/public/styles/styleLogin.css" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/Controleur/FrontControler.php" beforeDir="false" afterPath="$PROJECT_DIR$/src/Controleur/FrontControler.php" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/Controleur/QuizController.php" beforeDir="false" afterPath="$PROJECT_DIR$/src/Controleur/QuizController.php" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/Gateway/Connection.php" beforeDir="false" afterPath="$PROJECT_DIR$/src/Gateway/Connection.php" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/Gateway/QuestionGateway.php" beforeDir="false" afterPath="$PROJECT_DIR$/src/Gateway/QuestionGateway.php" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/Gateway/QuizGateway.php" beforeDir="false" afterPath="$PROJECT_DIR$/src/Gateway/QuizGateway.php" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/Model/QuestionModel.php" beforeDir="false" afterPath="$PROJECT_DIR$/src/Model/QuestionModel.php" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/Model/QuizQuestionModel.php" beforeDir="false" afterPath="$PROJECT_DIR$/src/Model/QuizQuestionModel.php" afterDir="false" />
<change beforePath="$PROJECT_DIR$/vendor/composer/autoload_psr4.php" beforeDir="false" afterPath="$PROJECT_DIR$/vendor/composer/autoload_psr4.php" afterDir="false" />
<change beforePath="$PROJECT_DIR$/vendor/composer/autoload_static.php" beforeDir="false" afterPath="$PROJECT_DIR$/vendor/composer/autoload_static.php" afterDir="false" />
<change beforePath="$PROJECT_DIR$/vue/accueil.php" beforeDir="false" afterPath="$PROJECT_DIR$/vue/accueil.php" afterDir="false" />
<change beforePath="$PROJECT_DIR$/vue/quiz.php" beforeDir="false" afterPath="$PROJECT_DIR$/vue/templates/quiz.html.twig" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/Controleur/VisitorControler.php" beforeDir="false" afterPath="$PROJECT_DIR$/src/Controleur/VisitorControler.php" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/Entity/userEntity.php" beforeDir="false" afterPath="$PROJECT_DIR$/src/Entity/userEntity.php" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/Gateway/userGateway.php" beforeDir="false" afterPath="$PROJECT_DIR$/src/Gateway/userGateway.php" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/Model/userModel.php" beforeDir="false" afterPath="$PROJECT_DIR$/src/Model/userModel.php" afterDir="false" />
<change beforePath="$PROJECT_DIR$/vue/login.html" beforeDir="false" afterPath="$PROJECT_DIR$/vue/templates/login.html.twig" afterDir="false" />
<change beforePath="$PROJECT_DIR$/vue/signin.html" beforeDir="false" afterPath="$PROJECT_DIR$/vue/templates/signin.html.twig" afterDir="false" />
<change beforePath="$PROJECT_DIR$/vue/templates/bandeau.html.twig" beforeDir="false" afterPath="$PROJECT_DIR$/vue/templates/bandeau.html.twig" afterDir="false" />
<change beforePath="$PROJECT_DIR$/vue/templates/profil.html" beforeDir="false" afterPath="$PROJECT_DIR$/vue/templates/profil.html.twig" afterDir="false" />
<change beforePath="$PROJECT_DIR$/vue/templates/quote.html" beforeDir="false" afterPath="$PROJECT_DIR$/vue/templates/quote.html.twig" afterDir="false" />
</list>
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
@ -78,27 +80,30 @@
&quot;associatedIndex&quot;: 4
}</component>
<component name="ProjectId" id="2oQGGlghI0ydDNgxjOeok3kwC7m" />
<component name="ProjectLevelVcsManager">
<ConfirmationsSetting value="1" id="Add" />
</component>
<component name="ProjectViewState">
<option name="hideEmptyMiddlePackages" value="true" />
<option name="showLibraryContents" value="true" />
</component>
<component name="PropertiesComponent"><![CDATA[{
"keyToString": {
"RunOnceActivity.ShowReadmeOnStart": "true",
"git-widget-placeholder": "master",
"node.js.detected.package.eslint": "true",
"node.js.detected.package.tslint": "true",
"node.js.selected.package.eslint": "(autodetect)",
"node.js.selected.package.tslint": "(autodetect)",
"nodejs_package_manager_path": "npm",
"vue.rearranger.settings.migration": "true"
<component name="PropertiesComponent">{
&quot;keyToString&quot;: {
&quot;RunOnceActivity.ShowReadmeOnStart&quot;: &quot;true&quot;,
&quot;git-widget-placeholder&quot;: &quot;loginPart&quot;,
&quot;node.js.detected.package.eslint&quot;: &quot;true&quot;,
&quot;node.js.detected.package.tslint&quot;: &quot;true&quot;,
&quot;node.js.selected.package.eslint&quot;: &quot;(autodetect)&quot;,
&quot;node.js.selected.package.tslint&quot;: &quot;(autodetect)&quot;,
&quot;nodejs_package_manager_path&quot;: &quot;npm&quot;,
&quot;vue.rearranger.settings.migration&quot;: &quot;true&quot;
},
"keyToStringList": {
"DatabaseDriversLRU": [
"postgresql"
&quot;keyToStringList&quot;: {
&quot;DatabaseDriversLRU&quot;: [
&quot;postgresql&quot;
]
}
}]]></component>
}</component>
<component name="RecentsManager">
<key name="MoveFile.RECENT_KEYS">
<recent name="$PROJECT_DIR$/vue/templates" />
@ -122,6 +127,7 @@
<updated>1730794293135</updated>
<workItem from="1730794294713" duration="2741000" />
<workItem from="1730797544484" duration="27887000" />
<workItem from="1731254310060" duration="6803000" />
</task>
<servers />
</component>

@ -0,0 +1,114 @@
<?php
use Twig\Environment;
use Twig\Error\LoaderError;
use Twig\Error\RuntimeError;
use Twig\Extension\CoreExtension;
use Twig\Extension\SandboxExtension;
use Twig\Markup;
use Twig\Sandbox\SecurityError;
use Twig\Sandbox\SecurityNotAllowedTagError;
use Twig\Sandbox\SecurityNotAllowedFilterError;
use Twig\Sandbox\SecurityNotAllowedFunctionError;
use Twig\Source;
use Twig\Template;
use Twig\TemplateWrapper;
/* login.html.twig */
class __TwigTemplate_07a755596da3dba7ab89ea161b697e55 extends Template
{
private Source $source;
/**
* @var array<string, Template>
*/
private array $macros = [];
public function __construct(Environment $env)
{
parent::__construct($env);
$this->source = $this->getSourceContext();
$this->parent = false;
$this->blocks = [
];
}
protected function doDisplay(array $context, array $blocks = []): iterable
{
$macros = $this->macros;
// line 1
yield "<!DOCTYPE html>
<html lang=\"fr\">
<head>
<meta charset=\"UTF-8\">
<meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">
<link rel=\"stylesheet\" type=\"text/css\" href=\"../public/styles/styleLogin.css\" media=\"screen\">
<title>Wiki Fantasy : Connexion</title>
<link id=\"favicon\" rel=\"icon\" href=\"../../images/iconeSombre.ico\"> <!-- Par défaut sombre -->
<link href=\"https://fonts.googleapis.com/css2?family=Lemon&display=swap\" rel=\"stylesheet\">
<script defer src=\"../public/script/theme-toggle.js\"></script>
</head>
<body>
<div class=\"container\">
<div class=\"header\">
<div class=\"nav\">
<img src=\"../images/coeur.svg\" alt=\"coeur\" width=\"67px\" height=\"67px\" onmousedown=\"return false\">
<img id=\"theme-icon\" src=\"../images/light.svg\" alt=\"toggle theme\" width=\"72px\" height=\"37px\" onmousedown=\"return false\" onclick=\"toggleTheme()\">
<img src=\"../images/quizz.svg\" alt=\"quizz\" width=\"51px\" height=\"82px\" onmousedown=\"return false\">
</div>
<div class=\"logo\">
<a href=\"accueil.html\"><img src=\"../images/WIKIFANTASY.png\" alt=\"Logo\" width=\"227px\" height=\"106px\" onmousedown=\"return false\"></a>
</div>
<div class=\"user\">
<img src=\"../images/user_dark.png\" alt=\"user\" width=\"70px\" height=\"70px\" onmousedown=\"return false\">
</div>
</div>
</div>
<h1>▶ Connexion ◀</h1>
<form class=\"login\" method=\"post\">
<p> <strong>Identifiant *</strong></p>
<input type=\"text\" class=\"connexion\" name=\"pseudo\" id=\"pseudo\" placeholder=\"Entrez votre pseudo ...\" required />
<p> <strong> Mot de passe *</strong></p>
<input type=\"password\" class=\"connexion\" name=\"mdp\" id=\"mdp\" placeholder=\"Entrez votre mdp ...\" required />
<div class=\"createAccount\">
<p class=\"createAccount\">Vous n'avez pas de compte?</p>
<a href=\"signin.html.twig\" class=\"createAccount\">S'incrire</a>
</div>
<div class=\"buttonSubmitDiv\">
<button class=\"buttonSudmite\">Connexion</button>
</div>
</form>
</body>
</html>";
yield from [];
}
/**
* @codeCoverageIgnore
*/
public function getTemplateName(): string
{
return "login.html.twig";
}
/**
* @codeCoverageIgnore
*/
public function getDebugInfo(): array
{
return array ( 42 => 1,);
}
public function getSourceContext(): Source
{
return new Source("", "login.html.twig", "/Users/kiem/Documents/WikiFantasy/WF-Website/vue/templates/login.html.twig");
}
}

@ -0,0 +1,127 @@
<?php
use Twig\Environment;
use Twig\Error\LoaderError;
use Twig\Error\RuntimeError;
use Twig\Extension\CoreExtension;
use Twig\Extension\SandboxExtension;
use Twig\Markup;
use Twig\Sandbox\SecurityError;
use Twig\Sandbox\SecurityNotAllowedTagError;
use Twig\Sandbox\SecurityNotAllowedFilterError;
use Twig\Sandbox\SecurityNotAllowedFunctionError;
use Twig\Source;
use Twig\Template;
use Twig\TemplateWrapper;
/* signin.html.twig */
class __TwigTemplate_f3fb3bd89b84ec5439a034a1b7acb44e extends Template
{
private Source $source;
/**
* @var array<string, Template>
*/
private array $macros = [];
public function __construct(Environment $env)
{
parent::__construct($env);
$this->source = $this->getSourceContext();
$this->parent = false;
$this->blocks = [
];
}
protected function doDisplay(array $context, array $blocks = []): iterable
{
$macros = $this->macros;
// line 1
yield "<!DOCTYPE html>
<html lang=\"fr\">
<head>
<meta charset=\"UTF-8\">
<meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">
<link rel=\"stylesheet\" type=\"text/css\" href=\"../public/styles/styleSignin.css\" media=\"screen\">
<title>Wiki Fantasy : Inscription</title>
<link id=\"favicon\" rel=\"icon\" href=\"../images/iconeSombre.ico\"> <!-- Par défaut sombre -->
<link href=\"https://fonts.googleapis.com/css2?family=Lemon&display=swap\" rel=\"stylesheet\">
<script defer src=\"../public/script/theme-toggle.js\"></script>
</head>
<body>
<div class=\"container\">
<div class=\"header\">
<div class=\"nav\">
<a href=\"favorite.html\"><img src=\"../images/coeur.svg\" alt=\"coeur\" width=\"67px\" height=\"67px\" onmousedown=\"return false\"></a>
<img id=\"theme-icon\" src=\"../images/light.svg\" alt=\"toggle theme\" width=\"72px\" height=\"37px\" onmousedown=\"return false\" onclick=\"toggleTheme()\">
<a href=\"quiz.html\"><img src=\"../images/quizz.svg\" alt=\"quizz\" width=\"51px\" height=\"82px\" onmousedown=\"return false\"></a>
</div>
<div class=\"logo\">
<a href=\"accueil.html\"><img src=\"../images/WIKIFANTASY.png\" alt=\"Logo\" width=\"227px\" height=\"106px\" onmousedown=\"return false\"></a>
</div>
<div class=\"user\">
<img src=\"../images/user_dark.png\" alt=\"user\" width=\"70px\" height=\"70px\" onmousedown=\"return false\">
</div>
</div>
</div>
<h1>▶ S'inscrire ◀</h1>
<form method=\"post\">
<div class=\"signin\">
<div class=\"DivId\">
<p>Identifiant *</p>
<input type=\"text\" class=\"champ\" id=\"pseudo\" name=\"pseudo\" required/>
</div>
<div class=\"DivEmail\">
<p>Email *</p>
<input type=\"email\" class=\"champ\" id=\"email\" name=\"email\" required/>
</div>
<div class=\"mdp\">
<p>Mot de passe *</p>
<input type=\"password\" class=\"champ\" id=\"mdp\" name=\"mdp\" required/>
</div>
<div class=\"confmdp\">
<p>Confirmer mot de passe *</p>
<input type=\"password\" class=\"champ\" id=\"cmdp\" name=\"cmdp\" required/>
</div>
<div class=\"imgprof\">
<p>Image *</p>
</div>
<div class=\"confirmer\">
<input type=\"submit\" class=\"btn\" value=\"Inscription\" />
</div>
</div>
</form>
</body>
</html>";
yield from [];
}
/**
* @codeCoverageIgnore
*/
public function getTemplateName(): string
{
return "signin.html.twig";
}
/**
* @codeCoverageIgnore
*/
public function getDebugInfo(): array
{
return array ( 42 => 1,);
}
public function getSourceContext(): Source
{
return new Source("", "signin.html.twig", "/Users/kiem/Documents/WikiFantasy/WF-Website/vue/templates/signin.html.twig");
}
}

@ -17,7 +17,8 @@ $mdp = '';
$vues['erreur'] = 'vue/erreur.php';
$vues['accueil'] = 'vue/accueil.php';
$vues['quote'] = 'vue/quote.php';
$vues['login'] = 'vue/login.html';
$vues['login'] = 'vue/templates/login.html.twig';
$vues['signin'] = 'vue/templates/signin.html.twig';
//Style css
$style['accueil'] = 'public/styles/styleAccueil.css';

@ -98,7 +98,7 @@ body.light-mode .createAccount{
font-family: "Lemon", serif;
}
body.light-mode .buttonSudmite{
body.light-mode .buttonSubmit{
background: linear-gradient(180deg, rgba(187,211,249,1) 0%, rgba(199,246,196,1) 100%);
font-family: "Lemon", serif;
border: none;
@ -123,7 +123,7 @@ body.light-mode .connexion{
/* ====== DEFAULT ====== */
.buttonSudmiteDiv{
.buttonSubmitDiv{
text-align: center;
}

@ -16,7 +16,7 @@ Class FrontControler{
$this->co=$co;
$this->listAction = ['visitor' => array('accueil','search','quote','login','singin','quiz'),
$this->listAction = ['visitor' => array('accueil','search','quote','login','signin','quiz'),
'user' => array('quiz','commentary','favorite','logout'),
'admin' => array('null')];
@ -37,6 +37,7 @@ Class FrontControler{
$router->map('GET|POST', '/quote/[i:idQuote]?', 'VisitorControler');
$router->map('GET|POST', '/login', 'VisitorControler');
$router->map('GET|POST', '/signin', 'VisitorControler');
$router->map('GET|POST', '/quiz/[i:id]?', 'QuizController');
$match = $router->match();
@ -69,7 +70,7 @@ Class FrontControler{
$controller = '\\Controleur\\' . $controller;
$controller = new $controller($this->co);
$controller = new $controller($this->co, $action);
if (is_callable(array($controller, $action))) {
call_user_func_array(array($controller, $action),
array($match['params']));

@ -32,7 +32,7 @@ class QuizController
* @throws RuntimeError
* @throws LoaderError
*/
public function __construct(Connection $co)
public function __construct(Connection $co, ?string $action = null)
{
$this -> co = $co;
$this -> gw = new QuestionGateway($this->co);

@ -1,8 +1,51 @@
<?php
namespace Controleur;
use Gateway\Connection;
use Gateway\UserGateway;
use Model\UserModel;
use Twig\Error\LoaderError;
use Twig\Error\RuntimeError;
use Twig\Error\SyntaxError;
Class VisitorControler {
private Connection $co;
private UserGateway $gw;
private UserModel $mdl;
/**
* @throws SyntaxError
* @throws RuntimeError
* @throws LoaderError
*/
public function __construct(Connection $co, string $action) {
$this->co = $co;
$this->gw = new UserGateway($this->co);
$this->mdl = new UserModel($this->gw);
$this -> getAction($action);
}
/**
* @throws SyntaxError
* @throws RuntimeError
* @throws LoaderError
*/
public function getAction(string $action): void
{
switch ($action) {
case "login":
$this -> visitorLogIn();
break;
case "signin":
$this -> visitorSignIn();
break;
default:
break;
}
}
public function accueil(){
global $vues;
require_once $vues['accueil'];
@ -13,13 +56,50 @@ Class VisitorControler{
$id=$arg['idQuote'] ?? 1;
//echo "{$id}";
require_once $vues['quote'];
}
public function login(){
/**
* @throws SyntaxError
* @throws RuntimeError
* @throws LoaderError
*/
public function visitorLogIn(): void
{
global $vues;
require_once $vues['login'];
global $twig;
echo $twig->render("login.html.twig");
$pseudo = $_POST['pseudo'] ?? null;
$mdp = $_POST['mdp'] ?? null;
}
/**
* @throws SyntaxError
* @throws RuntimeError
* @throws LoaderError
*/
public function visitorSignIn(): void
{
global $vues;
global $twig;
echo $twig->render("signin.html.twig");
$pseudo = $_POST['pseudo'] ?? null;;
$email = $_POST['email'] ?? null;
$mdp = $_POST['mdp'] ?? null;
$cmdp = $_POST['cmdp'] ?? null;
if ($mdp != $cmdp) {
return;
}
$option = ['cost' => 12];
$hmdp = password_hash($mdp, PASSWORD_BCRYPT, $option);
$user = $this -> mdl -> getUsername($pseudo);
echo $this->mdl->insertUser($pseudo, $email, $hmdp);
}
}

@ -1,124 +1,107 @@
<?php
namespace Entity;
class User{
class UserEntity {
private int $id;
private string $username;
private string $passwd;
private string $hidenPasswd;
private int $img;
private string $pseudo;
private string $password;
private string $email;
private string $date;
private bool $isAdmin;
private int $imgPrfl;
/**
* @param int $id
* @param string $username
* @param string $passwd
* @param string $hidenPasswd
* @param int $img
* @param string $email
*/
public function __construct(int $id, string $username, string $passwd, int $img, string $email)
{
$this->id = $id;
$this->username = $username;
$this->passwd = $passwd;
$this->hidenPasswd = hidenPasswd($passwd);
$this->img = $img;
$this->email = $email;
}
/**
* @return string
*/
public function getId(): int
{
return $this->id;
}
/**
* @param string $id
*/
public function setId(int $id): void
{
$this->id = $id;
}
/**
* @return string
*/
public function getUsername(): string
public function getPseudo(): string
{
return $this->username;
return $this->pseudo;
}
/**
* @param string $username
*/
public function setUsername(string $username): void
public function setPseudo(string $pseudo): void
{
$this->username = $username;
$this->pseudo = $pseudo;
}
/**
* @return string
*/
public function getImg(): int
public function getPassword(): string
{
return $this->img;
return $this->password;
}
/**
* @param string $img
*/
public function setImg(int $img): void
public function setPassword(string $password): void
{
$this->img = $img;
$this->password = $password;
}
/**
* @return string
*/
public function getEmail(): string
{
return $this->email;
}
/**
* @param string $email
*/
public function setEmail(string $email): void
{
$this->email = $email;
}
/**
* @return string
*/
public function getPasswd(): string
public function getDate(): string
{
return $this->passwd;
return $this->date;
}
/**
* @return string
*/
public function getHidenPasswd(): string
public function setDate(string $date): void
{
$this->date = $date;
}
public function isAdmin(): bool
{
return $this->isAdmin;
}
public function setIsAdmin(bool $isAdmin): void
{
return $this->hidenPasswd;
$this->isAdmin = $isAdmin;
}
public function getImgPrfl(): int
{
return $this->imgPrfl;
}
public function setImgPrfl(int $imgPrfl): void
{
$this->imgPrfl = $imgPrfl;
}
/**
* @param string $passwd
* @param int $id
* @param string $pseudo
* @param string $password
* @param string $email
* @param int $imgPrfl
* @param bool $isAdmin
* @param string $date
*/
public function setPasswd(string $passwd): void
public function __construct(int $id, string $pseudo, string $password, string $email, int $imgPrfl, bool $isAdmin, string $date)
{
$this->passwd = $passwd;
$this->hidenPassWd = hidenPassWd($passwd);
$this->id = $id;
$this->pseudo = $pseudo;
$this->password = $password;
$this->email = $email;
$this->imgPrfl = $imgPrfl;
$this->isAdmin = $isAdmin;
$this->date = $date;
}
}
// ============================================ En attente du Model ============================================
/*$dsn = "pgsql:host=londres;dbname=dblebeaulato";

@ -1,27 +1,37 @@
<?php
namespace Gateway;
use Connection;
use PDO;
Class UserGateway{
private Connection $con;
private \Gateway\Connection $con;
public function __construct(Connection $con){
$this->con=$con;
}
public function insert(string $username,string $email,string $passwd):string{
public function getNumberOfUsers() : array
{
$query = "SELECT Count(*) FROM Users";
// récupération id
$query='SELECT id_user FROM Users WHERE id_user >= ALL (SELECT id_user FROM Users);';
$this -> con -> executeQuery($query);
$result=$this->con->getResults();
foreach($result as $row){
$id=$row['id_user'] + 1;
return $this -> con -> getResults();
}
// insertion user
$query='INSERT INTO Users VALUES (:id,:username,:email,:passwd,CURRENT_DATE,false);';
$this->con->executeQuery($query,array(':id' => array($id,PDO::PARAM_STR),':username' => array($u->username,PDO::PARAM_STR),':email' => array($u->email,PDO::PARAM_STR),':passwd' => array($u->passwd,PDO::PARAM_STR)));
return $id;
public function insertUser(int $id, string $pseudo, string $email, string $password, bool $isAdmin, int $imgPrfl) : bool {
$query = "
INSERT INTO Users
VALUES (:id, :pseudo, :email, :password, CURRENT_DATE, :isAdmin, :imgPrfl)
";
return $this -> con -> executeQuery($query, [
":id" => [$id, PDO::PARAM_INT],
":pseudo" => [$pseudo, PDO::PARAM_STR],
":email" => [$email, PDO::PARAM_STR],
":password" => [$password, PDO::PARAM_STR],
":isAdmin" => [$isAdmin, PDO::PARAM_INT],
":imgPrfl" => [$imgPrfl, PDO::PARAM_STR]
]);
}
public function delete(string $id) : bool{
@ -34,7 +44,7 @@ Class UserGateway{
public function getFavorite(string $id):array{
//obtention favoris d'un user
$query='SELECT * FROM Quote WHERE id_quote IN (SELECT id_quote IN Favorite f JOIN User u ON u.id_user = f.user WHERE id_user = :id);';
$query='SELECT * FROM Quote WHERE id_quote IN (SELECT id_quote FROM Favorite f JOIN users u ON u.id_user = f.user_f WHERE u.id_user = :id);';
$this->con->executeQuery($query,array(':id' => array($id,PDO::PARAM_STR)));
$result=$this->con->getResults();
return $result;
@ -44,62 +54,64 @@ Class UserGateway{
//obtenir les information d'un user
public function findDataUser(int $id):array{
$query = 'SELECT * FROM Users WHERE id_user=:idUser';
$con->executeQuery($query, array(':idUser'=>array($id, PDO::PARAM_STR)));
$result = $con->getResults();
$this->con->executeQuery($query, array(':idUser'=>array($id, PDO::PARAM_STR)));
$result = $this->con->getResults();
return $result;
}
// obtenir les informations d'un user selon son pseudo
public function findUsername(string $username):array{
$query = 'SELECT * FROM Users WHERE username= :username';
$this->con->executeQuery($query, array(':username'=>array($username, PDO::PARAM_STR)));
return $this->con->getResults();
}
// ===================== UPDATE FUNCTION =====================
public function updateUsername(int $id, string $newUsername):array{
public function updateUsername(int $id, string $newUsername):bool{
//Update le nom du user passé en paramètre
$queryUpdate = 'UPDATE Users SET username=:newUsername WHERE id_user=:idUser';
$con->executeQuery($queryUpdate, array(':idUser'=>array($id, PDO::PARAM_STR), ':newUsername'=> array($newUsername, PDO::PARAM_STR)));
$this->con->executeQuery($queryUpdate, array(':idUser'=>array($id, PDO::PARAM_STR), ':newUsername'=> array($newUsername, PDO::PARAM_STR)));
//Renvoie le nouveau nom du user
$queryReponse = 'SELECT username FROM Users WHERE id_user=:idUser';
$con->executeQuery($queryReponse, array($id=>array($newUsername, PDO::PARAM_STR)));
return $result;
return $this->con->executeQuery($queryReponse, array($id=>array($newUsername, PDO::PARAM_STR)));
}
public function updateEmail(int $id, string $newEmail):array{
public function updateEmail(int $id, string $newEmail):bool{
//Update le email du user passé en paramètre
$queryUpdate = 'UPDATE Users SET email=:newEmail WHERE id_user=:idUser';
$con->executeQuery($queryUpdate, array(':idUser'=>array($id, PDO::PARAM_STR), ':newEmail'=> array($newEmail, PDO::PARAM_STR)));
$this->con->executeQuery($queryUpdate, array(':idUser'=>array($id, PDO::PARAM_STR), ':newEmail'=> array($newEmail, PDO::PARAM_STR)));
//Renvoie le nouveau email du user
$queryReponse = 'SELECT email FROM Users WHERE id_user=:idUser';
$con->executeQuery($queryReponse, array(':idUser'=>array($id, PDO::PARAM_STR)));
$result = $con->getResults();
return $result;
return $this->con->executeQuery($queryReponse, array(':idUser'=>array($id, PDO::PARAM_STR)));
}
public function updateImg(int $id, int $newImg):array{
//Update l'image du user passé en paramètre
$query = 'UPDATE Users SET img=:newImg WHERE id_user=:idUser';
$con->executeQuery($query, array(':idUser'=>array($id, PDO::PARAM_STR), ':newImg'=> array($newImg, PDO::PARAM_STR)));
$query = 'UPDATE Users SET img_prfl=:newImg WHERE id_user=:idUser';
$this->con->executeQuery($query, array(':idUser'=>array($id, PDO::PARAM_STR), ':newImg'=> array($newImg, PDO::PARAM_STR)));
//Renvoie la nouvelle image du user
$queryReponse = 'SELECT img FROM Users WHERE id_user=:idUser';
$con->executeQuery($queryReponse, array(':idUser'=>array($id, PDO::PARAM_STR)));
$result = $con->getResults();
$queryReponse = 'SELECT img_prfl FROM Users WHERE id_user=:idUser';
$this->con->executeQuery($queryReponse, array(':idUser'=>array($id, PDO::PARAM_STR)));
$result = $this->con->getResults();
return $result;
}
public function updatePasswd(int $id, string $newPassWd):array{
//Update le passwd du user passé en paramètre
$query = 'UPDATE Users SET pssword=:newPassWd WHERE id_user=:idUser';
$con->executeQuery($query, array(':idUser'=>array($id, PDO::PARAM_STR), ':newPassWd'=> array($newPassWd, PDO::PARAM_STR)));
$this->con->executeQuery($query, array(':idUser'=>array($id, PDO::PARAM_STR), ':newPassWd'=> array($newPassWd, PDO::PARAM_STR)));
//Renvoie le nouveau passwd du user
$queryReponse = 'SELECT pssword FROM Users WHERE id_user=:idUser';
$con->executeQuery($queryReponse, array(':idUser'=>array($id, PDO::PARAM_STR)));
$result = $con->getResults();
$this->con->executeQuery($queryReponse, array(':idUser'=>array($id, PDO::PARAM_STR)));
$result = $this->con->getResults();
return $result;
}
}
$uG = new UserGateway(new Connection("pgsql:host=londres;dbname=dblebeaulato","lebeaulato",""));
?>

@ -11,13 +11,18 @@
$this->gateway = $gate;
}
public function insertUser(string $username,string $email,string $passwd) : User{
global $rep,$image;
$id = $this->gateway->insert($username,$email,$passwd);
$u = new User($id,$usename,$passwd,$rep.$image['default'],$email);
public function insertUser(string $username,string $email,string $passwd) : bool{
/*global $rep,$image;*/
return $this->gateway->insertUser($this->getNumberOfUsers() + 1, $username, $email, $passwd, false, 0);
}
public function deletUser(string $id) : bool{
public function getNumberOfUsers() : int
{
return $this->gateway->getNumberOfUsers()[0]['count'] ?? 0;
}
public function deleteUser(string $id) : bool{
return $this->gateway->delete($id);
}
@ -30,20 +35,32 @@
// }
// }
public function getDataUser(int $id){
public function getDataUser(int $id) : ?User {
$res = $this->gateway->findDataUser($id);
foreach($res as $sources){
$src[] = new User(
$sources['id_user'],
$sources['username'],
$sources['pssword'],
$sources['img'],
$sources['email']
if ($res)
return new User(
$res['id_user'],
$res['username'],
$res['pssword'],
$res['img'],
$res['email']
);
}
return $src;
return null;
}
public function getUsername(string $username) : ?User
{
$res = $this->gateway->findUsername($username);
if ($res)
return new User(
$res['id_user'],
$res['username'],
$res['pssword'],
$res['img'],
$res['email']
);
return null;
}
public function setUsername(int $id, string $newUsername){
$res = $this->gateway->updateUsername($id,$newUsername);

@ -8,6 +8,6 @@
<a href="accueil.html"><img src="../images/WIKIFANTASY.png" alt="Logo" width="227px" height="106px" onmousedown="return false"></a>
</div>
<div class="user">
<a href="profil.html"><img src="../images/user_dark.png" alt="user" width="70px" height="70px" onmousedown="return false"></a>
<a href="profil.html.twig"><img src="../images/user_dark.png" alt="user" width="70px" height="70px" onmousedown="return false"></a>
</div>
</div>

@ -27,23 +27,23 @@
</div>
<h1>▶ Connexion ◀</h1>
<div class="login">
<form class="login" method="post">
<p> <strong>Identifiant *</strong></p>
<input type="text" class="connexion" name="name" required />
<input type="text" class="connexion" name="pseudo" id="pseudo" placeholder="Entrez votre pseudo ..." required />
<p> <strong> Mot de passe *</strong></p>
<input type="password" class="connexion" name="passwd" required />
<input type="password" class="connexion" name="mdp" id="mdp" placeholder="Entrez votre mdp ..." required />
<div class="createAccount">
<p class="createAccount">Vous n'avez pas de compte?</p>
<a href="signin.html" class="createAccount">S'incrire</a>
<a href="signin.html.twig" class="createAccount">S'incrire</a>
</div>
<div class="buttonSudmiteDiv">
<div class="buttonSubmitDiv">
<button class="buttonSudmite">Connexion</button>
</div>
</div>
</form>
</body>
</html>

@ -26,11 +26,11 @@
</div>
</div>
<h1>▶ S'inscrire ◀</h1>
<form action="../script/signin.php" method="post">
<form method="post">
<div class="signin">
<div class="DivId">
<p>Identifiant *</p>
<input type="text" class="champ" id="name" name="name" required/>
<input type="text" class="champ" id="pseudo" name="pseudo" required/>
</div>
<div class="DivEmail">
@ -40,12 +40,18 @@
<div class="mdp">
<p>Mot de passe *</p>
<input type="password" class="champ" id="pswd" name="pswd" required/>
<input type="password" class="champ" id="mdp" name="mdp" required placeholder="{{ errors }}"/>
{% if errors %}
<div>{{ errors }}</div>
{% endif %}
</div>
<div class="confmdp">
<p>Confirmer mot de passe *</p>
<input type="password" class="champ" id="confpswd" name="confpswd" required/>
<input type="password" class="champ" id="cmdp" name="cmdp" required/>
{% if errors %}
<div>{{ errors }}</div>
{% endif %}
</div>
<div class="imgprof">
Loading…
Cancel
Save