hasPluginAccess()) { http_response_code(403); $langCode = $daUser->language(); $lang = Lang::load($daUser->language()); render_access_denied_message($lang, $daUser->skin(), $langCode); exit; } $credentials = Settings::loadPostgresqlCredentials('/usr/local/directadmin/conf/postgresql.conf'); $pg = new PostgresService($credentials, $settings); $pg->ensureMetadataSchema(); $secret = $settings->loadOrCreateSecret(PLUGIN_ROOT . '/data/secret.key'); $csrf = new CsrfGuard($secret, $daUser->username(), Http::server('SESSION_ID')); $lang = Lang::load($daUser->language()); $ctx = new AppContext($daUser, $settings, $pg, $csrf, $lang); $handlerFile = PLUGIN_HANDLERS_DIR . '/' . basename((string)PLUGIN_ACTION) . '.php'; if (!is_file($handlerFile)) { throw new RuntimeException('Brak handlera dla akcji: ' . (string)PLUGIN_ACTION); } $handler = require $handlerFile; if (!is_callable($handler)) { throw new RuntimeException('Handler akcji nie jest wywoływalny: ' . (string)PLUGIN_ACTION); } $handler($ctx); exit; } catch (Throwable $e) { $msg = sprintf( "[%s] EXCEPTION class=%s message=%s file=%s line=%d action=%s\n", date('c'), get_class($e), $e->getMessage(), $e->getFile(), $e->getLine(), defined('PLUGIN_ACTION') ? (string)PLUGIN_ACTION : 'unknown' ); @error_log($msg, 3, $pluginErrorLog); @error_log("[stacktrace]\n" . $e->getTraceAsString() . "\n", 3, $pluginErrorLog); http_response_code(500); header('Content-Type: text/html; charset=UTF-8'); echo '
' . htmlspecialchars($e->getMessage(), ENT_QUOTES | ENT_SUBSTITUTE, 'UTF-8') . '
'; echo 'Sprawdź konfigurację i uprawnienia pluginu.
'; echo ''; exit; } function autoload_plugin_libs(): void { $files = [ PLUGIN_EXEC_DIR . '/lib/Http.php', PLUGIN_EXEC_DIR . '/lib/Settings.php', PLUGIN_EXEC_DIR . '/lib/AdminerRuntimeConfig.php', PLUGIN_EXEC_DIR . '/lib/DirectAdminUser.php', PLUGIN_EXEC_DIR . '/lib/Lang.php', PLUGIN_EXEC_DIR . '/lib/LocalizedException.php', PLUGIN_EXEC_DIR . '/lib/CsrfGuard.php', PLUGIN_EXEC_DIR . '/lib/NamePolicy.php', PLUGIN_EXEC_DIR . '/lib/PostgresService.php', PLUGIN_EXEC_DIR . '/lib/AdminerSso.php', PLUGIN_EXEC_DIR . '/lib/BackupQueueService.php', PLUGIN_EXEC_DIR . '/lib/FilePicker.php', PLUGIN_EXEC_DIR . '/lib/AppContext.php', ]; foreach ($files as $file) { require_once $file; } } function render_access_denied_message(Lang $lang, string $skin, string $langCode): void { $path = PLUGIN_ROOT . '/user/' . strtolower(trim($skin)) . '.css'; if (!is_file($path)) { $path = PLUGIN_ROOT . '/user/enhanced.css'; } $css = is_file($path) ? (string)file_get_contents($path) : ''; $message = $lang->t('Bazy danych PostgreSQL nie są dostępne dla Twojego konta - skontaktuj się z pomocą techniczną aby uzyskać pomoc i więcej informacji'); $title = $lang->t('Błąd'); header('Content-Type: text/html; charset=UTF-8'); echo ''; echo ''; echo '