From 9407c92a6adc7513030a2f8bbd7d3d3ff4ffefda Mon Sep 17 00:00:00 2001 From: Mark Schouten Date: Wed, 22 Aug 2018 16:51:07 +0200 Subject: [PATCH] Show a clear message instead of ERROR 500 --- includes/misc.inc.php | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/includes/misc.inc.php b/includes/misc.inc.php index 274b638..88cb2a1 100644 --- a/includes/misc.inc.php +++ b/includes/misc.inc.php @@ -59,13 +59,18 @@ if (function_exists('openssl_random_pseudo_bytes') === FALSE) { $defaults['defaulttype'] = ucfirst(strtolower($defaults['defaulttype'])); -if (isset($authdb) && !file_exists($authdb) && class_exists('SQLite3')) { - is_dir(dirname($authdb)) || mkdir(dirname($authdb)); - $db = new SQLite3($authdb, SQLITE3_OPEN_CREATE|SQLITE3_OPEN_READWRITE); - $createsql = file_get_contents('includes/scheme.sql'); - $db->exec($createsql); - $salt = bin2hex(openssl_random_pseudo_bytes(16)); - $db->exec("INSERT INTO users (emailaddress, password, isadmin) VALUES ('admin', '".crypt("admin", '$6$'.$salt)."', 1)"); +try { + if (isset($authdb) && !file_exists($authdb) && class_exists('SQLite3')) { + is_dir(dirname($authdb)) || mkdir(dirname($authdb)); + $db = new SQLite3($authdb, SQLITE3_OPEN_CREATE|SQLITE3_OPEN_READWRITE); + $createsql = file_get_contents('includes/scheme.sql'); + $db->exec($createsql); + $salt = bin2hex(openssl_random_pseudo_bytes(16)); + $db->exec("INSERT INTO users (emailaddress, password, isadmin) VALUES ('admin', '".crypt("admin", '$6$'.$salt)."', 1)"); + } +} catch (Exception $e) { + print("We have issues getting the authdb working: $e"); + $blocklogin = TRUE; } function string_starts_with($string, $prefix)