feat: implement mail-login directadmin plugin
This commit is contained in:
@@ -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);
|
||||
}
|
||||
Reference in New Issue
Block a user