2016-02-01 22:09:35 +00:00
|
|
|
<?php define('__ROOT__', dirname(__FILE__) );
|
|
|
|
require_once 'manager/autoloader.php';
|
|
|
|
|
2016-02-02 22:29:30 +00:00
|
|
|
/*******************************************/
|
|
|
|
/* DEBUGGER */
|
|
|
|
/*******************************************/
|
|
|
|
ini_set('display_errors',1);
|
|
|
|
ini_set('display_startup_errors',1);
|
|
|
|
error_reporting(-1);
|
|
|
|
/*******************************************/
|
2016-02-01 22:09:35 +00:00
|
|
|
|
|
|
|
|
|
|
|
/* [0] On initialise le routeur
|
|
|
|
===================================================*/
|
|
|
|
$R = new router\Router( $_GET['url'] );
|
|
|
|
// var_dump($R);
|
|
|
|
|
|
|
|
/* [1] On cree les regles de routage
|
|
|
|
===================================================*/
|
2016-02-02 22:29:30 +00:00
|
|
|
// Racine -> page d'accueil
|
2016-02-02 10:09:48 +00:00
|
|
|
$R->get('/?', function(){ header('Location: /dashboard/'); });
|
2016-02-01 22:09:35 +00:00
|
|
|
|
2016-02-02 22:29:30 +00:00
|
|
|
// nomPage/arg1/arg2 -> inclusion de la page
|
|
|
|
$R->get('dashboard(?:/[\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('sync(?:/[\w-]+)*/??', function(){ include __ROOT__.'/view.php'; });
|
|
|
|
$R->get('settings(?:/[\w-]+)*/??', function(){ include __ROOT__.'/view.php'; });
|
|
|
|
|
|
|
|
// nomPage -> nomPage/
|
|
|
|
$R->get('dashboard', function(){ header('Location: /dashboard/'); });
|
|
|
|
$R->get('machines', function(){ header('Location: /machines/'); });
|
|
|
|
$R->get('users', function(){ header('Location: /users/'); });
|
|
|
|
$R->get('sync', function(){ header('Location: /sync/'); });
|
|
|
|
$R->get('settings', function(){ header('Location: /settings/'); });
|
|
|
|
|
|
|
|
$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('sync/', function(){ include __ROOT__.'/view.php'; });
|
|
|
|
$R->get('settings/', function(){ include __ROOT__.'/view.php'; });
|
|
|
|
|
|
|
|
// Dispatcher
|
2016-02-03 07:45:42 +00:00
|
|
|
$R->get('f(?:/([\w-]+))*/?', function(){ new manager\ResourcesDispatcher($_GET['url']); });
|
2016-02-02 22:29:30 +00:00
|
|
|
|
|
|
|
// N'importe -> page d'accueil
|
2016-02-02 10:09:48 +00:00
|
|
|
$R->get('.+', function(){ header('Location: /dashboard/'); });
|
2016-02-01 22:09:35 +00:00
|
|
|
|
|
|
|
|
|
|
|
$R->post('.*', function(){
|
2016-02-02 10:09:48 +00:00
|
|
|
var_dump( 'Acces POST : '.$_GET['url'] );
|
2016-02-01 22:09:35 +00:00
|
|
|
});
|
|
|
|
|
2016-02-02 10:09:48 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
2016-02-01 22:09:35 +00:00
|
|
|
/* [2] On lance le routeur
|
|
|
|
===================================================*/
|
|
|
|
$R->run();
|
|
|
|
|
|
|
|
?>
|