diff --git a/.idea/dataSources.xml b/.idea/dataSources.xml index 701773f..cfd0235 100644 --- a/.idea/dataSources.xml +++ b/.idea/dataSources.xml @@ -1,7 +1,7 @@ - + mysql.8 true com.mysql.cj.jdbc.Driver diff --git a/lib/bootstrap.php b/lib/bootstrap.php index e34323c..05c6937 100644 --- a/lib/bootstrap.php +++ b/lib/bootstrap.php @@ -1,4 +1,5 @@ prepare( - 'SELECT r.name FROM userRoles ur JOIN roles r ON r.roleID = ur.roleID WHERE ur.userID = ?' - ); - if ($__bsStmt) { + $__bsStmt = $__bsConn->prepare('SELECT r.name FROM userRoles ur JOIN roles r ON r.roleID = ur.roleID WHERE ur.userID = ?'); + + if ($__bsStmt) + { $__bsUid = (int)$_SESSION['user_id']; $__bsStmt->bind_param('i', $__bsUid); $__bsStmt->execute(); $__bsResult = $__bsStmt->get_result(); $_SESSION['user_roles'] = []; - while ($__bsRow = $__bsResult->fetch_assoc()) { + + while ($__bsRow = $__bsResult->fetch_assoc()) + { $_SESSION['user_roles'][] = $__bsRow['name']; } + $__bsStmt->close(); } + $__bsConn->close(); -} else { +} +else +{ $_SESSION['user_roles'] = []; } +?> + diff --git a/lib/config.php b/lib/config.php index 776b061..3f57003 100644 --- a/lib/config.php +++ b/lib/config.php @@ -1,6 +1,5 @@ keine automatische Typenumwandlung /** * Liefert eine MySQLi-Verbindung anhand der zentralen Konfiguration. @@ -11,7 +11,9 @@ declare(strict_types=1); function db_connect(): mysqli { static $cfg; - if ($cfg === null) { + + if ($cfg === null) + { /** @var array{db: array{host:string,port:int,user:string,pass:string,name:string,charset:string}} $cfg */ $cfg = require __DIR__ . '/config.php'; } @@ -19,7 +21,9 @@ function db_connect(): mysqli $db = $cfg['db']; $conn = new mysqli($db['host'], $db['user'], $db['pass'], $db['name'], $db['port']); - if ($conn->connect_error) { + + if ($conn->connect_error) + { http_response_code(500); die('Datenbankfehler'); } @@ -30,3 +34,4 @@ function db_connect(): mysqli return $conn; } +?> diff --git a/lib/strings.php b/lib/strings.php index c81e35a..444bc81 100644 --- a/lib/strings.php +++ b/lib/strings.php @@ -1,4 +1,5 @@