66 lines
2.4 KiB
PHP
Executable File
66 lines
2.4 KiB
PHP
Executable File
<?php define('__ROOT__', dirname(__FILE__) );
|
|
// \manager\session_start();
|
|
require_once __ROOT__.'/manager/autoloader.php';
|
|
|
|
/*******************************************/
|
|
/* DEBUGGER */
|
|
/*******************************************/
|
|
debug();
|
|
/*******************************************/
|
|
|
|
|
|
/* [0] On initialise le routeur
|
|
===================================================*/
|
|
$R = new router\Router( $_GET['url'] );
|
|
// var_dump($R);
|
|
|
|
/* [1] On cree les regles de routage
|
|
===================================================*/
|
|
// Racine -> page d'accueil
|
|
$R->get('/?', function(){ header('Location: /dashboard/'); });
|
|
|
|
// nomPage/arg1/arg2 -> inclusion de la page
|
|
$R->get('dashboard(?:/[\w-]+)*/?', function(){ include __ROOT__.'/view.php'; });
|
|
$R->get('profile(?:/[\w-]+)*/?', function(){ include __ROOT__.'/view.php'; });
|
|
$R->get('machines(?:/[\w-]+)*/?', function(){ include __ROOT__.'/view.php'; });
|
|
$R->get('users(?:/[\w-]+)*/?', function(){ include __ROOT__.'/view.php'; });
|
|
$R->get('analytics(?:/[\w-]+)*/?', function(){ include __ROOT__.'/view.php'; });
|
|
$R->get('settings(?:/[\w-]+)*/?', function(){ include __ROOT__.'/view.php'; });
|
|
|
|
// nomPage -> nomPage/
|
|
|
|
|
|
// $R->get('dashboard/', function(){ include __ROOT__.'/view.php'; });
|
|
// $R->get('machines/', function(){ include __ROOT__.'/view.php'; });
|
|
// $R->get('users/', function(){ include __ROOT__.'/view.php'; });
|
|
// $R->get('analytics/', function(){ include __ROOT__.'/view.php'; });
|
|
// $R->get('settings/', function(){ include __ROOT__.'/view.php'; });
|
|
|
|
// Dispatcher
|
|
$R->get('f(?:/([\w-]+))*/?', function(){ new \manager\ResourceDispatcher($_GET['url'], true); });
|
|
|
|
// Api
|
|
$R->post('api/?', function(){
|
|
$request = \manager\ModuleRequest::fromPost($_POST);
|
|
$answer = $request->dispatch();
|
|
|
|
echo $answer->serialize();
|
|
});
|
|
|
|
// N'importe -> page d'accueil
|
|
$R->get('.+', function(){ header('Location: /dashboard/'); });
|
|
|
|
|
|
// $R->post('.*', function(){
|
|
// var_dump( 'Acces POST : '.$_GET['url'] );
|
|
// var_dump( $_POST );
|
|
// });
|
|
|
|
|
|
|
|
|
|
/* [2] On lance le routeur
|
|
===================================================*/
|
|
$R->run();
|
|
|
|
?>
|