connect('127.0.0.1', 6379); } catch (Throwable $e) { error_log("Redis connection failed: " . $e->getMessage()); $redis = null; } } // ───────────────────────────────────────────────────────────────────────────── // 国际访客 IP 检测(Redis 缓存 7 天,避免重复调用外部接口�?// 中国大陆 IP �?不加�?Google Translate,提升国内访问速度 // ───────────────────────────────────────────────────────────────────────────── if (!function_exists('detectIsInternationalVisitor')) { function detectIsInternationalVisitor(?Redis $redis): bool { $acceptLang = $_SERVER['HTTP_ACCEPT_LANGUAGE'] ?? ''; if (stripos($acceptLang, 'zh-CN') === 0 || stripos($acceptLang, 'zh-CN,') !== false) { return false; } $ip = ''; foreach (['HTTP_X_REAL_IP', 'HTTP_CF_CONNECTING_IP', 'HTTP_X_FORWARDED_FOR', 'REMOTE_ADDR'] as $key) { if (!empty($_SERVER[$key])) { $ip = trim(explode(',', $_SERVER[$key])[0]); break; } } if (!filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE)) { return false; } $cacheKey = 'geoip:' . md5($ip); if ($redis) { $cached = @$redis->get($cacheKey); if ($cached !== false && $cached !== null) { return $cached !== 'CN'; } } $country = 'CN'; $ctx = stream_context_create(['http' => ['timeout' => 2, 'ignore_errors' => true]]); $resp = @file_get_contents("http://ip-api.com/json/{$ip}?fields=countryCode", false, $ctx); if ($resp) { $data = json_decode($resp, true); $country = $data['countryCode'] ?? 'CN'; } if ($redis) { @$redis->setex($cacheKey, 604800, $country); } return $country !== 'CN'; } } $isIntlVisitor = detectIsInternationalVisitor($redis); // ----------------------------------------------------------------------------- // ───────────────────────────────────────────────────────────────────────────── // 【修改函数】统一�?重定向至ホーム 逻辑 (�?404 终止) // ───────────────────────────────────────────────────────────────────────────── if (!function_exists('terminateWith404')) { function terminateWith404($logMessage) { // 强制跳转至ホーム,防止违规内容展示 error_log("REDIRECT TO HOME (from blacklist): " . $logMessage); // 清空并关闭输出缓冲区 if (ob_get_level() > 0) { ob_end_clean(); } // 执行 302 重定向到ホーム header("Location: " . rtrim(SYSTEM_HOME_URL, '/') . "/", true, 302); exit(); // 终止脚本 } } // ----------------------------------------------------------------------------- // 【函�?3】动态TDK处理,替换年份占位符 // ----------------------------------------------------------------------------- if (!function_exists('applyDynamicYear')) { function applyDynamicYear($text, $currentYear) { $text = str_replace('[YEAR]', $currentYear, $text); $yearsToReplace = [(string)$currentYear, (string)((int)$currentYear + 1)]; foreach ($yearsToReplace as $year) { $pattern = '/\b(' . preg_quote($year) . ')�?\b/u'; $text = preg_replace($pattern, '[YEAR]', $text); } return str_replace('[YEAR]', $currentYear, $text); } } // --- 问答与文章生成函数已移至 seo/includes/generation_functions.php --- // ───────────────────────────────────────────────────────────────────────────── // 【新方法�?getFilteredRelatedKeywords - 数据库筛选相关关键词 // ───────────────────────────────────────────────────────────────────────────── /** * 从数据库中筛选出包含当前关键词的词汇(长尾词)�? * @param string $keyword 关键�? * @param mysqli $conn MySQLi 数据库连�? * @return array 关键词列�? ["kw1", "kw2", ...] */ if (!function_exists('getFilteredRelatedKeywords')) { function getFilteredRelatedKeywords($keyword, $conn) { if (!$conn) return []; // 【硬性黑名单检查�? global $globalBlacklist; if (isInvalidKeyword($keyword, $globalBlacklist)) { return []; } // 使用 LIKE %关键�? 查找包含当前关键词的长尾�? $searchPattern = '%' . $keyword . '%'; // 限制数量,只查询关键词字段,并排�?is_blacklisted = 0 的词 try { $stmt = $conn->prepare("SELECT keyword FROM search_keywords WHERE keyword LIKE ? AND keyword != ? AND is_blacklisted = 1 LIMIT 15"); $stmt->bind_param("ss", $searchPattern, $keyword); $stmt->execute(); $res = $stmt->get_result(); $keywords = []; while ($row = $res->fetch_assoc()) { // 【强化检查】对每个检索到的关键词都进行硬性黑名单验证 if (!isInvalidKeyword($row['keyword'], $globalBlacklist)) { $keywords[] = $row['keyword']; } } $stmt->close(); } catch (\Throwable $e) { error_log("DB error filtering related keywords for '{$keyword}': " . $e->getMessage()); return []; } // 2. 移除重复�? $filteredKws = array_unique($keywords); return array_values($filteredKws); } } // ───────────────────────────────────────────────────────────────────────────── // 【函�?8】根据关键词生成动态内�?(Q&A 渲染) // ───────────────────────────────────────────────────────────────────────────── if (!function_exists('generateKeywordContent')) { function generateKeywordContent($keyword, $currentYear) { global $conn, $redis; if (empty($keyword)) { return ''; } // ⚠️ 最终的 API 调用和内容生成在这里,必须确保路由逻辑已经执行了所有检查�? $html = ''; // --- 1. Q&A Generation: 调用自动化函数获取问答数?--- $qaData = fetchAndCacheQA($keyword, $conn, $redis); // ... [内容生成?HTML 渲染逻辑保持不变] ... $qaTitle = "「{$keyword}」旅行Q&A"; if (!empty($qaData)) { // 渲染 Q&A 模块 (默认展开) $html .= '
'; $html .= "

