-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
41 lines (33 loc) · 1.04 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
<?php
session_start();
require_once 'Core/Config.php';
require_once 'Core/Helpers.php';
function loadController($controller){
$controller = ucwords($controller).'Controller';
$controllerFile = 'Controllers/'.$controller.'.php';
if(!is_file($controllerFile)){
$controllerFile = 'Controllers/'.ucwords(DEFAULT_CONTROLLER).'Controller.php';
}
require_once $controllerFile;
$controllerObj = new $controller();
return $controllerObj;
}
function loadAction($controllerObj, $action){
$execute = $action;
$controllerObj->$execute();
}
function executeAction($controllerObj){
if(isset($_GET["action"]) && method_exists($controllerObj, $_GET["action"])){
loadAction($controllerObj, $_GET["action"]);
}else{
loadAction($controllerObj, DEFAULT_ACTION);
}
}
if(isset($_GET["controller"])){
$controllerObj = loadController($_GET["controller"]);
executeAction($controllerObj);
}else{
$controllerObj = loadController(DEFAULT_CONTROLLER);
executeAction($controllerObj);
}
?>