-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathuser.php
47 lines (47 loc) · 1.16 KB
/
user.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
<?php
class User {
public $id = "";
public $name = "";
public $phone = "";
public $password = "";
public function __construct() {
$this->id = $id;(isset($data['id'])) ? $data['id'] : "";
$this->name = $name;
$this->phone = $phone;
$this->password = $password;
}
function delete($id) {
include('database.php');
unset ($dataBase[$id]);
file_put_contents("database.db", serialize($dataBase));
return;
}
function save() {
include('database.php');
$dataBase[count($dataBase)] = array($this->name => array($this->phone, $this->password));
file_put_contents("database.db", serialize($dataBase));
return ;
}
function login($login, $password) {
include('database.php');
$logged = false;
foreach ($dataBase as $users)
{
if (array_key_exists($login, $users))
{
$logged = $users[$login][1] === $password;
return $logged;
}
}
return $logged;
}
function getAll() {
include('database.php');
return $dataBase;
}
function findByID($id) {
include('database.php');
return $dataBase[$id];
}
}
?>