2016-08-01 18:04:44 +02:00
|
|
|
<?php
|
2016-09-07 22:28:28 +00:00
|
|
|
|
2015-10-31 15:42:25 +01:00
|
|
|
require_once __DIR__.'/vendor/autoload.php';
|
2017-01-10 23:37:29 +01:00
|
|
|
use Alltube\Config;
|
2017-01-10 23:39:58 +01:00
|
|
|
use Alltube\Controller\FrontController;
|
2017-05-30 22:20:16 +02:00
|
|
|
use Alltube\LocaleManager;
|
2017-05-29 21:11:59 +02:00
|
|
|
use Alltube\LocaleMiddleware;
|
2017-05-02 17:04:55 +02:00
|
|
|
use Alltube\PlaylistArchiveStream;
|
2017-01-10 23:37:29 +01:00
|
|
|
use Alltube\UglyRouter;
|
2017-04-26 00:50:19 +02:00
|
|
|
use Alltube\ViewFactory;
|
|
|
|
use Slim\App;
|
2015-10-29 21:19:40 +01:00
|
|
|
|
2016-10-26 17:16:17 +02:00
|
|
|
if (isset($_SERVER['REQUEST_URI']) && strpos($_SERVER['REQUEST_URI'], '/index.php') !== false) {
|
2016-07-27 02:19:29 +02:00
|
|
|
header('Location: '.str_ireplace('/index.php', '/', $_SERVER['REQUEST_URI']));
|
|
|
|
die;
|
|
|
|
}
|
|
|
|
|
2017-05-02 17:04:55 +02:00
|
|
|
stream_wrapper_register('playlist', PlaylistArchiveStream::class);
|
|
|
|
|
2017-04-26 00:50:19 +02:00
|
|
|
$app = new App();
|
2016-03-30 01:39:47 +02:00
|
|
|
$container = $app->getContainer();
|
2017-01-10 23:37:29 +01:00
|
|
|
$config = Config::getInstance();
|
|
|
|
if ($config->uglyUrls) {
|
|
|
|
$container['router'] = new UglyRouter();
|
|
|
|
}
|
2017-04-26 00:50:19 +02:00
|
|
|
$container['view'] = ViewFactory::create($container);
|
2017-10-02 20:53:12 +02:00
|
|
|
|
|
|
|
if (!class_exists('Locale')) {
|
|
|
|
die('You need to install the intl extension for PHP.');
|
|
|
|
}
|
2017-05-30 22:20:16 +02:00
|
|
|
$container['locale'] = new LocaleManager($_COOKIE);
|
|
|
|
$app->add(new LocaleMiddleware($container));
|
2016-03-30 01:39:47 +02:00
|
|
|
|
2017-04-25 23:04:59 +02:00
|
|
|
$controller = new FrontController($container, null, $_COOKIE);
|
2016-04-08 19:06:41 +02:00
|
|
|
|
2016-09-07 22:28:28 +00:00
|
|
|
$container['errorHandler'] = [$controller, 'error'];
|
2016-05-01 01:25:08 +02:00
|
|
|
|
2015-10-29 21:23:02 +01:00
|
|
|
$app->get(
|
|
|
|
'/',
|
2016-09-07 22:28:28 +00:00
|
|
|
[$controller, 'index']
|
2016-06-09 21:15:44 +02:00
|
|
|
)->setName('index');
|
2015-10-29 21:23:02 +01:00
|
|
|
$app->get(
|
|
|
|
'/extractors',
|
2016-09-07 22:28:28 +00:00
|
|
|
[$controller, 'extractors']
|
2016-03-30 01:39:47 +02:00
|
|
|
)->setName('extractors');
|
2016-10-20 23:01:31 +02:00
|
|
|
$app->any(
|
2015-10-29 21:23:02 +01:00
|
|
|
'/video',
|
2016-09-07 22:28:28 +00:00
|
|
|
[$controller, 'video']
|
2016-03-30 01:39:47 +02:00
|
|
|
)->setName('video');
|
2015-10-31 11:48:14 +01:00
|
|
|
$app->get(
|
|
|
|
'/redirect',
|
2016-09-07 22:28:28 +00:00
|
|
|
[$controller, 'redirect']
|
2016-04-10 21:42:38 +02:00
|
|
|
)->setName('redirect');
|
2017-05-30 22:20:16 +02:00
|
|
|
$app->get(
|
|
|
|
'/locale/{locale}',
|
|
|
|
[$controller, 'locale']
|
|
|
|
)->setName('locale');
|
2017-10-02 21:07:13 +02:00
|
|
|
|
|
|
|
try {
|
|
|
|
$app->run();
|
|
|
|
} catch (\SmartyException $e) {
|
|
|
|
die('Smarty could not compile the template file: '.$e->getMessage());
|
|
|
|
}
|