Exemplo n.º 1
0
 public static function negotiate(array $array)
 {
     if (!isset($_SESSION['user'])) {
         return Redirect::process('/auth/login');
     }
     return IndexController::indexAction();
 }
Exemplo n.º 2
0
    $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");
}