48 lines
1.2 KiB
PHP
48 lines
1.2 KiB
PHP
<?php
|
|
declare(strict_types=1);
|
|
|
|
if (!defined('IN_DA_PLUGIN') || IN_DA_PLUGIN !== true) {
|
|
http_response_code(403);
|
|
echo 'Forbidden';
|
|
exit;
|
|
}
|
|
|
|
define('PLUGIN_ROOT', dirname(__DIR__));
|
|
define('PLUGIN_EXEC_DIR', __DIR__);
|
|
|
|
foreach ([
|
|
'Settings.php',
|
|
'Http.php',
|
|
'AuditLog.php',
|
|
'ClientIp.php',
|
|
'DirectAdminContext.php',
|
|
'KeyName.php',
|
|
'RateLimiter.php',
|
|
'RemoteLoginUrlClient.php',
|
|
'UrlValidator.php',
|
|
] as $file) {
|
|
require_once PLUGIN_EXEC_DIR . '/lib/' . $file;
|
|
}
|
|
|
|
try {
|
|
Http::bootstrapGlobals();
|
|
$action = basename((string)PLUGIN_ACTION);
|
|
$handlerPath = PLUGIN_EXEC_DIR . '/handlers/' . $action . '.php';
|
|
if (!is_file($handlerPath)) {
|
|
throw new RuntimeException('Missing handler');
|
|
}
|
|
$handler = require $handlerPath;
|
|
if (!is_callable($handler)) {
|
|
throw new RuntimeException('Invalid handler');
|
|
}
|
|
$handler();
|
|
} catch (Throwable $e) {
|
|
AuditLog::safeAppend(Settings::AUDIT_LOG, [
|
|
'event' => 'plugin_error',
|
|
'result' => 'failure',
|
|
'category' => get_class($e),
|
|
'message' => $e->getMessage(),
|
|
]);
|
|
Http::errorPage('Nie można teraz zalogować do serwera poczty.', 500);
|
|
}
|