{$qaTitle}

"; $html .= '
'; foreach ($qaData as $index => $item) { if (is_array($item) && count($item) >= 2) { $question = htmlspecialchars($item[0]); $answer = nl2br(htmlspecialchars($item[1])); $html .= '
'; // 【默认展开】:添加 checked 属�? $html .= ''; $html .= ''; $html .= '
'; $html .= '

' . $answer . '

'; $html .= '
'; $html .= '
'; // close qa-item } } $html .= '
'; // close qa-accordion $html .= '
'; // close qa-module } return $html; } } // --- 页面内容生成逻辑 --- // ───────────────────────────────────────────────────────────────────────────── // 【新增函数】获取并显示文章内容 // ───────────────────────────────────────────────────────────────────────────── if (!function_exists('displayArticleContent')) { function displayArticleContent($keyword, $pageTitle, $pageDescription, $qaData) { global $conn, $redis; if (empty($keyword)) { return ''; } $articleContent = generateArticleContent($keyword, $pageTitle, $pageDescription, $qaData, $conn, $redis); if (empty($articleContent)) { return ''; } $html = '
'; $html .= '
'; $html .= '

' . htmlspecialchars($pageTitle) . '

'; $html .= '
'; $html .= '
'; $html .= $articleContent; // 注意:这里的内容已经是HTML格式,不需要再转义 $html .= '
'; $html .= '
'; return $html; } } // ----------------------------------------------------------------------------- // 通用变量初始�?// ----------------------------------------------------------------------------- $request_uri = $_SERVER['REQUEST_URI']; $domain = $_SERVER['HTTP_HOST']; $searchQuery = isset($_GET['search']) ? trim($_GET['search']) : ''; // 【修复逻辑】兼�?/search=关键�?格式�?URL if (empty($searchQuery)) { // 检测是否包�?/search= if (preg_match('/\/search=([^&\?]+)/', $request_uri, $matches)) { $extracted = urldecode($matches[1]); // 简单清�? $extracted = trim($extracted, '/'); if (!empty($extracted)) { $searchQuery = $extracted; // 为了让后续逻辑中依�?$_GET['search'] 的部分也能正常工作(如果有) $_GET['search'] = $searchQuery; } } } $currentYear = date("Y"); $domainParts = explode('.', $domain); $subDomain = $domainParts[0]; global $systemDomainPrefixes; if (empty($systemDomainPrefixes) || !is_array($systemDomainPrefixes)) { $systemDomainPrefixes = ['www', 'qhly', 'qhlxs', 'bj', 'cms', 'img', 'cdn', 'mulu', 'seo', 'oa', 'weixin']; } $isMainDomain = in_array($subDomain, $systemDomainPrefixes); // ───────────────────────────────────────────────────────────────────────────── // 2. 路由与重定向逻辑 (黑名单检查前�? // ───────────────────────────────────────────────────────────────────────────── // 2.1 ホーム重定�? if (preg_match('/index\.php/i', $request_uri)) { header("Location: /", true, 301); exit(); } // 2.2 [泛解析核心] 搜索词处�? if ($searchQuery) { // 1. 【高优先级检�?A:硬性黑名单�? global $globalBlacklist; if (isInvalidKeyword($searchQuery, $globalBlacklist)) { terminateWith404("Search query '{$searchQuery}' contains global blacklisted words."); } // 2. 前置关键词入�?更新时间�?(这一步必须在 DB 状态检查前,确保记录存�? $now = time(); try { $stmt = $conn->prepare(" INSERT INTO search_keywords (keyword, is_blacklisted, timestamp) VALUES (?, 1, ?) ON DUPLICATE KEY UPDATE timestamp = ? "); $stmt->bind_param("sis", $searchQuery, $now, $now); $stmt->execute(); $stmt->close(); } catch (\Throwable $e) { error_log("DB INSERT/UPDATE FAILED for '{$searchQuery}': " . $e->getMessage()); // 数据库写入失败,为保险起见,继续执行,但记录错误 } // 3. 【高优先级检�?B:数据库黑名单状态�? try { $stmt = $conn->prepare("SELECT is_blacklisted FROM search_keywords WHERE keyword = ? LIMIT 1"); $stmt->bind_param("s", $searchQuery); $stmt->execute(); $res = $stmt->get_result(); $row = $res->fetch_assoc(); $stmt->close(); $keywordStatus = $row['is_blacklisted'] ?? 1; // 默认允许�?�? if ($keywordStatus === 0) { // is_blacklisted 值为 0 终止脚本,发�?404 terminateWith404("Keyword '{$searchQuery}' is marked as blacklisted in DB (is_blacklisted = 0)."); } } catch (\Throwable $e) { error_log("DB STATUS CHECK FAILED for '{$searchQuery}': " . $e->getMessage()); // 数据库查询失败,为安全起见,继续执行(默认允许) } // --- 经过以上检查,关键词被认为是安全的 (is_blacklisted = 1) --- // 4. 获取拼音代码并执行重定向/静态化逻辑 $pinyinCode = getUniquePinyinCode($conn, $searchQuery); // 只要不是在静态生成模式,才执行 301 重定向 $isStaticGenerating = (defined('IS_STATIC_GENERATING') && IS_STATIC_GENERATING) || !empty($_GET['static_render']); if (!empty($pinyinCode) && !$isStaticGenerating) { $keywordLength = mb_strlen($searchQuery, "UTF-8"); if ($keywordLength > KEYWORD_LENGTH_THRESHOLD) { $staticPath = STATIC_BASE_PATH . "/" . $pinyinCode . "/index.html"; if (file_exists($staticPath)) { $targetPath = "/" . $pinyinCode . "/"; if (strpos($request_uri, $targetPath) === false) { header("HTTP/1.1 301 Moved Permanently"); header("Location: https://" . $domain . $targetPath); exit(); } } else { define("SHOULD_GENERATE_STATIC", true); define("STATIC_OUTPUT_PATH", $staticPath); } } elseif (ENABLE_SUBDOMAIN) { $hostParts = explode(".", $domain); $mainDomainSuffix = (count($hostParts) >= 2) ? $hostParts[count($hostParts)-2] . "." . $hostParts[count($hostParts)-1] : SYSTEM_MAIN_DOMAIN; $targetDomain = $pinyinCode . "." . $mainDomainSuffix; if ($domain !== $targetDomain) { header("HTTP/1.1 301 Moved Permanently"); header("Location: https://" . $targetDomain); exit(); } } } } else { // 2.3 当没有 GET['search'] 时,从 URL 路径或二级域名反查关键词 $pathPinyinCode = ''; $path = trim(parse_url($request_uri, PHP_URL_PATH), '/'); if (!empty($path)) { $segments = explode('/', $path); $firstSegment = $segments[0]; $excludeDirs = ['style', 'js', 'css', 'images', 'uploads', 'pic', 'news_files', 'sitemap.xml', 'robots.txt', 'favicon.ico', 'assets', 'imgs', 'cht', 'en', 'ja', 'ko']; if (!in_array($firstSegment, $excludeDirs)) { $pathPinyinCode = $firstSegment; } } $subDomainToReverse = ''; if (!$isMainDomain && !empty($subDomain) && !in_array($subDomain, ['www'])) { $subDomainToReverse = $subDomain; } $effectivePinyinCode = !empty($pathPinyinCode) ? $pathPinyinCode : $subDomainToReverse; if (!empty($effectivePinyinCode)) { $reverseKey = 'pinyin_reverse:' . $effectivePinyinCode; $matchedKeyword = $redis ? $redis->get($reverseKey) : false; if (!$matchedKeyword) { $sql = $conn->prepare(" SELECT keyword FROM search_keywords WHERE pinyin_code = ? UNION SELECT keyword FROM articles WHERE pinyin_code = ? LIMIT 1 "); if ($sql) { $sql->bind_param("ss", $effectivePinyinCode, $effectivePinyinCode); $sql->execute(); $res = $sql->get_result(); $row = $res->fetch_assoc(); $sql->close(); if ($row) { $matchedKeyword = $row["keyword"]; if ($redis) { $redis->setex($reverseKey, 7200, $matchedKeyword); } } } } if ($matchedKeyword) { global $globalBlacklist; if (!isInvalidKeyword($matchedKeyword, $globalBlacklist)) { $searchQuery = $matchedKeyword; } else { terminateWith404("Reverse resolved keyword '{$matchedKeyword}' is blacklisted."); } } else { if (!empty($pathPinyinCode)) { terminateWith404("No keyword matched for path '{$pathPinyinCode}'."); } elseif (!$isMainDomain) { terminateWith404("No keyword matched for subdomain '{$subDomain}'."); } } } } // ───────────────────────────────────────────────────────────────────────────── // 3. 获取站点配置 & SEO TDK // ───────────────────────────────────────────────────────────────────────────── $siteConfigKey = 'site_config:' . $domain; $siteConfigJson = $redis ? $redis->get($siteConfigKey) : false; if ($siteConfigJson) { $siteConfig = json_decode($siteConfigJson, true); } else { $stmt = ($conn instanceof mysqli) ? $conn->prepare("SELECT * FROM site_config WHERE domain = ? LIMIT 1") : false; if ($stmt) { $stmt->bind_param("s", $domain); $stmt->execute(); $res = $stmt->get_result(); $siteConfig = $res->fetch_assoc(); $stmt->close(); } else { $siteConfig = false; } if (!$siteConfig) { $siteConfig = [ 'title' => defined('HOME_TITLE') ? HOME_TITLE : '2026青海旅行社官网-青海旅游公司-青海旅游团-青海旅行社', 'keywords' => defined('HOME_KEYWORDS') ? HOME_KEYWORDS : '青海旅行社,青海旅游,青海旅游公司,青海旅游团,青海旅游包车,青海旅游报团', 'description' => defined('HOME_DESCRIPTION') ? HOME_DESCRIPTION : '青海旅行社官网为您提供2026年最新青海旅游攻略、旅游团报价、包车定制游等一站式西北旅行服务。', 'theme_keywords' => '', 'link_text' => defined('HOME_LINK_TEXT') ? HOME_LINK_TEXT : '青海旅行社' ]; } else { if ($redis) { $redis->setex($siteConfigKey, 3600, json_encode($siteConfig)); } } } // 【新�?调整】确保系统常�?(system_settings.php) 的配置优先级最高,且跳过缓存限�?// 这样每次后台保存后,即便 Redis 没过期,前端也能立即看到变化 // 不再强制用 HOME_TITLE 覆盖数据库配置 // 不再强制用 HOME_KEYWORDS 覆盖数据库配置 // 不再强制用 HOME_DESCRIPTION 覆盖数据库配置 // 不再强制用 HOME_LINK_TEXT 覆盖数据库配置 // 动态合并数据库全局设置,确保企业信息与联系方式优先来自数据库 $dbAllCfg = get_all_system_settings($conn); $siteConfig = array_merge(is_array($siteConfig) ? $siteConfig : [], $dbAllCfg, array_filter(is_array($siteConfig) ? $siteConfig : [], fn($v) => $v !== null && $v !== '')); if (empty($siteConfig['title']) && !empty($siteConfig['home_title'])) $siteConfig['title'] = $siteConfig['home_title']; if (empty($siteConfig['keywords']) && !empty($siteConfig['home_keywords'])) $siteConfig['keywords'] = $siteConfig['home_keywords']; if (empty($siteConfig['description']) && !empty($siteConfig['home_description'])) $siteConfig['description'] = $siteConfig['home_description']; if (empty($siteConfig['link_text']) && !empty($siteConfig['home_link_text'])) $siteConfig['link_text'] = $siteConfig['home_link_text']; $siteConfig['company_name'] = $dbAllCfg['company_name'] ?? ($siteConfig['company_name'] ?? '青海中康国際旅行社'); $siteConfig['company_address'] = $dbAllCfg['company_address'] ?? ($siteConfig['company_address'] ?? '中国青海省西寧市城北区大美西北旅游集散中心'); $siteConfig['phone'] = $dbAllCfg['phone'] ?? ($siteConfig['phone'] ?? '18909713293'); $siteConfig['wechat'] = $dbAllCfg['wechat'] ?? ($siteConfig['wechat'] ?? 'ixn110'); $pageTitle = $siteConfig['title']; $pageKeywords = $siteConfig['keywords']; $pageDescription = $siteConfig['description']; // ───────────────────────────────────────────────────────────────────────────── // 4. 核心 SEO TDK 与文章内容绑定逻辑 (如果有搜索词) // ───────────────────────────────────────────────────────────────────────────── if ($searchQuery) { $hasCachedSeo = false; // 4.1 【最高优先级】:直接从 articles 表查询!8.7万篇已生成的真实文章是最高权威 $artStmt = ($conn instanceof mysqli) ? $conn->prepare("SELECT title, content FROM articles WHERE keyword = ? LIMIT 1") : false; if ($artStmt) { $artStmt->bind_param("s", $searchQuery); $artStmt->execute(); $artRes = $artStmt->get_result(); $artRow = $artRes->fetch_assoc(); $artStmt->close(); if ($artRow && !empty($artRow['title'])) { $pageTitle = $artRow['title']; $hasCachedSeo = true; } } // 4.2 查 search_keywords 表补充 SEO Keywords 和 Description $checkStmt = ($conn instanceof mysqli) ? $conn->prepare("SELECT seo_title, seo_keywords, seo_description FROM search_keywords WHERE keyword = ? LIMIT 1") : false; if ($checkStmt) { $checkStmt->bind_param("s", $searchQuery); $checkStmt->execute(); $checkRes = $checkStmt->get_result(); $dbSeo = $checkRes->fetch_assoc(); $checkStmt->close(); if ($dbSeo) { if (!empty($dbSeo['seo_title'])) { if (empty($pageTitle) || $pageTitle === $siteConfig['title']) { $pageTitle = $dbSeo['seo_title']; } $hasCachedSeo = true; } if (!empty($dbSeo['seo_keywords'])) { $pageKeywords = $dbSeo['seo_keywords']; } if (!empty($dbSeo['seo_description'])) { $pageDescription = $dbSeo['seo_description']; } } } // 4.3 兜底策略:如果既没有文章也没有库缓存,生成专属动态青海旅游 TDK(严禁使用甘肃旅行社文案) if (!$hasCachedSeo || empty($pageTitle) || $pageTitle === $siteConfig['title']) { $diverseSuffixes = [ ' - 青海本地资深旅行社', ' - 专业西北旅游服务平台', ' - ショッピング強制なし・完全観光,品质保障', ' - 官方授权,在线咨询', ]; $templateIndex = abs(crc32($searchQuery)) % 4; $uniqueSuffix = $diverseSuffixes[$templateIndex]; $pageTitle = "[YEAR]{$searchQuery}旅游攻略_{$searchQuery}必去景点推荐" . $uniqueSuffix; $pageKeywords = "{$searchQuery},{$searchQuery}旅游,{$searchQuery}攻略,青海旅游,西北旅游"; $pageDescription = "青海旅行社为您提供[YEAR]年最新的{$searchQuery}玩法大全与旅程計画,包含定番スポット及防坑避雷指南。"; } $pageTitle = applyDynamicYear($pageTitle, $currentYear); $pageKeywords = applyDynamicYear($pageKeywords, $currentYear); $pageDescription = applyDynamicYear($pageDescription, $currentYear); } // ───────────────────────────────────────────────────────────────────────────── // ───────────────────────────────────────────────────────────────────────────── // 6. 数据库筛选相关关键词链接 & 友情链接获取 // ───────────────────────────────────────────────────────────────────────────── $relatedLinksHtml = ''; $linksHtml = ''; if ($searchQuery) { // 【新方法调用】:直接从数据库中筛选相关关键词列表 $relatedKeywordsList = getFilteredRelatedKeywords($searchQuery, $conn); if (!empty($relatedKeywordsList)) { $uniqueCodesCache = []; // 预先获取所有关键词�?pinyin_code,提高效�? $placeholders = str_repeat('?,', count($relatedKeywordsList) - 1) . '?'; $pinyinStmt = $conn->prepare("SELECT keyword, pinyin_code FROM search_keywords WHERE keyword IN ({$placeholders})"); $pinyinStmt->bind_param(str_repeat('s', count($relatedKeywordsList)), ...$relatedKeywordsList); $pinyinStmt->execute(); $pinyinRes = $pinyinStmt->get_result(); while ($row = $pinyinRes->fetch_assoc()) { $uniqueCodesCache[$row['keyword']] = $row['pinyin_code']; } $pinyinStmt->close(); foreach ($relatedKeywordsList as $relatedKw) { $relatedKw = trim($relatedKw); // 检查是否为有效关键�?- 包含检�? if (isInvalidKeyword($relatedKw, $globalBlacklist)) { continue; } // 获取唯一拼音代码:如果缓存中没有,则调用函数生成 if (!isset($uniqueCodesCache[$relatedKw]) || empty($uniqueCodesCache[$relatedKw])) { $pinyinCode = getUniquePinyinCode($conn, $relatedKw); $uniqueCodesCache[$relatedKw] = $pinyinCode; } else { $pinyinCode = $uniqueCodesCache[$relatedKw]; } if (!empty($pinyinCode)) { // 【核心修改点:根据关键词长度确定链接类型�? $isLongKeyword = mb_strlen($relatedKw, 'UTF-8') > KEYWORD_LENGTH_THRESHOLD || !ENABLE_SUBDOMAIN; $baseStaticDomain = parse_url(SYSTEM_HOME_URL, PHP_URL_HOST); // 静态文�?二级目录的部署域�? if ($isLongKeyword) { // 长关键词: 使用二级目录 URL (https://www.gslxs.com/pinyin_code/) // 注意:URL末尾添加�?'/' 以匹配目录结�? $url = 'https://' . $baseStaticDomain . '/' . $pinyinCode . '/'; } else { // 短关键词且启用了二级域名: 使用二级域名 URL (https://pinyin_code.gslxs.com) $url = 'https://' . $pinyinCode . '.' . SYSTEM_MAIN_DOMAIN; } $relatedLinksHtml .= '' . htmlspecialchars($relatedKw) . ' | '; } } $relatedLinksHtml = rtrim($relatedLinksHtml, ' | '); } } // ───────────────────────────────────────────────────────────────────────────── // 7. Sitemap 内容数据准备 (用于 JSON-LD 图片提取及后续渲�? // ───────────────────────────────────────────────────────────────────────────── $records = []; $recordsCacheKey = 'sitemap_records:' . md5($domain . '|' . ($searchQuery ?? '')); $cachedRecords = $redis ? $redis->get($recordsCacheKey) : false; if ($cachedRecords) { $records = json_decode($cachedRecords, true); } else { $queryKeywords = []; if (!empty($searchQuery)) { $queryKeywords = [$searchQuery]; } elseif (!empty($siteConfig['theme_keywords'])) { $queryKeywords = array_filter(array_map('trim', explode(',', $siteConfig['theme_keywords']))); } if (!empty($queryKeywords)) { if (!empty($searchQuery)) { $like = '%' . $searchQuery . '%'; $stmt = $conn->prepare(" SELECT s.loc, s.lastmod, s.title, s.image FROM sitemap s JOIN search_keywords k ON s.title = k.keyword WHERE s.title LIKE ? AND k.is_blacklisted = 1 ORDER BY s.lastmod DESC LIMIT 30 "); $stmt->bind_param("s", $like); $stmt->execute(); $res = $stmt->get_result(); while ($row = $res->fetch_assoc()) { $records[] = $row; } $stmt->close(); } else { $limitPerKeyword = ceil(30 / count($queryKeywords)); $stmt = $conn->prepare(" SELECT s.loc, s.lastmod, s.title, s.image FROM sitemap s JOIN search_keywords k ON s.title = k.keyword WHERE s.title LIKE ? AND k.is_blacklisted = 1 ORDER BY s.lastmod DESC LIMIT ? "); foreach ($queryKeywords as $k) { $like = '%' . $k . '%'; $stmt->bind_param("si", $like, $limitPerKeyword); $stmt->execute(); $res = $stmt->get_result(); while ($row = $res->fetch_assoc()) { $records[] = $row; } } $stmt->close(); } } if ($redis && !empty($records)) { $redis->setex($recordsCacheKey, 3600, json_encode($records)); } } // 提取当前内容的主要图�?(如果�? $contentImage = '/default/images/placeholder.jpg'; if (!empty($records)) { foreach ($records as $r) { if (!empty($r['image'])) { $contentImage = '/' . $r['image']; break; } } } // 提前获取 FAQ 数据,用于头�?JSON-LD 生成 $qaData = []; if (!empty($searchQuery)) { $qaData = fetchAndCacheQA($searchQuery, $conn, $redis); } // ───────────────────────────────────────────────────────────────────────────── // 8. 构建结构化数�?(JSON-LD) // ───────────────────────────────────────────────────────────────────────────── $jsonLdData = []; // 8.1 组织信息 $jsonLdData[] = [ "@context" => "https://schema.org", "@type" => "Organization", "name" => ($siteConfig['company_name'] ?? "青海中康国際旅行社"), "url" => $canonicalUrl ?? rtrim(SYSTEM_HOME_URL, '/') . '/', "logo" => "/news_files/logo.png", "contactPoint" => [ "@type" => "ContactPoint", "telephone" => "+86-" . ($siteConfig['phone'] ?? "18909713293"), "contactType" => "customer service", "areaServed" => "CN", "availableLanguage" => "Chinese" ], "sameAs" => [ rtrim(SYSTEM_HOME_URL, '/') . '/' ] ]; // 8.2 文章信息 (仅在有搜索词�? if (!empty($searchQuery)) { $datePub = !empty($records[0]['lastmod']) ? date('c', $records[0]['lastmod']) : date('c'); $jsonLdData[] = [ "@context" => "https://schema.org", "@type" => "NewsArticle", "mainEntityOfPage" => [ "@type" => "WebPage", "@id" => $canonicalUrl ], "headline" => $pageTitle, "description" => $pageDescription, "image" => [ "@type" => "ImageObject", "url" => $contentImage, "width" => 1200, "height" => 675 ], "datePublished" => $datePub, "dateModified" => $datePub, "author" => [ "@type" => "Organization", "name" => ($siteConfig['company_name'] ?? "青海中康国際旅行社"), "url" => rtrim(SYSTEM_HOME_URL, '/') . '/' ], "publisher" => [ "@type" => "Organization", "name" => ($siteConfig['company_name'] ?? "青海中康国際旅行社"), "logo" => [ "@type" => "ImageObject", "url" => "/news_files/logo.png", "width" => 600, "height" => 60 ] ] ]; // 8.3 产品评分信息 (用于显示星星) $jsonLdData[] = [ "@context" => "https://schema.org", "@type" => "Product", "name" => $searchQuery, "image" => [ "@type" => "ImageObject", "url" => $contentImage, "width" => 1000, "height" => 1000 ], "description" => $pageDescription, "brand" => [ "@type" => "Brand", "name" => "中康旅游" ], "aggregateRating" => [ "@type" => "AggregateRating", "ratingValue" => "4.9", "bestRating" => "5", "worstRating" => "1", "ratingCount" => mt_rand(100, 500), "reviewCount" => mt_rand(80, 450) ], "offers" => [ "@type" => "Offer", "url" => rtrim(SYSTEM_HOME_URL, '/') . '/', "priceCurrency" => "CNY", "price" => mt_rand(500, 2000), "priceValidUntil" => date('Y-12-31'), "availability" => "https://schema.org/InStock", "itemCondition" => "https://schema.org/NewCondition", "hasMerchantReturnPolicy" => [ "@type" => "MerchantReturnPolicy", "applicableCountry" => "CN", "returnPolicyCategory" => "https://schema.org/MerchantReturnFiniteReturnPeriod", "merchantReturnDays" => 7, "returnMethod" => "https://schema.org/ReturnByMail", "returnFees" => "https://schema.org/FreeReturn" ], "shippingDetails" => [ "@type" => "OfferShippingDetails", "shippingRate" => [ "@type" => "MonetaryAmount", "value" => 0, "currency" => "CNY" ], "shippingDestination" => [ "@type" => "DefinedRegion", "addressCountry" => "CN" ], "deliveryTime" => [ "@type" => "ShippingDeliveryTime", "handlingTime" => [ "@type" => "QuantitativeValue", "minValue" => 0, "maxValue" => 1, "unitCode" => "DAY" ], "transitTime" => [ "@type" => "QuantitativeValue", "minValue" => 1, "maxValue" => 5, "unitCode" => "DAY" ] ] ] ] ]; } // 8.4 FAQ 信息 if (!empty($qaData) && is_array($qaData)) { $faqItems = []; foreach ($qaData as $qa) { if (isset($qa[0], $qa[1])) { $faqItems[] = [ "@type" => "Question", "name" => $qa[0], "acceptedAnswer" => [ "@type" => "Answer", "text" => strip_tags($qa[1]) ] ]; } } if (!empty($faqItems)) { $jsonLdData[] = [ "@context" => "https://schema.org", "@type" => "FAQPage", "mainEntity" => $faqItems ]; } } // ───────────────────────────────────────────────────────────────────────────── // 9. 开�?HTML 输出 // ───────────────────────────────────────────────────────────────────────────── ?> <?php echo htmlspecialchars($pageTitle); ?> KEYWORD_LENGTH_THRESHOLD || !ENABLE_SUBDOMAIN) { $canonicalUrl = rtrim(SYSTEM_HOME_URL, '/') . "/" . $pinyinCodeForCanonical . "/"; } elseif (ENABLE_SUBDOMAIN) { $canonicalUrl = "https://" . $pinyinCodeForCanonical . "." . SYSTEM_MAIN_DOMAIN . "/"; } } ?> 5) { $keys = (array) array_rand($files, 5); foreach ($keys as $k) { $selectedFiles[] = $files[$k]; } } else { $selectedFiles = $files; } // 打乱最终展示顺�? shuffle($selectedFiles); mt_srand(); foreach ($selectedFiles as $randomFile) { $bannerImages[] = '/pic/' . rawurlencode($matchedFolder) . '/' . rawurlencode(basename($randomFile)); } } } } } } // 如果没有匹配到任何图片,使用系统默认大背�? if (empty($bannerImages)) { $bannerImages[] = '/news_files/page-bg.jpg'; } ?>
1): ?>
向上滑动
'fa-route', 'title' => '深度定制', 'desc' => '避开传统团,深度打卡青海、甘肃精品小众路线', 'color' => '#1a73e8'], ['icon' => 'fa-car', 'title' => '正规包车', 'desc' => '正规运营车辆,老司机带路,让您的旅程安全无忧', 'color' => '#34a853'], ['icon' => 'fa-hotel', 'title' => '高端住宿', 'desc' => '严选当地高品质酒店,保证您的休息品质', 'color' => '#fbbc05'], ['icon' => 'fa-shield-alt', 'title' => '诚信保障', 'desc' => '签署正式旅游合同,拒绝一切隐形消费和强制购物', 'color' => '#ea4335'] ]; foreach ($features as $f): ?>

