63 lines
1.5 KiB
PHP
63 lines
1.5 KiB
PHP
<?php
|
|
|
|
if (! function_exists('settings')) {
|
|
function settings(string $key, $default = null) {
|
|
return app(\App\Support\SettingsRepository::class)->get($key, $default);
|
|
}
|
|
}
|
|
|
|
if (!function_exists('domain_host')) {
|
|
function domain_host(string $sub = null): string
|
|
{
|
|
$base = env('BASE_DOMAIN', 'example.com');
|
|
return $sub ? "{$sub}.{$base}" : $base;
|
|
}
|
|
}
|
|
|
|
if (!function_exists('ui_host')) {
|
|
function ui_host(): string
|
|
{
|
|
return domain_host(env('UI_SUB', 'ui'));
|
|
}
|
|
}
|
|
|
|
if (!function_exists('webmail_host')) {
|
|
function webmail_host(): string
|
|
{
|
|
return domain_host(env('WEBMAIL_SUB', 'webmail'));
|
|
}
|
|
}
|
|
|
|
if (!function_exists('mta_host')) {
|
|
function mta_host(?int $domainId = null): string
|
|
{
|
|
if ($domainId) {
|
|
try {
|
|
$domain = \App\Models\Domain::find($domainId);
|
|
if ($domain && !empty($domain->mta_host)) {
|
|
return $domain->mta_host;
|
|
}
|
|
} catch (\Throwable $e) {
|
|
// DB evtl. noch nicht migriert — fallback auf env
|
|
}
|
|
}
|
|
|
|
$sub = env('MTA_SUB');
|
|
if ($sub) {
|
|
return domain_host($sub);
|
|
}
|
|
return domain_host('mx');
|
|
}
|
|
}
|
|
|
|
if (! function_exists('countryFlag')) {
|
|
function countryFlag(string $code): string
|
|
{
|
|
$code = strtoupper($code);
|
|
return implode('', array_map(
|
|
fn($char) => mb_chr(ord($char) + 127397, 'UTF-8'),
|
|
str_split($code)
|
|
));
|
|
}
|
|
}
|