You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
92 lines
2.7 KiB
92 lines
2.7 KiB
<?php
|
|
|
|
//require 'usages/AltoRouter.php';
|
|
|
|
/*class FrontController
|
|
{
|
|
|
|
function __construct()
|
|
{
|
|
global $dsn, $user, $pass, $vues;
|
|
$listeAction_Acceuil = array('goToSolo', 'goToMulti', 'goToAdmin');
|
|
try {
|
|
$action = "";
|
|
|
|
if (isset($_REQUEST['action'])) {
|
|
$action = $_REQUEST['action'];
|
|
}
|
|
|
|
if (in_array($action, $listeAction_Acceuil)) {
|
|
|
|
}
|
|
} catch (Exception $e) {
|
|
header("Location:" . $vues["erreur"]);
|
|
}
|
|
}
|
|
}*/
|
|
|
|
class FrontController
|
|
{
|
|
function __construct()
|
|
{
|
|
global $dsn, $user, $pass, $vues;
|
|
$listeAction_Acceuil = array('goToSolo', 'goToMulti', 'goToAdmin');
|
|
|
|
try {
|
|
$action = "";
|
|
if (isset($_REQUEST['action'])) {
|
|
$action = $_REQUEST['action'];
|
|
}
|
|
|
|
// Initialize AltoRouter
|
|
$router = new AltoRouter();
|
|
|
|
//$router->setBasePath('/');
|
|
|
|
// Define routes
|
|
$router->map('GET', '/', 'ControllerAccueil'); // Route pour la page d'accueil
|
|
$router->map('GET', '/solo', 'ControllerSolo');
|
|
$router->map('GET', '/multi', 'ControllerMulti');
|
|
$router->map('GET', '/admin', 'ControllerAdmin');
|
|
$router->map('GET', '/login', 'ControllerLoginAdmin');
|
|
$router->map('GET', '/admin/chapters', 'ControllerAdminChapters');
|
|
$router->map('GET', '/admin/administrators', 'ControllerAdminAdministrators');
|
|
$router->map('GET', '/admin/users', 'ControllerAdminUsers');
|
|
|
|
// Match the current request
|
|
$match = $router->match();
|
|
|
|
if (!$match) {
|
|
echo "404"; // Redirige vers une page d'erreur 404
|
|
die;
|
|
}
|
|
|
|
if ($match) {
|
|
$controller = $match['target'];
|
|
$action=$match['params']['action'];
|
|
$id=$match['params']['id']; // paramètre 2
|
|
|
|
$controller = new $controller;
|
|
|
|
if (is_callable($match['target'])) {
|
|
call_user_func_array($match['target'], $match['params']);
|
|
}
|
|
|
|
/*
|
|
if (is_callable(array($controller, $action))) {
|
|
call_user_func_array(array($controller, $action), array($match['params'])); }
|
|
}
|
|
else {
|
|
if (is_callable($match['target'])) {
|
|
call_user_func_array($match['target'], $match['params']);
|
|
}
|
|
}
|
|
*/
|
|
}
|
|
}
|
|
catch (Exception $e) {
|
|
header("Location:" . $vues["erreur"]);
|
|
}
|
|
}
|
|
}
|