language(), $settings); if (!$user->hasPluginAccess($settings)) { http_response_code(403); echo 'Plugin is not enabled for this account.'; exit; } $secret = $settings->loadOrCreateSecret(); $csrf = new CsrfGuard($secret, $user->username(), (string)($_SERVER['SESSION_ID'] ?? getenv('SESSION_ID') ?: '')); $ctx = new AppContext($user, $settings, new RuleRepository(), $csrf, $lang, new AuditLog()); $action = basename((string)PLUGIN_ACTION); $handlerPath = PLUGIN_EXEC_DIR . '/handlers/' . $action . '.php'; if (!is_file($handlerPath)) { throw new RuntimeException('Missing handler: ' . $action); } $handler = require $handlerPath; if (!is_callable($handler)) { throw new RuntimeException('Invalid handler: ' . $action); } $handler($ctx); } catch (Throwable $e) { http_response_code(500); header('Content-Type: text/html; charset=UTF-8'); echo 'Błąd'; echo '

Błąd pluginu

' . htmlspecialchars($e->getMessage(), ENT_QUOTES | ENT_SUBSTITUTE, 'UTF-8') . '

'; echo ''; }