alltube/index.php

52 lines
1.3 KiB
PHP
Raw Normal View History

2016-08-01 16:04:44 +00:00
<?php
2016-09-07 22:28:28 +00:00
2015-10-31 14:42:25 +00:00
require_once __DIR__.'/vendor/autoload.php';
use Alltube\Config;
2017-01-10 22:39:58 +00:00
use Alltube\Controller\FrontController;
use Alltube\UglyRouter;
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) {
2016-07-27 00:19:29 +00:00
header('Location: '.str_ireplace('/index.php', '/', $_SERVER['REQUEST_URI']));
die;
}
2016-03-29 23:39:47 +00:00
$app = new \Slim\App();
$container = $app->getContainer();
$config = Config::getInstance();
if ($config->uglyUrls) {
$container['router'] = new UglyRouter();
}
2016-03-29 23:39:47 +00:00
$container['view'] = function ($c) {
$view = new \Slim\Views\Smarty(__DIR__.'/templates/');
2016-10-10 19:34:38 +00:00
$smartyPlugins = new \Slim\Views\SmartyPlugins($c['router'], $c['request']->getUri());
$view->registerPlugin('function', 'path_for', [$smartyPlugins, 'pathFor']);
$view->registerPlugin('function', 'base_url', [$smartyPlugins, 'baseUrl']);
2016-04-08 17:06:41 +00:00
$view->registerPlugin('modifier', 'noscheme', 'Smarty_Modifier_noscheme');
2016-04-06 11:19:27 +00:00
2016-03-29 23:39:47 +00:00
return $view;
};
2016-07-22 12:43:50 +00:00
$controller = new FrontController($container);
2016-04-08 17:06:41 +00:00
2016-09-07 22:28:28 +00:00
$container['errorHandler'] = [$controller, 'error'];
2016-04-30 23:25:08 +00:00
2015-10-29 20:23:02 +00:00
$app->get(
'/',
2016-09-07 22:28:28 +00:00
[$controller, 'index']
2016-06-09 19:15:44 +00:00
)->setName('index');
2015-10-29 20:23:02 +00:00
$app->get(
'/extractors',
2016-09-07 22:28:28 +00:00
[$controller, 'extractors']
2016-03-29 23:39:47 +00:00
)->setName('extractors');
$app->any(
2015-10-29 20:23:02 +00:00
'/video',
2016-09-07 22:28:28 +00:00
[$controller, 'video']
2016-03-29 23:39:47 +00:00
)->setName('video');
2015-10-31 10:48:14 +00:00
$app->get(
'/redirect',
2016-09-07 22:28:28 +00:00
[$controller, 'redirect']
2016-04-10 19:42:38 +00:00
)->setName('redirect');
2015-10-29 20:19:40 +00:00
$app->run();