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.
56 lines
1.4 KiB
56 lines
1.4 KiB
<?php
|
|
class User{
|
|
public int $id;
|
|
public string $username;
|
|
public string $passwd;
|
|
public string $hidenPasswd;
|
|
public string $img;
|
|
public string $email;
|
|
public bool $admin = false;
|
|
|
|
function __construct(string $pseudo, string $password, string $image, string $mail) {
|
|
$this->username = $pseudo;
|
|
$this->passwd = $password;
|
|
$this->hidenPasswd = hidenPassWd($password);
|
|
$this->img = $image;
|
|
$this->email = $mail;
|
|
}
|
|
|
|
public function updateUsername(string $newUsername){
|
|
if(!empty($newUsername)){
|
|
$this->username = $newUsername;
|
|
}
|
|
}
|
|
|
|
public function updateEmail(string $newEmail) {
|
|
if(!empty($newEmail)){
|
|
$this->email = $newEmail;
|
|
}
|
|
}
|
|
|
|
public function updatePassWd(string $newPassword1, string $newPassword2){
|
|
if(!empty($newPassword2) && !empty($newPassword1)){
|
|
if($newPassword1 == $newPassword2){
|
|
$u->passwd = $newPassword1;
|
|
}
|
|
}
|
|
}
|
|
|
|
public function modifyImage(string $image){
|
|
if(!empty($image)){
|
|
$u->img = $image;
|
|
}
|
|
}
|
|
}
|
|
|
|
$u = new User('Testeur', 'motDepasse', '../images/imageProfil.png', 'testeur.compte@wikifantasy.com'); /*Test*/
|
|
|
|
function hidenPassWd(string $passwd){
|
|
if(strlen($passwd) >= 16) return str_repeat('*', 16);
|
|
return str_repeat('*', strlen($passwd));
|
|
}
|
|
|
|
|
|
|
|
|
|
?>
|