コード例 #1
0
 public static function negotiate(array $array)
 {
     switch ($array[0]) {
         case 'login':
             AuthController::loginAction();
             break;
         case 'logout':
             AuthController::logoutAction();
             break;
         default:
             Redirect::process('/auth/login');
             break;
     }
 }
コード例 #2
0
ファイル: index.php プロジェクト: Embraser01/IUT-MP-TP
    $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");
}