-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
41 lines (32 loc) · 945 Bytes
/
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 "autoload.php";
require_once "config/db.php";
require_once "config/parameters.php";
require_once "helpers/utils.php";
require_once "views/layout/header.php";
require_once "views/layout/sidebar.php";
if(!isset($_GET["controller"]) && !isset($_GET["action"])) {
$controller_name = default_controller;
$default = default_action;
$controller = new $controller_name();
$controller->$default();
exit();
}
if(!isset($_GET["controller"])) {
Utils::showNotFoundError();
exit();
}
$controller_name = $_GET["controller"]."Controller";
if(!class_exists($controller_name)) {
Utils::showNotFoundError();
exit();
}
$controller = new $controller_name();
if(!isset($_GET["action"]) || !method_exists($controller, $_GET["action"])) {
Utils::showNotFoundError();
exit();
}
$action = $_GET["action"];
$controller->$action();
require_once("views/layout/footer.php");