Simplification
This commit is contained in:
@@ -24,20 +24,14 @@ if (is_file($root . '/config.local.ini')) {
|
||||
$f3->config($root . '/config.local.ini');
|
||||
}
|
||||
|
||||
date_default_timezone_set(app_timezone((string) $f3->get('app.timezone')));
|
||||
$f3->set('TZ', date_default_timezone_get());
|
||||
$f3->set('TZ', app_timezone((string) $f3->get('app.timezone')));
|
||||
$f3->set('DEBUG', $f3->get('app.env') === 'prod' ? 0 : 3);
|
||||
|
||||
foreach ([(string) $f3->get('TEMP'), (string) $f3->get('LOGS'), dirname((string) $f3->get('paths.db')), (string) $f3->get('paths.media_dir')] as $dir) {
|
||||
if (!is_dir($dir)) {
|
||||
mkdir($dir, 0775, true);
|
||||
}
|
||||
}
|
||||
$uploadsDir = $root . '/' . trim((string) $f3->get('UPLOADS'), '/');
|
||||
$f3->set('UPLOADS', $uploadsDir . '/');
|
||||
|
||||
$uploads = $root . '/' . trim((string) $f3->get('UPLOADS'), '/');
|
||||
$f3->set('UPLOADS', $uploads . '/');
|
||||
if (!is_dir($uploads)) {
|
||||
mkdir($uploads, 0775, true);
|
||||
foreach ([(string) $f3->get('TEMP'), (string) $f3->get('LOGS'), dirname((string) $f3->get('paths.db')), (string) $f3->get('paths.media_dir'), $uploadsDir] as $dir) {
|
||||
app_ensure_dir($dir);
|
||||
}
|
||||
|
||||
ini_set('log_errors', '1');
|
||||
@@ -49,16 +43,15 @@ $db = new DB\SQL('sqlite:' . $f3->get('paths.db'));
|
||||
$db->exec('PRAGMA foreign_keys = ON');
|
||||
$f3->set('DB', $db);
|
||||
|
||||
$secure = app_request_is_secure();
|
||||
session_name((string) $f3->get('app.session_name'));
|
||||
$f3->set('JAR', [
|
||||
'expire' => 0,
|
||||
'path' => '/',
|
||||
'secure' => $secure,
|
||||
'secure' => app_request_is_secure(),
|
||||
'httponly' => true,
|
||||
'samesite' => 'Lax',
|
||||
]);
|
||||
new Session(null, 'CSRF');
|
||||
new Session();
|
||||
|
||||
Template::instance()->filter('date_fr', 'app_date_fr');
|
||||
|
||||
@@ -66,6 +59,7 @@ if ($f3->get('app.env') === 'prod') {
|
||||
$f3->set('ONERROR', function (Base $f3): void {
|
||||
$code = max(1, (int) ($f3->get('ERROR.code') ?: 500));
|
||||
$meta = app_error_meta($code);
|
||||
|
||||
$f3->status($code);
|
||||
$f3->expire(0);
|
||||
$f3->mset([
|
||||
@@ -73,6 +67,7 @@ if ($f3->get('app.env') === 'prod') {
|
||||
'errorTitle' => $meta['title'],
|
||||
'errorMessage' => $meta['message'],
|
||||
]);
|
||||
|
||||
echo Template::instance()->render('errors/error.html');
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user