3 /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
6 * Galette's instanciation and routes
10 * Copyright © 2012-2014 The Galette Team
12 * This file is part of Galette (http://galette.tuxfamily.org).
14 * Galette is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU General Public License as published by
16 * the Free Software Foundation, either version 3 of the License, or
17 * (at your option) any later version.
19 * Galette is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
24 * You should have received a copy of the GNU General Public License
25 * along with Galette. If not, see <http://www.gnu.org/licenses/>.
30 * @author Johan Cwiklinski <johan@x-tnd.be>
31 * @copyright 2012-2014 The Galette Team
32 * @license http://www.gnu.org/licenses/gpl-3.0.html GPL License 3.0 or (at your option) any later version
33 * @link http://galette.tuxfamily.org
34 * @since 0.8.2dev 2014-11-10
39 use Galette\Core\Login
;
42 $time_start = microtime(true);
44 //define galette's root directory
45 if (!defined('GALETTE_ROOT')) {
46 define('GALETTE_ROOT', __DIR__
. '/../');
49 // define relative base path templating can use
50 if (!defined('GALETTE_BASE_PATH')) {
51 define('GALETTE_BASE_PATH', '../');
54 $needs_update = false;
56 require_once GALETTE_ROOT
. 'includes/galette.inc.php';
58 //Galette needs database update!
62 'templates.path' => GALETTE_ROOT
. 'templates/default/',
63 'mode' => 'NEED_UPDATE'
72 require_once GALETTE_ROOT
. 'includes/dependencies.php';
75 new \Galette\Middleware\
UpdateAndMaintenance(
77 \Galette\Middleware\UpdateAndMaintenance
::NEED_UPDATE
87 'determineRouteBeforeAppMiddleware' => true,
88 'displayErrorDetails' => (GALETTE_MODE
=== 'DEV'),
89 'addContentLengthHeader' => false,
93 'level' => \Monolog\Logger
::DEBUG
,
94 'path' => GALETTE_LOGS_PATH
. '/galette_slim.log',
96 //'routerCacheFile' => (GALETTE_MODE === 'DEV') ? false : GALETTE_CACHE_DIR . '/fastroute.cache' //disabled until properly handled
104 if (!defined('GALETTE_TIMEOUT')) {
105 //See https://php.net/manual/en/session.configuration.php#ini.session.cookie-lifetime
106 define('GALETTE_TIMEOUT', 0);
109 $plugins = new Galette\Core\
Plugins();
110 $plugins->autoload(GALETTE_PLUGINS_PATH
);
113 //since PREFIX_DB and NAME_DB are required to properly instanciate sessions,
114 // we have to check here if they're assigned
115 if ($installer ||
!defined('PREFIX_DB') ||
!defined('NAME_DB')) {
116 $session_name = 'install_' . str_replace('.', '_', GALETTE_VERSION
);
118 $session_name = PREFIX_DB
. '_' . NAME_DB
. '_' . str_replace('.', '_', GALETTE_VERSION
);
120 $session_name = 'galette_' . $session_name;
121 $session = new \RKA\
SessionMiddleware([
122 'name' => $session_name,
123 'lifetime' => GALETTE_TIMEOUT
128 // Set up dependencies
129 require GALETTE_ROOT
. '/includes/dependencies.php';
131 $smarty = $app->getContainer()->get('view')->getSmarty();
132 require_once GALETTE_ROOT
. 'includes/smarty.inc.php';
135 * Authentication middleware
137 $authenticate = new \Galette\Middleware\
Authenticate($container);
139 //Maintainance middleware
140 if ('MAINT' === GALETTE_MODE
&& !$container->get('login')->isSuperAdmin()) {
142 new \Galette\Middleware\
UpdateAndMaintenance(
144 \Galette\Middleware\UpdateAndMaintenance
::MAINTENANCE
150 * Trailing slash middleware
152 $app->add('\Galette\Middleware\TrailingSlash');
155 * Change language middleware
157 * Require determineRouteBeforeAppMiddleware to be on.
159 $app->add('\Galette\Middleware\Language');
161 //Telemetry update middleware
162 $app->add('\Galette\Middleware\Telemetry');
166 * This is important this one to be the last, so it'll be executed first.
168 $app->add('\Galette\Middleware\CheckAcls');
170 require_once GALETTE_ROOT
. 'includes/routes/main.routes.php';
171 require_once GALETTE_ROOT
. 'includes/routes/authentication.routes.php';
172 require_once GALETTE_ROOT
. 'includes/routes/management.routes.php';
173 require_once GALETTE_ROOT
. 'includes/routes/members.routes.php';
174 require_once GALETTE_ROOT
. 'includes/routes/groups.routes.php';
175 require_once GALETTE_ROOT
. 'includes/routes/contributions.routes.php';
176 require_once GALETTE_ROOT
. 'includes/routes/public_pages.routes.php';
177 require_once GALETTE_ROOT
. 'includes/routes/ajax.routes.php';
178 require_once GALETTE_ROOT
. 'includes/routes/plugins.routes.php';
182 if (isset($profiler)) {