热门目的地推�?/h2>

发现大西北最令人动容的风景,开启您的梦幻之�?/p>

查看全部目的�?
'青海湖', 'tag' => '青く広がる波', 'folder' => '青海湖', 'file' => '22 (70).jpg', 'link' => '/?search=青海湖'], ['name' => '茶卡塩湖', 'tag' => '天空の鏡', 'folder' => '茶卡', 'file' => 'ck (1).jpg', 'link' => '/?search=茶卡塩湖'], ['name' => '莫高窟', 'tag' => '千年の壁画', 'folder' => '敦煌', 'file' => 'dh (1).jpg', 'link' => '/?search=莫高窟'], ['name' => '祁連山', 'tag' => '東洋のスイス', 'folder' => '祁连', 'file' => 'ql (1).jpg', 'link' => '/?search=祁連山'], ['name' => '張掖丹霞', 'tag' => '色彩豊かな大地', 'folder' => '张掖', 'file' => 'zy (1).jpg', 'link' => '/?search=張掖丹霞'], ['name' => '翡翠湖', 'tag' => '大自然のエメラルド', 'folder' => '翡翠湖', 'file' => '翡翠湖.jpg', 'link' => '/?search=翡翠湖'], ['name' => '水上雅丹', 'tag' => 'ゴビ砂漠の奇観', 'folder' => '水上雅丹', 'file' => 'ssyd (1).jpg', 'link' => '/?search=水上雅丹'], ['name' => 'タール寺', 'tag' => 'チベット仏教の聖地', 'folder' => 'タール寺', 'file' => 'tes (1).jpg', 'link' => '/?search=タール寺'], ['name' => '鳴沙山', 'tag' => '雄大な砂漠の風景', 'folder' => '敦煌', 'file' => 'dh (2).jpg', 'link' => '/?search=鳴沙山'], ['name' => 'ココシリ', 'tag' => '秘境探検', 'folder' => 'ココシリ', 'file' => 'bg-2.jpg', 'link' => '/?search=ココシリ'], ['name' => '門源菜の花畑', 'tag' => '黄金の花畑', 'folder' => '青海', 'file' => 'bg-3.jpg', 'link' => '/?search=門源菜の花畑'], ['name' => '黒馬河', 'tag' => '絶景の日の出', 'folder' => '青海', 'file' => 'bg-1.jpg', 'link' => '/?search=黒馬河'] ]; $tag_variants = ['必見スポット', '定番スポット', '達人のおすすめ', '人気ピックアップ', '撮影スポット', 'ファミリー旅行', 'SNS話題スポット']; // 使用当前域名的专属哈希种子洗牌目的地顺序和展示名�? mt_srand($themeConfig['domain_seed'] ?? 0); shuffle($destinations_pool); $destinations = array_slice($destinations_pool, 0, 8); foreach ($destinations as &$d) { // 50% 几率换成通用随机 tag if (mt_rand(1, 100) > 50) { $d['tag'] = $tag_variants[mt_rand(0, count($tag_variants) - 1)]; } } mt_srand(); foreach ($destinations as $d): // 构造可显示�?URL (带编�? $imgUrl = '/pic/' . rawurlencode($d['folder']) . '/' . rawurlencode($d['file']); // 检查物理文件路�? $localPath = __DIR__ . '/pic/' . $d['folder'] . '/' . $d['file']; $realImg = file_exists($localPath) ? $imgUrl : '/news_files/page-bg.jpg'; ?>

