function arranca() { try { $rutaLibSesiones = $this->rutaClases . 'Sesiones.php'; if (file_exists($rutaLibSesiones)) { include_once $rutaLibSesiones; } else { throw new Exception("No se encuentra la libreria {$rutaLibSesiones}"); } $sesionLib = NULL; if (class_exists('Sesiones', false)) { $sesionLib = new Sesiones(); } else { throw new Exception("No carga la libreria: {$rutaLibSesiones}"); } if (!$sesionLib->existeSesion()) { $_SESSION['idUser'] = $this->usuario; } $this->comprobarPeticion(); $d = $this->ejecutarAccion(); $this->imprimirPagina($d); } catch (Exception $exc) { echo "Fallo en Controlador Frontal--- " . $exc->getTraceAsString(); } }
public static function arranca() { include_once $rutaClases . 'Sesiones.php'; if (isset($_GET['controlador'])) { $controlador = $_GET['controlador']; } else { if (isset($_POST['controlador'])) { $controlador = $_POST['controlador']; } else { $controlador = 'indexControl'; } } if (isset($_GET['accion'])) { $accion = $_GET['accion'] . "Accion"; } else { $accion = 'indexAccion'; } $sesiones = new Sesiones(); if (!$sesiones->existeSesion()) { $controlador = 'indexControl'; $accion = 'indexAccion'; } $rutaControlador = $rutaClases . $controlador . '.php'; if (file_exists($rutaControlador)) { include_once $rutaControlador; } else { throw new Exception("No se encuentra el {$controlador} {$rutaControlador}"); } if (class_exists($controlador, false)) { $cont = new $controlador(); } else { throw new Exception("No carga el Controlador: {$controlador}"); } if (method_exists($cont, $accion)) { $datosSalida = $cont->{$accion}(); } else { throw new Exception("No se encuentra la accion: {$accion}"); } if (isset($datosSalida['pagina'])) { $rutapagina = $_SERVER['DOCUMENT_ROOT'] . '/web/' . $datosSalida['pagina']; if (isset($datosSalida['datos'])) { $datos = $datosSalida["datos"]; echo '<?php ' . $datos . ' ?>'; } if (file_exists($rutapagina)) { include_once $rutapagina; } } else { throw new Exception("No se encuentra la pagina a mostrar."); } }