feat: implement mail-login directadmin plugin

This commit is contained in:
Marek Miklewicz
2026-06-30 11:31:19 +02:00
parent f6506e3293
commit 77c5431db0
34 changed files with 1620 additions and 0 deletions
+48
View File
@@ -0,0 +1,48 @@
<?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',
'SourceAuthorizer.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);
}