-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.php
More file actions
52 lines (45 loc) · 1.26 KB
/
index.php
File metadata and controls
52 lines (45 loc) · 1.26 KB
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
<?php
$ruta = !empty($_GET['url']) ? $_GET['url'] : "principal";
$array = explode("/", $ruta);
$controller = "Home";
$metodo = $array[0];
$parametro = "";
if(!empty($array[1])){
if(!empty($array[1] != '')){
for($i = 1; $i < count($array); $i++){
$parametro .= $array[$i].",";
}
$parametro = trim($parametro,",");
}
}
/* define("URL_BASE", "/");
define("PATH_PAGES", __DIR__ . DIRECTORY_SEPARATOR . "pages" . DIRECTORY_SEPARATOR);
$path = $_SERVER['REQUEST_URI'];
if (substr($path, 0, strlen(URL_BASE)) == URL_BASE) {
$path = substr($path, strlen(URL_BASE));
}
$path = explode("/", rtrim($path, "/\\"));
print_r($path); */
require_once 'Config/App/autoload.php';
$diController = "Controllers/".$controller.".php";
$diView = "Views/".$metodo.".php";
if(file_exists($diController)){
require_once $diController;
$controller = new $controller();
if(file_exists(($diView))){
if(method_exists($controller, 'principal')){
$controller->principal($metodo,$parametro);
}
else{
include"views/404.php";
}
}else{
if(method_exists($controller, 'principal')){
$controller->principal('principal','');
}
}
}
else{
echo "No existe el controlador";
}
?>