-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.php
More file actions
100 lines (79 loc) · 2.38 KB
/
index.php
File metadata and controls
100 lines (79 loc) · 2.38 KB
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
<?php
/**
* Created by PhpStorm.
* User: Frank
* Date: 02/08/2018
* Time: 18:22
*/
include_once("config/config.inc.php");
include_once("functionsSql.inc.php");
include_once("functionsHtml.inc.php");
$defaultPage = "main.php";
global $page; //requestedPage.php, pageParameter, arrMessages
global $pageRequested;
global $pageParameter;
global $pageStatus;
$pageStatus=array();
$error = false;
session_start();
fctSessionCheck(); //check the session duration and reset the counter
//catch ?id= and check if key exist
if (isset($_GET['id']) && isset($_SESSION['key'])) {
try {
$urlId = fctUrlOpensslDecipher($_GET['id']);
$page = explode(',', $urlId);
} catch (Exception $e) {
$pageStatus[] = array("error", "Error", "Url serialisation Issue");
}
if ($page[0] == 'logout.php') {
file_exists($page[0]) ? include($page[0]) : include($defaultPage);
exit();
}
}
//html head /!\ any php header() needs to be before
include_once("header.inc.php");
?>
<body>
<?php
//case when user not logged in
if (!isset($_SESSION['user']['id'])) {
include("loginForm.php");
//case logged
} else {
include_once("nav.inc.php"); //which includes the counter
//then when a page is requested
if (isset($_GET['id'])) {
//parsing page parameter if existing
isset($page[0]) ? $pageRequested = $page[0] : $pageRequested = "";
isset($page[1]) ? $pageParameter = $page[1] : $pageParameter = 0;
if (isset($page[2])) {
try {
$pageStatus = unserialize($page[2]);
} catch (Exception $e) {
$pageStatus[] = array("error", "Error", "Url serialisation Issue");
}
} else {
//$pageStatus = "";
}
//last check if requested page (file) veritably exists + avoid calling itself
if (file_exists($pageRequested) && $pageRequested != 'index.php') {
include($pageRequested);
} else {
$pageStatus[] = array("error", "Error", "Page not found");
include($defaultPage);
}
} else {
//case logged user but no page requested
include($defaultPage);
}
}
if ($pageStatus) {
foreach ($pageStatus as $item) {
fctShowToast($item[0], $item[1], $item[2]);
}
}
getDebug(); //toast alert with $_SESSION and $Page details
include_once("footer.inc.php")
?>
</body>
</html>