-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathuser.php
40 lines (35 loc) · 846 Bytes
/
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
<?php
include_once('Database.php');
class User
{
public static function is_logged_in()
{
if (!empty($_SESSION['loggedin'])) {
return $_SESSION['loggedin'];
}
return false;
}
public static function login($mail, $pswd)
{
$DBi = new Database();
if ($DBi->valid_user($mail, $pswd)) {
$_SESSION['loggedin'] = true;
$_SESSION['mail'] = $mail;
return true;
}
return false;
}
public static function register($mail, $pswd)
{
$DBi = new Database();
return $DBi->add_user($mail, $pswd);
}
public static function is_admin()
{
if (!empty($_SESSION['mail'])) {
$DBi = new Database();
$DBi->get_user($_SESSION['mail']);
}
return false;
}
}