From 1c9afba5f058adace5e005b51fc533882f9af0fa Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Sun, 14 Mar 2021 14:17:18 +0300 Subject: * add CSRF protection to xhr requests * force ORM to use SQLITE WAL * add .editorconfig * cleanup a few things --- classes/db.php | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'classes/db.php') diff --git a/classes/db.php b/classes/db.php index cc835b7..61467eb 100644 --- a/classes/db.php +++ b/classes/db.php @@ -7,14 +7,21 @@ class Db { try { $this->pdo = new PDO(self::get_dsn()); } catch (Exception $e) { - die("Unable to initialize database driver (SQLite): $e"); + user_error($e, E_USER_WARNING); + die("Unable to initialize database driver (SQLite)."); } //$this->dbh->busyTimeout(30*1000); $this->pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); - $this->pdo->query('PRAGMA journal_mode = wal;'); + $this->pdo->query('PRAGMA journal_mode = wal'); - ORM::configure(self::get_dsn()); - ORM::configure('return_result_sets', true); + try { + ORM::configure(self::get_dsn()); + ORM::configure('return_result_sets', true); + ORM::raw_execute('PRAGMA journal_mode = wal'); + } catch (Exception $e) { + user_error($e, E_USER_WARNING); + die("Unable to initialize ORM layer."); + } } public static function get_dsn() { -- cgit v1.2.3