aboutsummaryrefslogtreecommitdiffhomepage
path: root/index.php
diff options
context:
space:
mode:
Diffstat (limited to 'index.php')
-rw-r--r--index.php66
1 files changed, 29 insertions, 37 deletions
diff --git a/index.php b/index.php
index 76ad3696..7da8c22f 100644
--- a/index.php
+++ b/index.php
@@ -61,29 +61,31 @@ require_once 'application/FileUtils.php';
61require_once 'application/TimeZone.php'; 61require_once 'application/TimeZone.php';
62require_once 'application/Utils.php'; 62require_once 'application/Utils.php';
63 63
64use \Shaarli\ApplicationUtils; 64use Shaarli\ApplicationUtils;
65use Shaarli\Bookmark\BookmarkServiceInterface;
66use \Shaarli\Bookmark\Exception\BookmarkNotFoundException;
67use Shaarli\Bookmark\Bookmark; 65use Shaarli\Bookmark\Bookmark;
68use Shaarli\Bookmark\BookmarkFilter;
69use Shaarli\Bookmark\BookmarkFileService; 66use Shaarli\Bookmark\BookmarkFileService;
70use \Shaarli\Config\ConfigManager; 67use Shaarli\Bookmark\BookmarkFilter;
71use \Shaarli\Feed\CachedPage; 68use Shaarli\Bookmark\BookmarkServiceInterface;
72use \Shaarli\Feed\FeedBuilder; 69use Shaarli\Bookmark\Exception\BookmarkNotFoundException;
70use Shaarli\Config\ConfigManager;
71use Shaarli\Container\ContainerBuilder;
72use Shaarli\Feed\CachedPage;
73use Shaarli\Feed\FeedBuilder;
73use Shaarli\Formatter\BookmarkMarkdownFormatter; 74use Shaarli\Formatter\BookmarkMarkdownFormatter;
74use Shaarli\Formatter\FormatterFactory; 75use Shaarli\Formatter\FormatterFactory;
75use \Shaarli\History; 76use Shaarli\History;
76use \Shaarli\Languages; 77use Shaarli\Languages;
77use \Shaarli\Netscape\NetscapeBookmarkUtils; 78use Shaarli\Netscape\NetscapeBookmarkUtils;
78use \Shaarli\Plugin\PluginManager; 79use Shaarli\Plugin\PluginManager;
79use \Shaarli\Render\PageBuilder; 80use Shaarli\Render\PageBuilder;
80use \Shaarli\Render\ThemeUtils; 81use Shaarli\Render\ThemeUtils;
81use \Shaarli\Router; 82use Shaarli\Router;
82use \Shaarli\Security\LoginManager; 83use Shaarli\Security\LoginManager;
83use \Shaarli\Security\SessionManager; 84use Shaarli\Security\SessionManager;
84use \Shaarli\Thumbnailer; 85use Shaarli\Thumbnailer;
85use \Shaarli\Updater\Updater; 86use Shaarli\Updater\Updater;
86use \Shaarli\Updater\UpdaterUtils; 87use Shaarli\Updater\UpdaterUtils;
88use Slim\App;
87 89
88// Ensure the PHP version is supported 90// Ensure the PHP version is supported
89try { 91try {
@@ -594,19 +596,7 @@ function renderPage($conf, $pluginManager, $bookmarkService, $history, $sessionM
594 596
595 // -------- Display login form. 597 // -------- Display login form.
596 if ($targetPage == Router::$PAGE_LOGIN) { 598 if ($targetPage == Router::$PAGE_LOGIN) {
597 if ($conf->get('security.open_shaarli')) { 599 header('Location: ./login');
598 header('Location: ?');
599 exit;
600 } // No need to login for open Shaarli
601 if (isset($_GET['username'])) {
602 $PAGE->assign('username', escape($_GET['username']));
603 }
604 $PAGE->assign('returnurl', (isset($_SERVER['HTTP_REFERER']) ? escape($_SERVER['HTTP_REFERER']):''));
605 // add default state of the 'remember me' checkbox
606 $PAGE->assign('remember_user_default', $conf->get('privacy.remember_user_default'));
607 $PAGE->assign('user_can_login', $loginManager->canLogin($_SERVER));
608 $PAGE->assign('pagetitle', t('Login') .' - '. $conf->get('general.title', 'Shaarli'));
609 $PAGE->renderPage('loginform');
610 exit; 600 exit;
611 } 601 }
612 // -------- User wants to logout. 602 // -------- User wants to logout.
@@ -1930,11 +1920,9 @@ if (isset($_SERVER['QUERY_STRING']) && startsWith($_SERVER['QUERY_STRING'], 'do=
1930 exit; 1920 exit;
1931} 1921}
1932 1922
1933$container = new \Slim\Container(); 1923$containerBuilder = new ContainerBuilder($conf, $sessionManager, $loginManager);
1934$container['conf'] = $conf; 1924$container = $containerBuilder->build();
1935$container['plugins'] = $pluginManager; 1925$app = new App($container);
1936$container['history'] = $history;
1937$app = new \Slim\App($container);
1938 1926
1939// REST API routes 1927// REST API routes
1940$app->group('/api/v1', function () { 1928$app->group('/api/v1', function () {
@@ -1953,6 +1941,10 @@ $app->group('/api/v1', function () {
1953 $this->get('/history', '\Shaarli\Api\Controllers\HistoryController:getHistory')->setName('getHistory'); 1941 $this->get('/history', '\Shaarli\Api\Controllers\HistoryController:getHistory')->setName('getHistory');
1954})->add('\Shaarli\Api\ApiMiddleware'); 1942})->add('\Shaarli\Api\ApiMiddleware');
1955 1943
1944$app->group('', function () {
1945 $this->get('/login', '\Shaarli\Front\Controller\LoginController:index')->setName('login');
1946})->add('\Shaarli\Front\ShaarliMiddleware');
1947
1956$response = $app->run(true); 1948$response = $app->run(true);
1957 1949
1958// Hack to make Slim and Shaarli router work together: 1950// Hack to make Slim and Shaarli router work together: