-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.php
64 lines (56 loc) · 1.38 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
<?php
session_start();
define('DS', DIRECTORY_SEPARATOR);
define('WWW_ROOT', __DIR__ . DS);
$routes = array(
'index' => array(
'controller' => 'Users',
'action' => 'index'
),
'profile' => array(
'controller' => 'Users',
'action' => 'profile'
),
'register' => array(
'controller' => 'Users',
'action' => 'register'
),
'login' => array(
'controller' => 'Users',
'action' => 'login'
),
'logout' => array(
'controller' => 'Users',
'action' => 'logout'
),
'newproject' => array(
'controller' => 'Pages',
'action' => 'newproject'
),
'scrum' => array(
'controller' => 'Pages',
'action' => 'scrum'
),
'whiteboard' => array(
'controller' => 'Pages',
'action' => 'whiteboard'
),
'addMember' => array(
'controller' => 'Pages',
'action' => 'addMember'
)
);
if(empty($_GET['page'])){
$_GET['page'] = 'index';
}
if(empty($routes[$_GET['page']])) {
header('Location: index.php');
exit();
}
$route = $routes[$_GET['page']];
$controllerName = $route['controller'] . 'Controller';
require_once WWW_ROOT . 'controller' . DS . $controllerName . ".php";
$controllerObj = new $controllerName();
$controllerObj->route = $route;
$controllerObj->filter();
$controllerObj->render();