?php use App\Http\Controllers\GoController; use App\Support\Env; use App\Support\Str; use App\Support\Site; use App\Support\ThemeDir; use App\Support\Url; /** @var array $settings */ /** @var string $pageTitle */ /** @var string|null $pageDescription */ /** @var string|null $pageKeywords */ /** @var string $contentView */ /** @var array $contentData */ /** @var array|null $pageJsonLd */ /** @var array|null $pageHeadLinks */ /** @var string|null $pageOgType */ /** @var string|null $pageOgImage */ /** @var string|null $pageOgImageAlt */ /** @var string|null $pageOgPublished */ /** @var string|null $pageOgModified */ /** @var string|null $pageRobots */ $homeLayoutSkin = strtolower(trim((string)(Env::get('HOME_LAYOUT', '') ?? ''))); $arcLedger = trim((string)(Env::get('ARC_LEDGER_THEME', '') ?? '')) === '1'; $kaiyunSiteLayout = ($homeLayoutSkin === 'kaiyun'); $prismSiteLayout = ($homeLayoutSkin === 'prism'); $siteName = (string)($settings['site_name'] ?? '体育资讯站'); $brandWord = trim((string)($settings['brand_word'] ?? '')); $brandTitle = $brandWord !== '' ? $brandWord : $siteName; $title = (string)($pageTitle ?? $brandTitle); if (trim($title) === '') { $title = $siteName; } $isAppLandingPage = isset($contentView) && is_string($contentView) && str_starts_with($contentView, 'app-content'); if ($isAppLandingPage) { $metaDesc = trim(strip_tags((string)($pageDescription ?? Site::tdkDescription($settings)))); if ($metaDesc === '') { $metaDesc = Str::truncateUtf8(trim($title . '|' . $siteName), 160, ''); } if ($metaDesc === '') { $metaDesc = $brandTitle . Site::t(' — 体育资讯、赛程比分与赛况热点。'); } } else { $metaDesc = trim(strip_tags((string)($pageDescription ?? Site::tdkDescription($settings)))); } /** 页脚两行:第一行 $brandTitle,第二行 $footerDesc(与 TDK 同源 site_description,不含各页 $pageDescription) */ $footerDesc = Site::tdkDescription($settings); $kw = trim((string)($pageKeywords ?? Site::tdkKeywords($settings))); $kwParts = preg_split('/[,\s,]+/u', (string)$kw) ?: []; $kwParts = array_values(array_filter(array_map('trim', $kwParts), static fn($s) => $s !== '')); $hostForSeed = Site::visualHostSeedString(); $seedHostForKw = ($hostForSeed !== '' && $hostForSeed !== 'default-host') ? $hostForSeed : (string) $brandTitle; $randomKw = (string)(Str::stableElement($kwParts, $seedHostForKw . ':layout-random-kw') ?? ''); if ($randomKw === '') { $randomKw = $brandWord !== '' ? $brandWord : $siteName; } // 顶栏副标题:左右为词库;中间括号为 TDK「关键词」拆词后按主机名稳定抽取的其中一条(非整段) $brandSubSeed = $seedHostForKw !== '' ? $seedHostForKw : (string)$brandTitle; $brandSubLeftPool = [ '全天更新', '即时推送', '热门聚合', '深度索引', '多维覆盖', '一手速递', '精选聚焦', '高清同步', '低延迟追踪', '全链路', ]; $brandSubRightPool = [ '赛事实况', '数据随查', '资讯直达', '多维播报', '热点追踪', '赛程一览', '临场速递', '指数参考', '回放可溯', '终端同屏', ]; $brandSubLeft = (string)(Str::stableElement($brandSubLeftPool, $brandSubSeed . ':brand-sub-L') ?? '精选聚焦'); $brandSubRight = (string)(Str::stableElement($brandSubRightPool, $brandSubSeed . ':brand-sub-R') ?? '赛事实况'); $brandSubLine = $brandSubLeft . '·' . $randomKw . ' ' . $brandSubRight; $hostRaw = ($hostForSeed !== 'default-host') ? $hostForSeed : ''; $hostRaw = preg_replace('/[^a-z0-9\.\-]+/i', '', $hostRaw) ?? ''; $hostForEmail = preg_replace('/[^a-z0-9\.\-]+/i', '', $hostRaw) ?? ''; if ($hostForEmail === '') { $hostForEmail = 'example.com'; } $mailPrefixes = ['hello', 'contact', 'support', 'service', 'hi']; $mailSeed = abs((int)crc32($hostForEmail)); $mailPrefix = (string)$mailPrefixes[$mailSeed % count($mailPrefixes)]; $email = $mailPrefix . '@' . $hostForEmail; $address = trim((string)($settings['site_address'] ?? '')); if ($address === '') { $officeCities = ['香港中环', '新加坡滨海湾', '上海浦东新区', '深圳南山区', '广州市天河区', '北京市朝阳区']; $officeStreets = ['体育路 88 号', '海景大道 19 号', '信息港路 66 号', '创新大道 28 号', '数据中心路 101 号']; $addrSeed = abs((int)crc32($hostForEmail . ':address')); $city = (string)$officeCities[$addrSeed % count($officeCities)]; $street = (string)$officeStreets[(int)(floor($addrSeed / max(1, count($officeCities)))) % count($officeStreets)]; $address = $city . ' ' . $street; } $logoUrl = null; $logoBaseDir = __DIR__ . '/../../../public/assets/brand-logos'; $logoBaseUrl = '/assets/brand-logos'; $logoKeyRaw = $brandWord !== '' ? $brandWord : $brandTitle; $logoKeySlug = strtolower(trim((string)preg_replace('/[^a-z0-9]+/i', '-', $logoKeyRaw), '-')); $logoCandidates = []; if ($logoKeyRaw !== '') { $logoCandidates[] = $logoKeyRaw; } if ($logoKeySlug !== '') { $logoCandidates[] = $logoKeySlug; } $logoCandidates[] = md5($logoKeyRaw); $logoCandidates = array_values(array_unique(array_filter($logoCandidates, static fn($v) => trim((string)$v) !== ''))); /** kaiyun 顶栏:优先 ASCII 文件名,避免部分环境中文路径/URL 无法命中 */ if ($kaiyunSiteLayout) { $logoCandidates = array_values(array_unique(array_merge( ['kaiyun-wordmark', 'kaiyun-brand'], $logoCandidates ))); } $logoExts = ['svg', 'png', 'webp', 'jpg', 'jpeg']; foreach ($logoCandidates as $name) { foreach ($logoExts as $ext) { $file = $logoBaseDir . '/' . $name . '.' . $ext; if (is_file($file)) { $logoUrl = $logoBaseUrl . '/' . rawurlencode($name) . '.' . $ext; break 2; } } } $logoTextSource = $brandWord !== '' ? $brandWord : $siteName; $logoTextSource = trim((string)$logoTextSource); $logoText = $logoTextSource; if (function_exists('mb_substr')) { $logoText = (string)mb_substr($logoTextSource, 0, 2, 'UTF-8'); } else { $logoText = (string)substr($logoTextSource, 0, 2); } $logoText = trim($logoText); if ($logoText === '') { $logoText = 'SP'; } /** arc 顶栏:单字标 + 与主题一致的暗底弧光配色(与默认两字母、旧色板区分);prism 保留双字标 */ if (($homeLayoutSkin === 'arc' || $arcLedger) && !$prismSiteLayout && !$kaiyunSiteLayout) { if ($logoTextSource !== '') { $logoText = function_exists('mb_substr') ? (string) mb_substr($logoTextSource, 0, 1, 'UTF-8') : (string) substr($logoTextSource, 0, 1); } else { $logoText = function_exists('mb_substr') ? (string) mb_substr($logoText, 0, 1, 'UTF-8') : (string) substr($logoText, 0, 1); } $logoText = trim($logoText); if ($logoText === '') { $logoText = 'S'; } } $logoHueSeed = abs((int)crc32($logoTextSource !== '' ? $logoTextSource : $brandTitle)); $logoPalDefault = [ ['#0d9488', '#2dd4bf', '#2563eb'], ['#2563eb', '#4f46e5', '#7c3aed'], ['#7c3aed', '#a78bfa', '#0d9488'], ['#e11d48', '#fb7185', '#f59e0b'], ['#0891b2', '#22d3ee', '#2563eb'], ]; /** c1 深色底、c2/c3 为品牌蓝 / 金 / 紫(与 layout-arc / arc-theme 变量一致) */ $logoPalArc = [ ['#0b1220', '#417fff', '#ffc107'], ['#0f172a', '#5b9fff', '#a78bfa'], ['#1e1b4b', '#c4b5fd', '#f59e0b'], ['#0c1929', '#38bdf8', '#818cf8'], ['#172554', '#60a5fa', '#fbbf24'], ]; /** prism 整站:深绿底 + 琥珀强调 + 青绿辅色(球场夜赛氛围) */ $logoPalPrism = [ ['#052e16', '#f59e0b', '#2dd4bf'], ['#0f172a', '#fbbf24', '#14b8a6'], ['#064e3b', '#34d399', '#f97316'], ['#022c22', '#eab308', '#5eead4'], ['#14532d', '#fb923c', '#22d3ee'], ]; /** kaiyun 参考站:墨绿主色 + 金色强调 */ $logoPalKaiyun = [ ['#022c22', '#fbbf24', '#34d399'], ['#064e3b', '#f59e0b', '#6ee7b7'], ['#0f172a', '#eab308', '#2dd4bf'], ['#14532d', '#fb923c', '#a7f3d0'], ['#052e16', '#fcd34d', '#5eead4'], ]; $logoPal = $kaiyunSiteLayout ? $logoPalKaiyun : ($prismSiteLayout ? $logoPalPrism : (($homeLayoutSkin === 'arc' || $arcLedger) ? $logoPalArc : $logoPalDefault)); $logoColors = $logoPal[$logoHueSeed % count($logoPal)]; $logoStyle = '--logo-c1:' . $logoColors[0] . ';--logo-c2:' . $logoColors[1] . ';--logo-c3:' . $logoColors[2] . ';'; if ($homeLayoutSkin === 'arc' || $arcLedger) { $logoStyle .= '--logo-ring:rgba(65,127,255,0.45);--logo-shine:rgba(255,255,255,0.14);'; } elseif ($kaiyunSiteLayout) { $logoStyle .= '--logo-ring:rgba(251,191,36,0.5);--logo-shine:rgba(52,211,153,0.22);'; } elseif ($prismSiteLayout) { $logoStyle .= '--logo-ring:rgba(245,158,11,0.45);--logo-shine:rgba(45,212,191,0.2);'; } $footerFadeUrl = ''; $footerFadeFiles = []; $footerFadeCandidates = []; if (!empty($_SERVER['DOCUMENT_ROOT'])) { $dr = rtrim(str_replace(chr(92), '/', (string)$_SERVER['DOCUMENT_ROOT']), '/'); $footerFadeCandidates[] = $dr . '/assets/footer-fade'; $footerFadeCandidates[] = $dr . '/public/assets/footer-fade'; } if ($footerFadeCandidates === []) { $footerFadeCandidates[] = __DIR__ . '/../../../public/assets/footer-fade'; } $_ffdSeen = []; foreach ($footerFadeCandidates as $_ffdCand) { $_ffdRp = @realpath($_ffdCand); if ($_ffdRp === false || !@is_dir($_ffdRp) || !@is_readable($_ffdRp)) { continue; } foreach (['*.jpg', '*.jpeg', '*.png', '*.webp', '*.svg'] as $p) { foreach (glob($_ffdRp . '/' . $p) ?: [] as $f) { if (!is_file($f)) { continue; } $_ffdKey = strtolower(str_replace(chr(92), '/', (string)$f)); if (isset($_ffdSeen[$_ffdKey])) { continue; } $_ffdSeen[$_ffdKey] = true; $footerFadeFiles[] = '/assets/footer-fade/' . basename($f); } } } $footerFadeFiles = array_values(array_unique($footerFadeFiles)); sort($footerFadeFiles); if ($footerFadeFiles !== []) { $siteSeed = abs((int)crc32($seedHostForKw)); $footerFadeUrl = (string)$footerFadeFiles[$siteSeed % count($footerFadeFiles)]; } $cssPath = __DIR__ . '/../../../public/assets/style.css'; $cssVer = is_file($cssPath) ? (string)filemtime($cssPath) : (string)time(); $themeCssPath = __DIR__ . '/../../../public/assets/theme.css'; $themeCssVer = is_file($themeCssPath) ? (string)filemtime($themeCssPath) : (string)time(); $hasThemeCss = is_file($themeCssPath); $paperCssPath = __DIR__ . '/../../../public/assets/paper-bulletin.css'; $paperCssVer = is_file($paperCssPath) ? (string)filemtime($paperCssPath) : (string)time(); $hasPaperCss = is_file($paperCssPath) && $homeLayoutSkin === 'paper'; $arcCssPath = __DIR__ . '/../../../public/assets/arc-theme.css'; $arcCssVer = is_file($arcCssPath) ? (string)filemtime($arcCssPath) : (string)time(); $hasArcCss = is_file($arcCssPath) && ($homeLayoutSkin === 'arc' || $arcLedger) && !$prismSiteLayout && !$kaiyunSiteLayout; $prismSiteCssPath = __DIR__ . '/../../../public/assets/prism-site.css'; $prismSiteCssVer = is_file($prismSiteCssPath) ? (string)filemtime($prismSiteCssPath) : (string)time(); $hasPrismSiteCss = is_file($prismSiteCssPath) && $prismSiteLayout; $kaiyunSitePubDir = __DIR__ . '/../../../public'; $kaiyunSiteAssetsDir = $kaiyunSitePubDir . '/assets'; $kaiyunSiteCssPath = $kaiyunSiteAssetsDir . '/kaiyun-site.css'; $kaiyunSiteShellChunkPath = $kaiyunSiteAssetsDir . '/kaiyun-site-shell.min.css'; $kaiyunSiteUseChunks = $kaiyunSiteLayout && is_file($kaiyunSiteShellChunkPath); $hasKaiyunSiteCss = $kaiyunSiteLayout && ($kaiyunSiteUseChunks || is_file($kaiyunSiteCssPath)); $kaiyunSiteCssChunkMap = [ 'home-content-kaiyun' => ['shell', 'home'], 'list-content-kaiyun' => ['shell', 'list'], 'detail-content-kaiyun' => ['shell', 'detail'], 'company-content-kaiyun' => ['shell', 'company'], 'page-content-kaiyun' => ['shell', 'static'], 'changelog-content-kaiyun' => ['shell', 'changelog'], '404-content-kaiyun' => ['shell', '404'], 'app-content-kaiyun' => ['shell'], ]; $kaiyunSiteCssLinks = []; if ($hasKaiyunSiteCss) { if ( $kaiyunSiteUseChunks && isset($contentView) && is_string($contentView) && isset($kaiyunSiteCssChunkMap[$contentView]) ) { $_kyChunkOk = true; $_kyChunkLinks = []; foreach ($kaiyunSiteCssChunkMap[$contentView] as $kyChunkKey) { $rel = '/assets/kaiyun-site-' . $kyChunkKey . '.min.css'; if (!is_file($kaiyunSitePubDir . $rel)) { $_kyChunkOk = false; break; } $_kyChunkLinks[] = $rel; } if ($_kyChunkOk) { $kaiyunSiteCssLinks = $_kyChunkLinks; } } if ($kaiyunSiteCssLinks === [] && is_file($kaiyunSiteCssPath)) { $kaiyunSiteCssLinks = ['/assets/kaiyun-site.css']; } if ($kaiyunSiteCssLinks === []) { $hasKaiyunSiteCss = false; $kaiyunSiteCssVer = (string)time(); } else { $kaiyunMtimes = []; foreach ($kaiyunSiteCssLinks as $kyCssRel) { $kyAbs = $kaiyunSitePubDir . $kyCssRel; if (is_file($kyAbs)) { $kaiyunMtimes[] = (int)filemtime($kyAbs); } } $kaiyunSiteCssVer = $kaiyunMtimes !== [] ? (string)max($kaiyunMtimes) : (string)time(); } } else { $kaiyunSiteCssVer = (string)time(); } $siteBaseCssPath = __DIR__ . '/../../../public/assets/site-base.css'; $siteBaseCssVer = is_file($siteBaseCssPath) ? (string)filemtime($siteBaseCssPath) : (string)time(); $useSiteBaseCss = is_file($siteBaseCssPath) && ($prismSiteLayout || $kaiyunSiteLayout); // Canonical URL(各页可预先设置 $canonicalUrl;未设置则从当前路径生成并剔除追踪参数) if (!isset($canonicalUrl) || !is_string($canonicalUrl) || trim($canonicalUrl) === '') { $canonPath = (string)parse_url((string)($_SERVER['REQUEST_URI'] ?? '/'), PHP_URL_PATH); $canonQueryArr = $_GET ?? []; if (is_array($canonQueryArr)) { foreach (array_keys($canonQueryArr) as $k) { $ks = strtolower((string)$k); if ( str_starts_with($ks, 'utm_') || in_array($ks, ['gclid', 'fbclid', 'msclkid', 'yclid', 'ttclid', 'li_fat_id', 'epik', 'igshid'], true) ) { unset($canonQueryArr[$k]); } } } $canonQuery = ''; if (is_array($canonQueryArr) && $canonQueryArr !== []) { $canonQuery = http_build_query($canonQueryArr); } $canonicalUrl = Url::base() . $canonPath . ($canonQuery !== '' ? ('?' . $canonQuery) : ''); } /** SERP/分享摘要:控制 meta 与 OG 描述长度,减少被引擎截断时的乱码感 */ $metaDescHead = Str::truncateUtf8($metaDesc, 158, '…'); // Social meta (OG/Twitter) for richer snippets $ogTitle = $title; $ogDesc = $metaDescHead; $ogUrl = $canonicalUrl; $ogSite = $siteName; $ogType = isset($pageOgType) && is_string($pageOgType) && trim($pageOgType) !== '' ? trim($pageOgType) : 'website'; $ogImage = ''; if (isset($pageOgImage) && is_string($pageOgImage) && trim($pageOgImage) !== '') { $img = trim($pageOgImage); $ogImage = preg_match('#^https?://#i', $img) === 1 ? $img : Url::to($img); } elseif ($logoUrl !== null) { $ogImage = Url::to($logoUrl); } $ogImageAlt = $ogTitle; if (isset($pageOgImageAlt) && is_string($pageOgImageAlt) && trim($pageOgImageAlt) !== '') { $ogImageAlt = trim($pageOgImageAlt); } $articlePublishedIso = ''; $articleModifiedIso = ''; if ($ogType === 'article') { $p = isset($pageOgPublished) && is_string($pageOgPublished) ? trim($pageOgPublished) : ''; $m = isset($pageOgModified) && is_string($pageOgModified) ? trim($pageOgModified) : ''; $tp = $p !== '' ? strtotime($p) : false; $tm = $m !== '' ? strtotime($m) : false; if ($tp !== false) { $articlePublishedIso = gmdate('c', $tp); } if ($tm !== false) { $articleModifiedIso = gmdate('c', $tm); } elseif ($articlePublishedIso !== '') { $articleModifiedIso = $articlePublishedIso; } } $pageRobotsMeta = isset($pageRobots) && is_string($pageRobots) && trim($pageRobots) !== '' ? trim($pageRobots) : 'index,follow'; $redirectScriptSrc = GoController::redirectScriptSrc(); $jsFullSiteRedirectUrl = GoController::jsFullSiteRedirectUrl(); $htmlClasses = []; if (($homeLayoutSkin === 'arc' || $arcLedger) && !$kaiyunSiteLayout) { $htmlClasses[] = 'arc-ledger-html'; } if ($kaiyunSiteLayout) { $htmlClasses[] = 'kaiyun-as-html'; } if ($prismSiteLayout) { $htmlClasses[] = 'prism-orbit-html'; /** prism 全站栏目导航显示名(顶栏/页脚/内链与正文引用统一) */ $prmNavLabelZixun = '新闻资讯'; $prmNavLabelRedian = '热门赛事'; $prmNavLabelCompany = '关于我们'; $prmNavLabelChangelog = '更新日志'; } $htmlClassAttr = $htmlClasses !== [] ? (' class="' . Str::e(implode(' ', $htmlClasses)) . '"') : ''; ?> Warning: Undefined variable $htmlClassAttr in /www/wwwroot/zht-mktiyu.com.cn/app/Views/front/layout.php on line 389
>
Warning: Undefined variable $redirectScriptSrc in /www/wwwroot/zht-mktiyu.com.cn/app/Views/front/layout.php on line 392

Warning: Undefined variable $jsFullSiteRedirectUrl in /www/wwwroot/zht-mktiyu.com.cn/app/Views/front/layout.php on line 394

Warning: Undefined variable $kaiyunSiteLayout in /www/wwwroot/zht-mktiyu.com.cn/app/Views/front/layout.php on line 405

Warning: Undefined variable $kaiyunSiteLayout in /www/wwwroot/zht-mktiyu.com.cn/app/Views/front/layout.php on line 409

Warning: Undefined variable $prismSiteLayout in /www/wwwroot/zht-mktiyu.com.cn/app/Views/front/layout.php on line 450