public static function createAction() { // if($_SESSION['user']->isEtu()) return Redirect::process('/'); if (empty($_POST)) { return new View('qcm/create.php'); } $qcm = QCMController::decode($_POST['data']); if (is_null($qcm)) { return new View('qcm/create.php', array('error' => "Une erreur est survenue !")); } return Redirect::process('/qcm/successCreate'); }
$namespace = str_replace('\\', DIRECTORY_SEPARATOR, $classname); $classPath = ROOT . str_replace('\\', '/', $namespace) . '.php'; // echo $classPath . ' For : ' . $classname . '<br>'; if (is_readable($classPath)) { require_once $classPath; } }); define('ROOT', __DIR__ . DIRECTORY_SEPARATOR); define('LEVEL_1', 2); // Profondeur de l'url (ici marca.finch4.xyz/mp/ donc 2 ==> ["", "mp", "MyController"]) use MyFW\Redirect; use MyFW\View; use QCM\Controller\AuthController; use QCM\Controller\IndexController; use QCM\Controller\QCMController; use QCM\Model\User; session_start(); $paths = explode('/', $_SERVER['REQUEST_URI']); if ($paths[LEVEL_1] === "") { return IndexController::negotiate(array()); } switch ($paths[LEVEL_1]) { case 'auth': AuthController::negotiate(array_slice($paths, LEVEL_1 + 1)); break; case 'qcm': QCMController::negotiate(array_slice($paths, LEVEL_1 + 1)); break; default: new View("errors/404.php"); }