/
index.php
118 lines (89 loc) · 2.81 KB
/
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
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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
<?php
ini_set('display_errors',1);
error_reporting(E_ALL);
require_once './Config.php';
require_once './lib/DB/Database.php';
require_once './lib/Site/Page.php';
require_once './lib/Site/StandardLayout.php';
require_once './lib/Site/StandardNavigation.php';
require_once './lib/Util/Context.php';
require_once './lib/Util/SessionUtil.php';
if(!SessionUtil::start())
echo "Error Starting Session";
Database::Open();
$context = new Context();
$context->setPageID("home");
if(isset($_GET['pageid'])){
$context->setPageID($_GET['pageid']);
}
else if(isset($_POST['pageid'])){
$context->setPageID($_POST['pageid']);
}
if(isset($_POST['action'])){
$action = $_POST['action'];
if($context->getPageID() == "login"){
require_once './lib/Form/LoginHandler.php';
$loginHandler = new LoginHandler();
$loginHandler->handleForm($context, $action);
}
else if($context->getPageID() == "register"){
require_once './lib/Form/RegisterHandler.php';
$registerHandler = new RegisterHandler();
$registerHandler->handleForm($context, $action);
}
else if($context->getPageID() == "createInsertion"){
require_once './lib/Form/CreateInsertionHandler.php';
$createInsertionHandler = new CreateInsertionHandler();
$createInsertionHandler->handleForm($context, $action);
}
else if($context->getPageID() == "myAccount"){
require_once './lib/Form/MyAccountHandler.php';
$myAccountHandler = new MyAccountHandler();
$myAccountHandler->handleForm($context, $action);
}
}
if(!SessionUtil::isLoggedIn() && $context->getPageID() != "register"){
$context->setPageID("login");
}
$pageBody;
if($context->getPageID() == "home"){
require_once './lib/Site/HomeBody.php';
$pageBody = new HomeBody();
}
else if($context->getPageID() == "login"){
require_once './lib/Site/LoginBody.php';
$pageBody = new LoginBody($context);
}
else if($context->getPageID() == "register"){
require_once './lib/Site/RegisterBody.php';
$pageBody = new RegisterBody($context);
}
else if($context->getPageID() == "logout"){
SessionUtil::restart();
$context->setPageID("login");
require_once './lib/Site/LoginBody.php';
$pageBody = new LoginBody($context);
}
else if($context->getPageID() == "createInsertion"){
require_once './lib/Site/CreateInsertBody.php';
$pageBody = new CreateInsertBody($context);
}
else if($context->getPageID() == "myInserts"){
require_once './lib/Site/MyInsertsBody.php';
$pageBody = new MyInsertsBody();
}
else if($context->getPageID() == "myAccount"){
require_once './lib/Site/MyAccountBody.php';
$pageBody = new MyAccountBody($context);
}
else{
$context->setPageID("home");
require_once './lib/Site/HomeBody.php';
$pageBody = new HomeBody();
}
$pageNavigation = new StandardNavigation($context);
$layout = new StandardLayout($pageNavigation, $pageBody);
$page = new Page(0, $layout);
$page->displayPage();
Database::Close();
?>