diff options
Diffstat (limited to 'index.php')
-rw-r--r-- | index.php | 66 |
1 files changed, 29 insertions, 37 deletions
@@ -61,29 +61,31 @@ require_once 'application/FileUtils.php'; | |||
61 | require_once 'application/TimeZone.php'; | 61 | require_once 'application/TimeZone.php'; |
62 | require_once 'application/Utils.php'; | 62 | require_once 'application/Utils.php'; |
63 | 63 | ||
64 | use \Shaarli\ApplicationUtils; | 64 | use Shaarli\ApplicationUtils; |
65 | use Shaarli\Bookmark\BookmarkServiceInterface; | ||
66 | use \Shaarli\Bookmark\Exception\BookmarkNotFoundException; | ||
67 | use Shaarli\Bookmark\Bookmark; | 65 | use Shaarli\Bookmark\Bookmark; |
68 | use Shaarli\Bookmark\BookmarkFilter; | ||
69 | use Shaarli\Bookmark\BookmarkFileService; | 66 | use Shaarli\Bookmark\BookmarkFileService; |
70 | use \Shaarli\Config\ConfigManager; | 67 | use Shaarli\Bookmark\BookmarkFilter; |
71 | use \Shaarli\Feed\CachedPage; | 68 | use Shaarli\Bookmark\BookmarkServiceInterface; |
72 | use \Shaarli\Feed\FeedBuilder; | 69 | use Shaarli\Bookmark\Exception\BookmarkNotFoundException; |
70 | use Shaarli\Config\ConfigManager; | ||
71 | use Shaarli\Container\ContainerBuilder; | ||
72 | use Shaarli\Feed\CachedPage; | ||
73 | use Shaarli\Feed\FeedBuilder; | ||
73 | use Shaarli\Formatter\BookmarkMarkdownFormatter; | 74 | use Shaarli\Formatter\BookmarkMarkdownFormatter; |
74 | use Shaarli\Formatter\FormatterFactory; | 75 | use Shaarli\Formatter\FormatterFactory; |
75 | use \Shaarli\History; | 76 | use Shaarli\History; |
76 | use \Shaarli\Languages; | 77 | use Shaarli\Languages; |
77 | use \Shaarli\Netscape\NetscapeBookmarkUtils; | 78 | use Shaarli\Netscape\NetscapeBookmarkUtils; |
78 | use \Shaarli\Plugin\PluginManager; | 79 | use Shaarli\Plugin\PluginManager; |
79 | use \Shaarli\Render\PageBuilder; | 80 | use Shaarli\Render\PageBuilder; |
80 | use \Shaarli\Render\ThemeUtils; | 81 | use Shaarli\Render\ThemeUtils; |
81 | use \Shaarli\Router; | 82 | use Shaarli\Router; |
82 | use \Shaarli\Security\LoginManager; | 83 | use Shaarli\Security\LoginManager; |
83 | use \Shaarli\Security\SessionManager; | 84 | use Shaarli\Security\SessionManager; |
84 | use \Shaarli\Thumbnailer; | 85 | use Shaarli\Thumbnailer; |
85 | use \Shaarli\Updater\Updater; | 86 | use Shaarli\Updater\Updater; |
86 | use \Shaarli\Updater\UpdaterUtils; | 87 | use Shaarli\Updater\UpdaterUtils; |
88 | use Slim\App; | ||
87 | 89 | ||
88 | // Ensure the PHP version is supported | 90 | // Ensure the PHP version is supported |
89 | try { | 91 | try { |
@@ -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: |