Marc Kupietz | 0215a44 | 2023-03-05 18:34:16 +0100 | [diff] [blame] | 1 | <?php |
| 2 | require_once 'vendor/autoload.php'; |
| 3 | |
| 4 | class User |
| 5 | { |
Marc Kupietz | ade9e3c | 2023-03-06 21:39:23 +0100 | [diff] [blame^] | 6 | public $username; |
Marc Kupietz | 0215a44 | 2023-03-05 18:34:16 +0100 | [diff] [blame] | 7 | public $name; |
| 8 | public $first_name; |
| 9 | public $last_name; |
| 10 | public $email; |
| 11 | public $organization; |
| 12 | public $user_hash; |
| 13 | public $password; |
Marc Kupietz | ade9e3c | 2023-03-06 21:39:23 +0100 | [diff] [blame^] | 14 | 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 Kupietz | 0215a44 | 2023-03-05 18:34:16 +0100 | [diff] [blame] | 25 | |
Marc Kupietz | ade9e3c | 2023-03-06 21:39:23 +0100 | [diff] [blame^] | 26 | function __construct6(string $username, string $first_name, string $last_name, string $email, string $password, string $organization) |
Marc Kupietz | 0215a44 | 2023-03-05 18:34:16 +0100 | [diff] [blame] | 27 | { |
| 28 | include 'config.php'; |
Marc Kupietz | ade9e3c | 2023-03-06 21:39:23 +0100 | [diff] [blame^] | 29 | $this->username = $username; |
Marc Kupietz | 0215a44 | 2023-03-05 18:34:16 +0100 | [diff] [blame] | 30 | $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 Kupietz | ade9e3c | 2023-03-06 21:39:23 +0100 | [diff] [blame^] | 35 | $this->set_password($password); |
| 36 | |
| 37 | } |
| 38 | |
| 39 | function set_password(string $password) |
| 40 | { |
| 41 | include 'config.php'; |
Marc Kupietz | 0215a44 | 2023-03-05 18:34:16 +0100 | [diff] [blame] | 42 | 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 Kupietz | 0215a44 | 2023-03-05 18:34:16 +0100 | [diff] [blame] | 49 | } |
| 50 | } |
| 51 | |
| 52 | ?> |