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!
60 define('GALETTE_THEME', 'themes/default/');
61 $app = new \Galette\Core\
LightSlimApp();
63 $app = new \Galette\Core\
SlimApp();
66 //CONFIGURE AND START SESSION
69 if (!defined('GALETTE_TIMEOUT')) {
70 //See https://php.net/manual/en/session.configuration.php#ini.session.cookie-lifetime
71 define('GALETTE_TIMEOUT', 0);
75 //since PREFIX_DB and NAME_DB are required to properly instanciate sessions,
76 // we have to check here if they're assigned
77 if ($installer ||
!defined('PREFIX_DB') ||
!defined('NAME_DB')) {
78 $session_name = 'install_' . str_replace('.', '_', GALETTE_VERSION
);
80 $session_name = PREFIX_DB
. '_' . NAME_DB
. '_' . str_replace('.', '_', GALETTE_VERSION
);
82 $session_name = 'galette_' . $session_name;
83 $session = new \RKA\
SessionMiddleware([
84 'name' => $session_name,
85 'lifetime' => GALETTE_TIMEOUT
91 // Set up dependencies
92 require GALETTE_ROOT
. '/includes/dependencies.php';
96 new \Galette\Middleware\
UpdateAndMaintenance(
97 $container->get('i18n'),
98 \Galette\Middleware\UpdateAndMaintenance
::NEED_UPDATE
106 $smarty = $app->getContainer()->get('view')->getSmarty();
107 require_once GALETTE_ROOT
. 'includes/smarty.inc.php';
110 * Authentication middleware
112 $authenticate = new \Galette\Middleware\
Authenticate($container);
114 //Maintainance middleware
115 if ('MAINT' === GALETTE_MODE
&& !$container->get('login')->isSuperAdmin()) {
117 new \Galette\Middleware\
UpdateAndMaintenance(
119 \Galette\Middleware\UpdateAndMaintenance
::MAINTENANCE
125 * Trailing slash middleware
127 $app->add('\Galette\Middleware\TrailingSlash');
130 * Change language middleware
132 * Require determineRouteBeforeAppMiddleware to be on.
134 $app->add('\Galette\Middleware\Language');
136 //Telemetry update middleware
137 $app->add('\Galette\Middleware\Telemetry');
141 * This is important this one to be the last, so it'll be executed first.
143 $app->add('\Galette\Middleware\CheckAcls');
145 require_once GALETTE_ROOT
. 'includes/routes/main.routes.php';
146 require_once GALETTE_ROOT
. 'includes/routes/authentication.routes.php';
147 require_once GALETTE_ROOT
. 'includes/routes/management.routes.php';
148 require_once GALETTE_ROOT
. 'includes/routes/members.routes.php';
149 require_once GALETTE_ROOT
. 'includes/routes/groups.routes.php';
150 require_once GALETTE_ROOT
. 'includes/routes/contributions.routes.php';
151 require_once GALETTE_ROOT
. 'includes/routes/public_pages.routes.php';
152 require_once GALETTE_ROOT
. 'includes/routes/ajax.routes.php';
153 require_once GALETTE_ROOT
. 'includes/routes/plugins.routes.php';
157 if (isset($profiler)) {