Files
preland/components/theme-preference.php

17 lines
622 B
PHP

<?php
/** preland#13: только оформление; не меняет рекламный набор и не подключает Yii. */
function prelandThemePreference(): ?array
{
$value = $_COOKIE['theme_choice'] ?? null;
if (!is_string($value) || strlen($value) > 128
|| !preg_match('/\Av1:(light|dark):(manual|preland):([A-Za-z0-9_-]{16,64})\z/', $value, $match)) {
return null;
}
return ['theme' => $match[1], 'source' => $match[2], 'revision' => $match[3]];
}
function prelandThemeResolve(string $fallback): string
{
return prelandThemePreference()['theme'] ?? $fallback;
}