You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
96 lines
3.1 KiB
96 lines
3.1 KiB
<?php
|
|
class User{
|
|
public string $id;
|
|
public string $username;
|
|
public string $passwd;
|
|
public string $hidenPasswd;
|
|
public string $img;
|
|
public string $email;
|
|
|
|
function __construct(string $id, string $pseudo, string $password, string $image, string $mail) {
|
|
$this->id = $id;
|
|
$this->username = $pseudo;
|
|
$this->passwd = $password;
|
|
$this->hidenPasswd = hidenPassWd($password);
|
|
$this->img = $image;
|
|
$this->email = $mail;
|
|
}
|
|
|
|
public function updateUsername(string $newUsername){
|
|
if(isset($newUsername)){
|
|
$this->username = $newUsername;
|
|
}
|
|
}
|
|
|
|
public function updateEmail(string $newEmail) {
|
|
if(isset($newEmail)){
|
|
$this->email = $newEmail;
|
|
}
|
|
}
|
|
|
|
|
|
public function modifyImage(string $image){
|
|
if(isset($image)){
|
|
$u->img = $image;
|
|
}
|
|
}
|
|
}
|
|
|
|
//include("userGateway.php");
|
|
//$result = donneeUser('U003');
|
|
|
|
|
|
// ============================================ En attente du Model ============================================
|
|
include("Connection.php");
|
|
$dsn = "pgsql:host=londres;dbname=dblebeaulato";
|
|
$username = "lebeaulato";
|
|
$password = "MaSQL:2004!";
|
|
|
|
$con = new Connection($dsn,$username,$password);
|
|
|
|
$query = 'SELECT * FROM Users WHERE id_user=:idUser';
|
|
$con->executeQuery($query, array(':idUser'=>array('U003', PDO::PARAM_STR)));
|
|
$result = $con->getResults();
|
|
|
|
$u = new User($result[0]['id_user'],$result[0]['username'], $result[0]['pssword'], '../../images/imageProfil.png', $result[0]['email']); /*Test*/
|
|
|
|
|
|
//UPDATE username User
|
|
$query = 'UPDATE Users SET username=:newUsername WHERE id_user=:idUser';
|
|
$con->executeQuery($query, array(':idUser'=>array('U003', PDO::PARAM_STR), ':newUsername'=> array('Hello', PDO::PARAM_STR)));
|
|
$queryReponse = 'SELECT username FROM Users WHERE id_user=:idUser';
|
|
|
|
$con->executeQuery($queryReponse, array(':idUser'=>array('U003', PDO::PARAM_STR)));
|
|
$result = $con->getResults();
|
|
$u->username = $result[0]['username']; /*Test*/
|
|
|
|
|
|
//UPDATE email User
|
|
$query = 'UPDATE Users SET email=:newEmail WHERE id_user=:idUser';
|
|
$con->executeQuery($query, array(':idUser'=>array('U003', PDO::PARAM_STR), ':newEmail'=> array('Sinper42Gamer@gmail.com', PDO::PARAM_STR)));
|
|
$queryReponse = 'SELECT email FROM Users WHERE id_user=:idUser';
|
|
|
|
$con->executeQuery($queryReponse, array(':idUser'=>array('U003', PDO::PARAM_STR)));
|
|
$result = $con->getResults();
|
|
$u->email = $result[0]['email']; /*Test*/
|
|
|
|
//UPDATE passwd User
|
|
$query = 'UPDATE Users SET pssword=:newPassWd WHERE id_user=:idUser';
|
|
$con->executeQuery($query, array(':idUser'=>array('U003', PDO::PARAM_STR), ':newPassWd'=> array('TestMotDePasssse', PDO::PARAM_STR)));
|
|
|
|
$queryReponse = 'SELECT pssword FROM Users WHERE id_user=:idUser';
|
|
$con->executeQuery($queryReponse, array(':idUser'=>array('U003', PDO::PARAM_STR)));
|
|
$result = $con->getResults();
|
|
$u->passwd = $result[0]['pssword']; /*Test*/
|
|
|
|
// ================================================================================================================
|
|
|
|
function hidenPassWd(string $passwd){
|
|
if(strlen($passwd) >= 16) return str_repeat('*', 16);
|
|
return str_repeat('*', strlen($passwd));
|
|
}
|
|
|
|
|
|
|
|
|
|
?>
|