/
Auth.php
75 lines (40 loc) · 1019 Bytes
/
Auth.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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
<?php
require_once 'Log.php';
// $log = new Log("password");
class Auth
{
public static $password = '$2y$10$SLjwBwdOVvnMgWxvTI4Gb.YVcmDlPTpQystHMO2Kfyi/DS8rgA0Fm';
public static function attempt($username, $password)
{
$log = new Log("ERROR");
$logInfo = new LOG("INFO");
if ($username == 'guest' && password_verify($password, self::$password))
{
$_SESSION['logged_in_user'] = $username;
$logInfo->logInfo("User " . $username . " is logged in. ");
} else if ($username != '' && $password != '')
{
$log->logError("login Info incorrect!!");
echo "You are WRONG!!!!";
}
}
public static function check()
{
if (isset($_SESSION['logged_in_user']))
{
return true;
} else {
return false;
}
}
public static function user()
{
return $_SESSION['logged_in_user'];
}
public static function logout()
{
session_unset();
session_destroy();
session_regenerate_id();
}
}