-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.php
42 lines (31 loc) · 995 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
<?php
session_start();
include_once 'lib/helpers.php';
checkMainConfig();
include_once 'lib/config.php';
// get selected page from url
$selectedPage = isset($_GET['page']) ? $_GET['page'] : 'home';
// if user not logged in, show login page
if (empty($_SESSION['uname'])) {
$selectedPage = 'login';
} elseif ($selectedPage == 'login') {
header('Location: /');
exit;
} else {
$uname = $_SESSION['uname'];
}
$pages = include_once 'lib/pages.php';
if (empty($pages[$selectedPage]) || !is_file($pages[$selectedPage]['file'])) {
// if selected page not exist
$currentPage['pageTitle'] = 'Page not found';
$currentPage['pageBody'] = 'Page not found ('.$selectedPage.')';
} else {
$activePageDetails = $pages[$selectedPage];
$currentPage = include_once $activePageDetails['file'];
}
$header = include_once('partials/header.php');
$footer = include_once('partials/footer.php');
echo $header;
echo printAlerts();
echo $currentPage['pageBody'];
echo $footer;