-
Notifications
You must be signed in to change notification settings - Fork 0
/
header_functions.php
49 lines (46 loc) · 1.34 KB
/
header_functions.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
<?php
session_start();
require_once('php/Gebruiker.php');
if (array_key_exists('login', $_POST))
{
$loginReturn = Gebruiker::login($_POST['username'], $_POST['password'], (bool)$_POST['rememberLogin'], false);
if ($loginReturn === false)
{
Gebruiker::logout();
$GLOBALS['userLoggedIn'] = false;
}
else if ($loginReturn === 'banned')
{
Gebruiker::logout();
$GLOBALS['userBanned'] = true;
$GLOBALS['userLoggedIn'] = null;
}
unset($loginReturn);
unset($_POST['username']);
unset($_POST['password']);
unset($_POST['rememberLogin']);
}
else if (array_key_exists('logout', $_POST)) Gebruiker::logout();
if (!isset($GLOBALS['userLoggedIn'])) $GLOBALS['userLoggedIn'] = Gebruiker::loggedIn();
if ($GLOBALS['userLoggedIn'] === null && !array_key_exists('logout', $_POST) && array_key_exists('username', $_COOKIE) &&
array_key_exists('password', $_COOKIE))
{
$loginReturn = Gebruiker::login($_COOKIE['username'], $_COOKIE['password'], false, true);
if ($loginReturn === true)
$GLOBALS['userLoggedIn'] = true;
if ($loginReturn === false)
{
Gebruiker::logout();
$GLOBALS['userLoggedIn'] = false;
}
else if ($loginReturn === 'banned')
{
Gebruiker::logout();
$GLOBALS['userBanned'] = true;
$GLOBALS['userLoggedIn'] = null;
}
unset($loginReturn);
unset($_POST['username']);
unset($_POST['password']);
unset($_POST['rememberLogin']);
}