$message, 'allow' => $allow, 'retry' => max(0, $retry), 'since' => time(), ], JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT)); } public static function deactivate(): void { @unlink(self::file()); } public static function active(): bool { return is_file(self::file()); } /** * Разрешён ли адресу проход мимо страницы «идут работы». */ public static function allows(string $ip): bool { $allow = trim((string) (self::payload()['allow'] ?? '')); return $allow !== '' && IpAllowlist::allows($allow, $ip); } /** * @return array{message: string, allow: string, retry: int, since: int} */ public static function payload(): array { if (!self::active()) { return ['message' => '', 'allow' => '', 'retry' => 0, 'since' => 0]; } $decoded = json_decode((string) file_get_contents(self::file()), true); return [ 'message' => (string) ($decoded['message'] ?? ''), 'allow' => (string) ($decoded['allow'] ?? ''), 'retry' => (int) ($decoded['retry'] ?? 0), 'since' => (int) ($decoded['since'] ?? 0), ]; } }