-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
54 lines (47 loc) · 1015 Bytes
/
index.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
<?php
include 'db/pdo.php';
include 'utils/utils.php';
session_start();
?>
<?php
if (array_key_exists('v', $_GET)) {
$module = $_GET['v'];
} else {
if (isset($_SESSION['admin'])) {
$module = 'posts';
} else {
$module = 'home';
}
}
if (isset($_SESSION['admin'])) {
if ($_SESSION['admin'] == true) {
$moduleDir = 'modules/admin/' . $module . '.php';
} else {
$moduleDir = 'modules/user/' . $module . '.php';
}
} else {
$moduleDir = 'modules/user/' . $module . '.php';
}
if (file_exists($moduleDir)) {
ob_start();
include $moduleDir;
$content = ob_get_contents();
ob_end_clean();
if (isset($_SESSION['admin'])) {
include 'layouts/admin.php';
} elseif (!isset($_SESSION['admin']) || $_SESSION['admin'] == false) {
include 'layouts/user.php';
}
} else {
header("HTTP/1.1 404 Not Found");
}
if (isset($_GET['logout']) == 1) {
@session_destroy();
$page = $_SERVER['PHP_SELF'];
$sec = "0";
if (isset($_SESSION['admin'])) {
$_SESSION['admin'] = false;
}
header('refresh: 1;');
}
?>