| Server IP : 213.255.246.8 / Your IP : 216.73.217.0 Web Server : Apache System : Linux dublin.stapolin.com 5.14.0-362.18.1.el9_3.x86_64 #1 SMP PREEMPT_DYNAMIC Mon Jan 29 07:05:48 EST 2024 x86_64 User : stapolin ( 1019) PHP Version : 8.4.24 Disable Function : exec,passthru,shell_exec,system MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : ON Directory : /home/stapolin/public_html/tracking.stapolin.com/includes/ |
Upload File : |
<?php
declare(strict_types=1);
function validate_email_address(string $email): ?string
{
$email = trim($email);
return filter_var($email, FILTER_VALIDATE_EMAIL) ? $email : null;
}
function validate_url_value(string $url): ?string
{
$url = trim($url);
if (!filter_var($url, FILTER_VALIDATE_URL)) {
return null;
}
$scheme = parse_url($url, PHP_URL_SCHEME);
return in_array($scheme, ['http', 'https'], true) ? rtrim($url, '/') : null;
}
function normalise_domain(string $domain): ?string
{
$domain = strtolower(trim($domain));
$domain = preg_replace('/^https?:\/\//', '', $domain);
$domain = explode('/', $domain)[0];
$domain = preg_replace('/:\d+$/', '', $domain);
if ($domain === 'localhost') {
return $domain;
}
return preg_match('/^(?:[a-z0-9-]+\.)+[a-z]{2,}$/', $domain) ? $domain : null;
}
function domains_from_text(string $text): array
{
$domains = [];
foreach (preg_split('/[\r\n,]+/', $text) ?: [] as $candidate) {
$domain = normalise_domain($candidate);
if ($domain !== null) {
$domains[$domain] = $domain;
}
}
return array_values($domains);
}
function validate_timezone_name(string $timezone): string
{
return in_array($timezone, DateTimeZone::listIdentifiers(), true) ? $timezone : 'UTC';
}
function validate_currency_code(string $currency): string
{
$currency = strtoupper(trim($currency));
return preg_match('/^[A-Z]{3}$/', $currency) ? $currency : 'EUR';
}