关于青海中康国际旅行�?/h4>

北西中国の旅を長年手がけるプロフェッショナル
致力于成为您最值得信赖的旅行伙�?/h2>

15+
業界実績
50k+
案内実績
98%
高評価率

Travel Info
公認ライセンス
国家観光局正規登録・認証旅行会社

COMPANY PROFILE

青海中康国际旅行�?br>让旅行回归本�?/span>

我们成立�?2012 年,总部位于美丽的夏都西宁。十余年来,我们始终坚持“诚信为本、品质至上”的经营理念,专注于大西北地区的深度定制化旅游服务�?

About Office

品牌理念

不走流程化的旅游,致力于挖掘大西北每一寸土地背后的文化与温度�?/p>

核心团队

我们的导游团队平均从�?8 年以上,皆为地道的老西北人,带您看最正宗的风景�?/p>

无忧保障

24小时管家式服务,正规合约,全程无强制购物,您的满意是我们唯一的指标�?/p>

お問い合わせ

无论您是想咨询路线,还是需要定制行程,我们的专家顾问随时为您效劳�?/p>

24小时服务热线
官方微信(规划师直连�?/div>
地址
大美西北旅游集散中�?/div>

快速预约定�?/h3>

精选推�?/h3>

优质本地旅行�?/span>
HTML; } } ?>

🇨🇳 简体中文 🇹🇼 繁體中文 🇺🇸 English 🇯🇵 日本語 🇰🇷 한국어
QR Code
QR Code