blob: ea144b73ef7614eb6eeaf110dcd386472d1366c7 [file] [log] [blame]
Marc Kupietzd871d882023-03-05 18:34:16 +01001<?php
2require_once 'vendor/autoload.php';
3
4class User
5{
Marc Kupietza57befa2023-03-06 21:39:23 +01006 public $username;
Marc Kupietzd871d882023-03-05 18:34:16 +01007 public $name;
8 public $first_name;
9 public $last_name;
10 public $email;
11 public $organization;
12 public $user_hash;
13 public $password;
Marc Kupietza57befa2023-03-06 21:39:23 +010014 function __construct()
15 {
16 $this->username = "";
17 $this->name = "";
18 $this->first_name = "";
19 $this->last_name = "";
20 $this->email = "";
21 $this->organization = "";
22 $this->user_hash = "";
23 $this->password = "";
24 }
Marc Kupietzd871d882023-03-05 18:34:16 +010025
Marc Kupietza57befa2023-03-06 21:39:23 +010026 function __construct6(string $username, string $first_name, string $last_name, string $email, string $password, string $organization)
Marc Kupietzd871d882023-03-05 18:34:16 +010027 {
28 include 'config.php';
Marc Kupietza57befa2023-03-06 21:39:23 +010029 $this->username = $username;
Marc Kupietzd871d882023-03-05 18:34:16 +010030 $this->name = $first_name;
31 $this->first_name = $first_name;
32 $this->last_name = $last_name;
33 $this->email = $email;
34 $this->organization = $organization;
Marc Kupietza57befa2023-03-06 21:39:23 +010035 $this->set_password($password);
36
37 }
38
39 function set_password(string $password)
40 {
41 include 'config.php';
Marc Kupietzd871d882023-03-05 18:34:16 +010042 if ($ENCRYPT_PASSWORDS) {
43 $this->user_hash = "{crypt}" . crypt($password, '$6$' . generateSalt(10) . '$');
44 # $this->user_hash = "{SHA}" . base64_encode(sha1($password, true));
45 } else {
46 $this->user_hash = "{CLEAR}" . $password;
47 }
48 $this->password = $this->user_hash;
Marc Kupietzd871d882023-03-05 18:34:16 +010049 }
50}
51
52?>