This commit is contained in:
2026-09-10 15:10:59 +02:00
parent 9016fb7baf
commit b8f9430827
8 changed files with 1339 additions and 8 deletions
+2
View File
@@ -1,5 +1,7 @@
<?php
session_start();
require_once $_SERVER['DOCUMENT_ROOT'] . '/vendor/autoload.php';
$dotenv = Dotenv\Dotenv::createImmutable($_SERVER['DOCUMENT_ROOT']); // dir containing .env
$dotenv->load();
+7 -2
View File
@@ -1,8 +1,13 @@
<?php
function hasPermission(int $userId, string $resourceName, string $actionName): bool
function hasPermission(string $resourceName, string $actionName): bool
{
global $conn;
if(!isset($_SESSION['id'])){
return false;
}
$sql = "
SELECT COUNT(*) AS permission_count
FROM users u
@@ -16,7 +21,7 @@ function hasPermission(int $userId, string $resourceName, string $actionName): b
$stmt = $conn->prepare($sql);
$stmt->execute([
':userId' => $userId,
':userId' => $_SESSION['id'],
':resourceName' => $resourceName,
':actionName' => $actionName,
]);