2020-05-17 22:30:22 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
require '../main.php';
|
|
|
|
|
|
|
|
// very basic routing
|
2020-05-20 13:06:40 +02:00
|
|
|
$host = $_SERVER["REQUEST_SCHEME"] . '://' . $_SERVER["SERVER_NAME"];
|
2020-05-17 22:30:22 +02:00
|
|
|
$url = $_SERVER['REQUEST_URI'];
|
2020-05-25 18:52:31 +02:00
|
|
|
if (($pos = strpos($url, '?')) !== false) {
|
|
|
|
$url = substr($url, 0, $pos);
|
|
|
|
}
|
2020-05-17 22:30:22 +02:00
|
|
|
switch($url) {
|
2020-05-19 16:13:57 +02:00
|
|
|
case '/game':
|
|
|
|
$controller = new MapGuesser\Controller\GameController();
|
2020-05-17 22:30:22 +02:00
|
|
|
break;
|
2020-05-26 23:19:23 +02:00
|
|
|
case '/game.json':
|
|
|
|
$controller = new MapGuesser\Controller\GameController(true);
|
|
|
|
break;
|
2020-05-25 19:46:31 +02:00
|
|
|
case '/position.json':
|
|
|
|
$controller = new MapGuesser\Controller\PositionController();
|
2020-05-19 03:19:23 +02:00
|
|
|
break;
|
2020-05-20 13:06:40 +02:00
|
|
|
case '/':
|
|
|
|
header('Location: ' . $host . '/game', true, 302);
|
|
|
|
die;
|
2020-05-17 22:30:22 +02:00
|
|
|
default:
|
|
|
|
echo 'Error 404';
|
|
|
|
die;
|
|
|
|
}
|
|
|
|
|
2020-05-19 03:19:23 +02:00
|
|
|
$view = $controller->run();
|
|
|
|
|
|
|
|
header('Content-Type: ' . $view->getContentType() . '; charset=UTF-8');
|
|
|
|
|
|
|
|
echo $view->render();
|