alltube/index.php
Pierre Rudloff 3fff849ea8 Merge branch 'master' of https://github.com/tony199555/alltube into feature/gettext
Conflicts:
	composer.json
	composer.lock
	templates/index.tpl
	templates/video.tpl
2017-05-29 19:01:20 +02:00

51 lines
1.2 KiB
PHP

<?php
$language = 'zh_CN';
putenv('LANG='.$language);
setlocale(LC_ALL, [$language, $language.'.utf8']);
require_once __DIR__.'/vendor/autoload.php';
use Alltube\Config;
use Alltube\Controller\FrontController;
use Alltube\PlaylistArchiveStream;
use Alltube\UglyRouter;
use Alltube\ViewFactory;
use Slim\App;
if (isset($_SERVER['REQUEST_URI']) && strpos($_SERVER['REQUEST_URI'], '/index.php') !== false) {
header('Location: '.str_ireplace('/index.php', '/', $_SERVER['REQUEST_URI']));
die;
}
stream_wrapper_register('playlist', PlaylistArchiveStream::class);
$app = new App();
$container = $app->getContainer();
$config = Config::getInstance();
if ($config->uglyUrls) {
$container['router'] = new UglyRouter();
}
$container['view'] = ViewFactory::create($container);
$controller = new FrontController($container, null, $_COOKIE);
$container['errorHandler'] = [$controller, 'error'];
$app->get(
'/',
[$controller, 'index']
)->setName('index');
$app->get(
'/extractors',
[$controller, 'extractors']
)->setName('extractors');
$app->any(
'/video',
[$controller, 'video']
)->setName('video');
$app->get(
'/redirect',
[$controller, 'redirect']
)->setName('redirect');
$app->run();