fix: fix boolean return type in totp.php, handle multi-statement sql and enable error reporting
This commit is contained in:
@@ -80,3 +80,10 @@ define('APP_ENV', fociz_env('APP_ENV', 'development')); // 'development' of 'liv
|
||||
|
||||
// Tijdzone
|
||||
date_default_timezone_set('Europe/Amsterdam');
|
||||
|
||||
// Foutrapportage: in development tonen we fouten direct op het scherm
|
||||
if (APP_ENV !== 'live') {
|
||||
ini_set('display_errors', '1');
|
||||
ini_set('display_startup_errors', '1');
|
||||
error_reporting(E_ALL);
|
||||
}
|
||||
|
||||
+12
-3
@@ -53,6 +53,9 @@ function get_db_connection(): PDO {
|
||||
PDO::ATTR_EMULATE_PREPARES => false,
|
||||
PDO::ATTR_TIMEOUT => 5,
|
||||
];
|
||||
if (defined('PDO::MYSQL_ATTR_MULTI_STATEMENTS')) {
|
||||
$options[PDO::MYSQL_ATTR_MULTI_STATEMENTS] = true;
|
||||
}
|
||||
|
||||
try {
|
||||
$pdo = new PDO($dsn, DB_USER, DB_PASS, $options);
|
||||
@@ -100,10 +103,16 @@ function ensure_tables_exist(PDO $pdo): void {
|
||||
$schemaFile = __DIR__ . '/../schema.sql';
|
||||
if (file_exists($schemaFile)) {
|
||||
$sql = file_get_contents($schemaFile);
|
||||
$pdo->exec($sql);
|
||||
// Splits op puntkomma om elk CREATE TABLE statement apart uit te voeren
|
||||
$statements = array_filter(array_map('trim', explode(';', $sql)));
|
||||
foreach ($statements as $stmt) {
|
||||
if (!empty($stmt)) {
|
||||
$pdo->exec($stmt);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (PDOException $e) {
|
||||
// Tabellen bestaan waarschijnlijk al
|
||||
} catch (Exception $e) {
|
||||
error_log("Fout bij uitvoeren schema.sql: " . $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user