2016-08-01 16:04:44 +00:00
|
|
|
<?php
|
2016-09-07 22:28:28 +00:00
|
|
|
|
2019-10-03 19:24:12 +00:00
|
|
|
require_once __DIR__ . '/vendor/autoload.php';
|
2017-01-10 22:37:29 +00:00
|
|
|
use Alltube\Config;
|
2019-04-22 15:04:59 +00:00
|
|
|
use Alltube\Controller\DownloadController;
|
2017-01-10 22:39:58 +00:00
|
|
|
use Alltube\Controller\FrontController;
|
2019-04-22 14:05:58 +00:00
|
|
|
use Alltube\Controller\JsonController;
|
2017-05-30 20:20:16 +00:00
|
|
|
use Alltube\LocaleManager;
|
2017-05-29 19:11:59 +00:00
|
|
|
use Alltube\LocaleMiddleware;
|
2017-01-10 22:37:29 +00:00
|
|
|
use Alltube\UglyRouter;
|
2017-04-25 22:50:19 +00:00
|
|
|
use Alltube\ViewFactory;
|
|
|
|
use Slim\App;
|
2019-11-27 20:22:23 +00:00
|
|
|
use Symfony\Component\Debug\Debug;
|
2015-10-29 20:19:40 +00:00
|
|
|
|
2016-10-26 15:16:17 +00:00
|
|
|
if (isset($_SERVER['REQUEST_URI']) && strpos($_SERVER['REQUEST_URI'], '/index.php') !== false) {
|
2019-10-03 19:24:12 +00:00
|
|
|
header('Location: ' . str_ireplace('/index.php', '/', $_SERVER['REQUEST_URI']));
|
2016-07-27 00:19:29 +00:00
|
|
|
die;
|
|
|
|
}
|
|
|
|
|
2019-10-03 19:24:12 +00:00
|
|
|
if (is_file(__DIR__ . '/config/config.yml')) {
|
|
|
|
Config::setFile(__DIR__ . '/config/config.yml');
|
2019-04-21 16:30:02 +00:00
|
|
|
}
|
|
|
|
|
2017-04-25 22:50:19 +00:00
|
|
|
$app = new App();
|
2016-03-29 23:39:47 +00:00
|
|
|
$container = $app->getContainer();
|
2017-01-10 22:37:29 +00:00
|
|
|
$config = Config::getInstance();
|
|
|
|
if ($config->uglyUrls) {
|
|
|
|
$container['router'] = new UglyRouter();
|
|
|
|
}
|
2019-11-27 20:22:23 +00:00
|
|
|
|
|
|
|
if ($config->debug) {
|
|
|
|
Debug::enable();
|
|
|
|
}
|
|
|
|
|
2017-04-25 22:50:19 +00:00
|
|
|
$container['view'] = ViewFactory::create($container);
|
2017-10-02 18:53:12 +00:00
|
|
|
|
|
|
|
if (!class_exists('Locale')) {
|
|
|
|
die('You need to install the intl extension for PHP.');
|
|
|
|
}
|
2019-04-22 15:00:51 +00:00
|
|
|
$container['locale'] = new LocaleManager();
|
2017-05-30 20:20:16 +00:00
|
|
|
$app->add(new LocaleMiddleware($container));
|
2016-03-29 23:39:47 +00:00
|
|
|
|
2019-04-22 15:00:51 +00:00
|
|
|
$frontController = new FrontController($container);
|
|
|
|
$jsonController = new JsonController($container);
|
|
|
|
$downloadController = new DownloadController($container);
|
2016-04-08 17:06:41 +00:00
|
|
|
|
2019-04-26 18:34:34 +00:00
|
|
|
$container['errorHandler'] = [$frontController, 'error'];
|
2016-04-30 23:25:08 +00:00
|
|
|
|
2015-10-29 20:23:02 +00:00
|
|
|
$app->get(
|
|
|
|
'/',
|
2019-04-22 14:05:58 +00:00
|
|
|
[$frontController, 'index']
|
2016-06-09 19:15:44 +00:00
|
|
|
)->setName('index');
|
2019-04-22 13:20:05 +00:00
|
|
|
|
2015-10-29 20:23:02 +00:00
|
|
|
$app->get(
|
|
|
|
'/extractors',
|
2019-04-22 14:05:58 +00:00
|
|
|
[$frontController, 'extractors']
|
2016-03-29 23:39:47 +00:00
|
|
|
)->setName('extractors');
|
2019-04-22 13:20:05 +00:00
|
|
|
|
2016-10-20 21:01:31 +00:00
|
|
|
$app->any(
|
2019-04-22 13:20:05 +00:00
|
|
|
'/info',
|
2019-04-22 14:05:58 +00:00
|
|
|
[$frontController, 'info']
|
2019-04-22 13:20:05 +00:00
|
|
|
)->setName('info');
|
|
|
|
// Legacy route.
|
2019-04-22 14:05:58 +00:00
|
|
|
$app->any('/video', [$frontController, 'info']);
|
2019-04-22 13:20:05 +00:00
|
|
|
|
2018-08-04 13:46:49 +00:00
|
|
|
$app->any(
|
|
|
|
'/watch',
|
2019-10-19 20:06:30 +00:00
|
|
|
[$frontController, 'info']
|
2018-08-04 13:46:49 +00:00
|
|
|
);
|
2019-04-22 13:20:05 +00:00
|
|
|
|
2019-04-22 14:05:58 +00:00
|
|
|
$app->any(
|
2019-04-22 13:20:05 +00:00
|
|
|
'/download',
|
2019-04-22 14:05:58 +00:00
|
|
|
[$downloadController, 'download']
|
2019-04-22 13:20:05 +00:00
|
|
|
)->setName('download');
|
|
|
|
// Legacy route.
|
2019-04-22 14:05:58 +00:00
|
|
|
$app->get('/redirect', [$downloadController, 'download']);
|
2019-04-22 13:20:05 +00:00
|
|
|
|
2017-05-30 20:20:16 +00:00
|
|
|
$app->get(
|
|
|
|
'/locale/{locale}',
|
2019-04-22 14:05:58 +00:00
|
|
|
[$frontController, 'locale']
|
2017-05-30 20:20:16 +00:00
|
|
|
)->setName('locale');
|
2017-10-02 19:07:13 +00:00
|
|
|
|
2019-04-22 14:05:58 +00:00
|
|
|
$app->get(
|
|
|
|
'/json',
|
|
|
|
[$jsonController, 'json']
|
|
|
|
)->setName('json');
|
|
|
|
|
2017-10-02 19:07:13 +00:00
|
|
|
try {
|
|
|
|
$app->run();
|
2018-02-05 15:48:58 +00:00
|
|
|
} catch (SmartyException $e) {
|
2019-10-03 19:24:12 +00:00
|
|
|
die('Smarty could not compile the template file: ' . $e->getMessage());
|
2017-10-02 19:07:13 +00:00
|
|
|
}
|