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
+30
View File
@@ -0,0 +1,30 @@
<?php
declare(strict_types=1);
final class KeyName
{
public const MAX_LENGTH = 96;
public static function build(string $serverName, string $username, int $timestamp): string
{
$server = self::clean($serverName);
$user = self::clean($username);
$raw = 'autologin-' . $server . '-' . $user . '-' . $timestamp;
if (strlen($raw) <= self::MAX_LENGTH) {
return $raw;
}
$hash = substr(hash('sha256', $raw), 0, 10);
$suffix = '-' . $hash . '-' . $timestamp;
$bodyMax = self::MAX_LENGTH - strlen($suffix);
$body = rtrim(substr('autologin-' . $server . '-' . $user, 0, $bodyMax), '-');
return $body . $suffix;
}
private static function clean(string $value): string
{
$value = strtolower(trim($value));
$value = preg_replace('/[^a-z0-9-]+/', '-', $value) ?? '';
$value = trim($value, '-');
return $value !== '' ? $value : 'unknown';
}
}