-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathauth.php
More file actions
47 lines (35 loc) · 797 Bytes
/
auth.php
File metadata and controls
47 lines (35 loc) · 797 Bytes
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
require_once '../Log.php';
require_once '../Input.php';
class Auth
{
public static $password = '$2y$10$SLjwBwdOVvnMgWxvTI4Gb.YVcmDlPTpQystHMO2Kfyi/DS8rgA0Fm';
public static function attempt($username, $password)
{
$log = new Log;
if($username == 'guest' && password_verify($password,
self::$password)) {
$_SESSION['logged_in_user'] = $username;
$log->info('User ' . $username . 'logged in');
} else {
$log->error('User'. $username . 'failed to log in!');
}
}
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_regenerate_id(true);
}
}