-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
35 lines (35 loc) · 962 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
<?php
require_once 'Config/Config.php';
$ruta = !empty($_GET['url']) ? $_GET['url'] : "home/index";
$array = explode("/", $ruta);
$controller = ucfirst($array[0]);
$metodo = "index";
$parametro = "";
if (!empty($array[1])) {
if (!empty($array[1] != "")) {
$metodo = $array[1];
}
}
if (!empty($array[2])) {
if (!empty($array[2] != "")) {
for ($i = 2; $i < count($array); $i++) {
$parametro .= $array[$i] . ",";
}
$parametro = trim($parametro, ",");
}
}
require_once 'Config/App/Autoload.php';
require_once 'Config/Helpers.php';
$dirControllers = "Controllers/" . $controller . ".php";
if (file_exists($dirControllers)) {
require_once $dirControllers;
$controller = new $controller();
if (method_exists($controller, $metodo)) {
$controller->$metodo($parametro);
} else {
header('Location: '.BASE_URL.'err');
}
} else {
header('Location: ' . BASE_URL . 'err');
}
?>