-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathcheck.php
36 lines (30 loc) · 887 Bytes
/
check.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
<?php
session_start();
include './config.php';
$query = new Database();
if (!isset($_SESSION['loggedin']) || $_SESSION['loggedin'] !== true) {
header("Location: ./login/");
exit;
}
if (!isset($_SESSION['id']) || empty($_SESSION['id'])) {
header("Location: ./login/");
exit;
}
$userStatus = $query->select('accounts', 'status', 'WHERE id = "' . $_SESSION['id'] . '"');
if (!isset($userStatus[0]['status']) || empty($userStatus[0]['status']) || $userStatus[0]['status'] === 'blocked') {
header("Location: ./blocked_page.php");
exit;
}
if (!isset($_SESSION['role']) || $_SESSION['role'] !== 'user') {
$roles = [
'admin' => './admin/',
'seller' => './seller/',
];
if (isset($roles[$_SESSION['role']])) {
header("Location: " . $roles[$_SESSION['role']]);
} else {
header("Location: ./login/");
}
exit;
}
?>