-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.php
More file actions
84 lines (65 loc) · 1.91 KB
/
index.php
File metadata and controls
84 lines (65 loc) · 1.91 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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
<?php
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
/* Variables Globales */
$instancia = '';
$request = '';
//Preparacion de Url
$request_uri = @parse_url($_SERVER['REQUEST_URI']);
$path = $request_uri['path'];
$request = explode('/', trim($path, '/'));
array_shift($request);
$isview = false;
$instance = array_shift($request);
$modulo = array_shift($request);
if ($modulo=='webapp')
{
$modulo = array_shift($request);
$isview == true;
}
//Utilidades
include('./modulos/utilidades/conexion.php');
include('./modulos/utilidades/errores.php');
include('./modulos/utilidades/app.php');
include('./modulos/utilidades/controller.php');
//Inicializacion
$app = new App;
$app->start($request, $_POST,$_GET,$instance);
$app->connect((new Conexion)->conectar($app));
if (!isset($modulo))
{
(new Errores)->throwError($app,500,'<br>No llamaste a ninguna funcion en la API');
}
if ($isview)
{
$url = './modulos/'.$modulo.'/modulo.php';
if (!file_exists($url))
(new Errores)->throwError($app,404,'Modulo inexistente: '.$modulo);
//echo('<br>La url que te abrira un modulo dinamicamente es<br>'.$url);
include($url);
$controller = new $modulo ($app);
$app->run();
}
else
{
$url = './vistas/'.$modulo.'/'.$app->request[0].'.html';
if (!file_exists($url))
(new Errores)->throwError($app,404,'Modulo inexistente: '.$url);
include($url);
}
//echo('<br>Estas en la instancia '.$instancia);
/*foreach ($selectors as $regex => $funcs) {
if (preg_match($regex, $path, $args)) {
$method = $_SERVER['REQUEST_METHOD'];
if (isset($funcs[$method])) {
// here the request is handled and the correct method called.
echo "calling ".$funcs[$method]." for ".print_r($args);
$output = $funcs[$method]($args);
// handling the output...
}
break;
}
}*/
//$conn->close();
?>