diff --git a/.htaccess b/.htaccess index 4c9a599..a2cbcaf 100644 --- a/.htaccess +++ b/.htaccess @@ -1,6 +1,8 @@ Options -Indexes -RewriteEngine On -RewriteRule ^(app|bin|bootstrap|resources|storage|vendor|logs)(/.*|)$ - [NC,F] -RewriteCond %{REQUEST_FILENAME} !-f -RewriteCond %{REQUEST_FILENAME} !-d -RewriteRule ^(.*)$ index.php [QSA,L] \ No newline at end of file + + RewriteEngine On + RewriteRule ^(app|bin|bootstrap|resources|storage|vendor|logs)(/.*|)$ - [NC,F] + RewriteCond %{REQUEST_FILENAME} !-f + RewriteCond %{REQUEST_FILENAME} !-d + RewriteRule ^(.*)$ index.php [QSA,L] + \ No newline at end of file diff --git a/app/Controllers/DashboardController.php b/app/Controllers/DashboardController.php index 661cc40..8c621a0 100644 --- a/app/Controllers/DashboardController.php +++ b/app/Controllers/DashboardController.php @@ -128,6 +128,11 @@ class DashboardController extends Controller public function applyTheme(Request $request, Response $response): Response { + if (!is_writable('static/bootstrap/css/bootstrap.min.css')) { + Session::alert(lang('cannot_write_file'), 'danger'); + return redirect($response, route('system')); + } + file_put_contents('static/bootstrap/css/bootstrap.min.css', file_get_contents($request->getParam('css'))); return redirect($response, 'system') ->withAddedHeader('Cache-Control', 'no-cache, no-store, must-revalidate') diff --git a/install/index.php b/install/index.php index 00e6368..425bf08 100644 --- a/install/index.php +++ b/install/index.php @@ -131,8 +131,16 @@ $app->post('/', function (Request $request, Response $response) use (&$config) { $config['db']['username'] = $request->getParam('db_user'); $config['db']['password'] = $request->getParam('db_password'); + if (!is_writable($config['storage_dir'])) { + Session::alert('The storage folder is not writable (' . $config['storage_dir'] . ')', 'danger'); + return redirect($response, '.'); + } - file_put_contents(__DIR__ . '/../config.php', 'post('/', function (Request $request, Response $response) use (&$config) { migrate($config); } catch (PDOException $exception) { - + Session::alert("Cannot connect to the database: {$exception->getMessage()} [{$exception->getCode()}]", 'danger'); + return redirect($response, '.'); } if (!$installed) { diff --git a/install/templates/install.twig b/install/templates/install.twig index 2f23916..a791675 100644 --- a/install/templates/install.twig +++ b/install/templates/install.twig @@ -19,6 +19,14 @@
+ {% for type, message in alerts %} + + {% endfor %}
diff --git a/resources/lang/en.lang.php b/resources/lang/en.lang.php index b49fc1c..13b5d45 100644 --- a/resources/lang/en.lang.php +++ b/resources/lang/en.lang.php @@ -84,4 +84,5 @@ return [ 'user_deleted' => 'User deleted.', 'cannot_delete' => 'You cannot delete yourself.', 'cannot_demote' => 'You cannot demote yourself.', + 'cannot_write_file' => 'The destination path is not writable.', ]; \ No newline at end of file diff --git a/resources/lang/it.lang.php b/resources/lang/it.lang.php index 91c1ce0..9a0a0ef 100644 --- a/resources/lang/it.lang.php +++ b/resources/lang/it.lang.php @@ -84,4 +84,5 @@ return [ 'user_deleted' => 'Utente rimosso.', 'cannot_delete' => 'Non puoi eliminare te stesso.', 'cannot_demote' => 'Non puoi degradare te stesso. ', + 'cannot_write_file' => 'Il percorso di destinazione non รจ scrivibile.', ]; \ No newline at end of file