-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.php
51 lines (45 loc) · 1.36 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
<?php
include_once 'controllers/UserController.php';
include_once 'controllers/HomeController.php';
// Grabs the URI and breaks it apart in case we have querystring stuff
$request_uri = explode('?', $_SERVER['REQUEST_URI'], 2);
// Checking for resources and image files to route it differently
if (preg_match('/\.(?:png|jpg|jpeg|gif|js|css)$/', $_SERVER["REQUEST_URI"])) {
return false; // Serve the requested resource as-is.
}
// Instance of the controllers
$homeController = new \controllers\HomeController();
$userController = new \controllers\UserController();
// Routing it up!
switch ($request_uri[0]) {
case '/':
return $userController->index();
break;
case '/home':
return $homeController->index();
break;
case '/register':
return $userController->doRegister();
break;
case '/login':
return $userController->doLogin();
break;
case '/addPost':
return $homeController->addPost();
break;
case '/admin':
return $homeController->adminHome();
break;
case '/detailView':
return $homeController->detailView();
break;
case '/editPost':
return $homeController->editPost();
break;
case '/logout':
return $userController->doLogout();
break;
default:
echo "404 not found";
break;
}