getDomainConfig($currentHost); // 根据域名配置确定模板路径 $templatePath = 'qqffc'; // 默认模板 if ($domainConfigResult['success'] && !empty($domainConfigResult['data']['path'])) { $templatePath = $domainConfigResult['data']['path']; } // 更新配置中的模板路径 $config['template_root'] = __DIR__ . '/' . $templatePath . '/templates/'; $config['domain_config'] = $domainConfigResult['data'] ?? []; // 将域名配置的关键数据合并到config中,供模板直接使用 if ($domainConfigResult['success'] && !empty($domainConfigResult['data'])) { $domainData = $domainConfigResult['data']; $config['name'] = $domainData['name'] ?? $domainData['title'] ?? $config['site_name']; $config['site_name'] = $config['name']; // 保持兼容性 $config['site_title'] = $domainData['title'] ?? $domainData['name'] ?? $config['site_name']; $config['site_keywords'] = $domainData['keywords'] ?? 'QQFFC,奇趣分分彩,彩票计划,彩票开奖'; $config['site_description'] = $domainData['description'] ?? '奇趣分分彩计划精准版-腾讯分分彩平台人工在线计划-天天玩计划-奇趣分分彩计划'; $config['template_path'] = $domainData['path'] ?? 'qqffc'; // 模板路径 $config['domain'] = $domainData['domainName'] ?? $currentHost; // 添加域名信息 $config['copyright'] = $domainData['copyright'] ?? 'Copyright © 2025 QQFFC.COM 奇趣分分彩计划版权所有'; // 添加版权信息 } else { // 如果没有域名配置,使用当前主机名作为域名 $config['domain'] = $currentHost; } // 获取请求信息 $requestMethod = $_SERVER['REQUEST_METHOD']; $requestUri = $_SERVER['REQUEST_URI']; $queryParams = $_GET; // 分离路径和查询参数 $parsedUri = parse_url($requestUri); $requestPath = $parsedUri['path'] ?? '/'; $queryString = $parsedUri['query'] ?? ''; // 检查是否为静态文件请求 if ($globalRouter->isStaticFile($requestPath)) { if ($globalRouter->serveStaticFile($requestPath)) { return; } } // 使用路由系统进行分发 $routeResult = $globalRouter->dispatch($requestMethod, $requestPath, $queryParams); // 处理路由结果 if ($routeResult['type'] === 'special') { // 特殊处理 switch ($routeResult['action']) { case 'image_proxy': require_once __DIR__ . '/image_proxy.php'; return; } } elseif ($routeResult['type'] === 'error') { // 错误处理 if ($routeResult['code'] == 404) { // 404错误使用专门的模板页面 header('HTTP/1.0 404 Not Found'); // 包含404模板 $templateFile = $config['template_root'] . '404.php'; if (file_exists($templateFile)) { include $templateFile; } else { // 如果404模板不存在,使用简单的错误页面 echo '404 - 页面未找到'; echo '

404 - 页面未找到

'; echo '

抱歉,您访问的页面不存在。

'; echo '

返回首页

'; echo ''; } return; } else { // 其他错误使用原来的处理方式 header('HTTP/1.0 ' . $routeResult['code'] . ' ' . $routeResult['message']); echo '' . $routeResult['code'] . ' ' . $routeResult['message'] . ''; echo '

' . $routeResult['code'] . ' ' . $routeResult['message'] . '

'; echo '

' . htmlspecialchars($routeResult['message']) . '

'; if (isset($routeResult['uri'])) { echo '

请求的URL: ' . htmlspecialchars($routeResult['uri']) . '

'; } echo ''; return; } } // 页面处理 $pageType = $routeResult['page_type']; $lotteryType = $routeResult['lottery_type'] ?? $config['default_lottery_type']; // 设置全局变量供路由工具函数使用 $currentPageType = $pageType; $currentLotteryType = $lotteryType; // 彩票类型列表 $lotteryTypes = getLotteryTypes(); // 最新开奖结果 $latestResults = getLatestResults(20); // 热门资讯 $newsService = ApiServiceFactory::getNewsService(); $hotNewsResult = $newsService->getHotNews(15); $hotNews = $hotNewsResult['success'] ? $hotNewsResult['data'] : []; // 处理新闻详情页 if ($pageType === 'news_detail' && isset($_GET['news_id'])) { $newsId = $_GET['news_id']; // 获取新闻服务并调用详情API $newsService = ApiServiceFactory::getNewsService(); $detailResult = $newsService->getDetail($newsId); if ($detailResult['success']) { $newsDetail = $detailResult['data']; } else { // API失败时的备用数据 $newsDetail = [ 'id' => $newsId, 'title' => '新闻详情暂时无法加载', 'createTime' => date('Y-m-d H:i:s'), 'author' => '网站编辑', 'summary' => '抱歉,该新闻详情暂时无法加载,请稍后重试。', 'content' => '

内容加载失败

抱歉,新闻内容暂时无法加载,请稍后重试或联系管理员。

新闻ID: ' . htmlspecialchars($newsId) . '

', 'catalogId' => 1, 'catalogName' => '系统消息', 'coverImg' => '', 'viewCount' => 0, 'tags' => [] ]; } // 获取相关新闻 $relatedResult = $newsService->getRelatedNews($newsId); if ($relatedResult['success']) { $relatedNews = $relatedResult['data']; } else { // 如果相关新闻获取失败,使用热门新闻作为备用 $relatedNews = array_slice($hotNews, 0, 3); } } // 为lottery页面准备数据 if (strpos($pageType, 'lottery_') === 0) { // 彩种名称 $lotteryName = ''; foreach ($lotteryTypes as $type) { if ($type['code'] === $lotteryType) { $lotteryName = $type['name']; break; } } // 该彩种的最新结果 $latestTypeResults = []; foreach ($latestResults as $result) { if ($result['type'] === $lotteryType) { $latestTypeResults[] = $result; } } // 如果没有匹配的结果,使用开奖结果服务生成正确格式的数据 if (empty($latestTypeResults)) { $resultService = ApiServiceFactory::getLotteryResultService(); $defaultResults = $resultService->getLatestResults(10); // 调试输出 if (isset($_GET['debug'])) { echo "\n"; echo "\n"; foreach ($defaultResults as $idx => $result) { echo "\n"; } } // 筛选出当前彩种的数据 $latestTypeResults = []; foreach ($defaultResults as $result) { if ($result['type'] === $lotteryType) { $latestTypeResults[] = $result; } } // 如果还是没有数据,生成该彩种的专用数据 if (empty($latestTypeResults)) { $currentDate = date('Ymd'); $currentHour = date('H'); $currentMinute = date('i'); $currentIssue = ($currentHour * 60 + $currentMinute); // 获取彩种配置 $lotteryConfig = getLotteryConfig($lotteryType); for ($i = 0; $i < 10; $i++) { $issueNum = max(1, $currentIssue - $i); // 根据彩种配置生成正确的号码 $numbers = []; $digits = $lotteryConfig['digits']; $range = $lotteryConfig['range']; for ($j = 0; $j < $digits; $j++) { // 根据彩种判断是否需要两位数格式 if (in_array($lotteryType, ['azxys', 'azxyw', 'bjpk10', 'xyft', 'jssc', 'jx11x5', 'gd11x5'])) { $numbers[] = sprintf('%02d', mt_rand($range[0], $range[1])); } else { $numbers[] = mt_rand($range[0], $range[1]); } } $latestTypeResults[] = [ 'type' => $lotteryType, 'name' => $lotteryName, 'expect' => $currentDate . '-' . str_pad($issueNum, 4, '0', STR_PAD_LEFT), 'openCode' => implode(',', $numbers), 'openTime' => date('Y-m-d H:i:s', strtotime('-' . $i . ' minutes')) ]; } } } // 如果是彩票详情页,准备一个详情结果 if ($pageType === 'lottery_detail' && isset($_GET['expect'])) { $resultService = ApiServiceFactory::getLotteryResultService(); $detailResponse = $resultService->getResultDetail($lotteryType, $_GET['expect']); $detailResult = $detailResponse['success'] ? $detailResponse['data'] : null; } // 历史开奖数据 if ($pageType === 'lottery_history') { $page = isset($_GET['page']) ? max(1, intval($_GET['page'])) : 1; $size = 20; $resultService = ApiServiceFactory::getLotteryResultService(); $historyResult = $resultService->getHistoryResults($lotteryType, $page, $size); if ($historyResult['success']) { $lotteryHistory = $historyResult['data']; $pagination = [ 'current_page' => $historyResult['pagination']['current'], 'total_pages' => $historyResult['pagination']['pages'], 'total' => $historyResult['pagination']['total'], 'query_string' => '' ]; } else { $lotteryHistory = []; $pagination = [ 'current_page' => 1, 'total_pages' => 1, 'total' => 0, 'query_string' => '' ]; } } } // 资讯分类 $newsService = ApiServiceFactory::getNewsService(); $catalogsResult = $newsService->getCatalogs(); $newsCatalogs = $catalogsResult['success'] ? $catalogsResult['data'] : []; // 处理资讯列表页 if ($pageType === 'news_list') { // 获取页码参数 $currentPage = isset($_GET['page']) ? max(1, intval($_GET['page'])) : 1; $pageSize = 10; // 每页显示10条新闻 // 获取新闻服务 $newsService = ApiServiceFactory::getNewsService(); // 根据不同的参数获取新闻列表 if (isset($_GET['catalog_id'])) { // 分类新闻 $result = $newsService->getNewsByCatalog($_GET['catalog_id'], $currentPage, $pageSize); } elseif (isset($_GET['tag_id'])) { // 标签新闻 $result = $newsService->getNewsByTag($_GET['tag_id'], $currentPage, $pageSize); } elseif (isset($_GET['keyword'])) { // 搜索新闻 $result = $newsService->searchNews($_GET['keyword'], $currentPage, $pageSize); } else { // 普通新闻列表分页 $result = $newsService->getPage($currentPage, $pageSize); } if ($result['success']) { $newsPage = $result['data']; $totalPages = ceil($newsPage['total'] / $pageSize); $pagination = [ 'currentPage' => $currentPage, 'totalPages' => $totalPages, 'total' => $newsPage['total'], 'size' => $pageSize ]; } else { // 如果获取失败,显示空列表 $newsPage = [ 'list' => [], 'total' => 0, 'page' => 1, 'size' => $pageSize ]; $pagination = [ 'currentPage' => 1, 'totalPages' => 1, 'total' => 0, 'size' => $pageSize ]; } } // 处理工具页面 if (strpos($pageType, 'tools_') === 0) { // 为工具页面准备一些基础数据 $toolsData = [ 'trend' => '走势图分析', 'missing' => '遗漏分析', 'hot' => '冷热分析', 'shrink' => '缩水工具', 'random' => '随机选号', 'history' => '历史统计' ]; $currentTool = isset($_GET['tool_type']) ? $_GET['tool_type'] : 'index'; // 为随机选号工具准备彩种配置数据 if ($pageType === 'tools_random') { $lotteryConfigs = []; foreach ($lotteryTypes as $type) { $lotteryConfigs[$type['code']] = getLotteryConfig($type['code']); } } // 准备趋势分析数据 if ($pageType === 'tools_trend') { $trendPeriods = [30, 50, 100]; $trendData = []; for ($i = 0; $i < 30; $i++) { $numbers = []; for ($j = 0; $j < 5; $j++) { $numbers[] = mt_rand(0, 9); } $trendData[] = [ 'period' => sprintf('20250517-%04d', 1432 - $i), 'numbers' => $numbers, 'time' => date('Y-m-d H:i:s', strtotime('-' . $i . ' hours')) ]; } } // 准备遗漏分析数据 if ($pageType === 'tools_missing') { $missingData = []; for ($pos = 0; $pos < 5; $pos++) { for ($num = 0; $num <= 9; $num++) { $missingData[$pos][$num] = mt_rand(0, 50); } } } // 准备冷热分析数据 if ($pageType === 'tools_hot') { $hotColdData = []; for ($num = 0; $num <= 9; $num++) { $hotColdData[$num] = [ 'number' => $num, 'frequency' => mt_rand(10, 100), 'missing' => mt_rand(0, 30), 'type' => mt_rand(0, 2) // 0=冷, 1=温, 2=热 ]; } } } // 输出调试信息(可选) if (isset($_GET['debug'])) { echo "\n"; echo "\n"; echo "\n"; echo "\n"; } // 获取SEO信息 $seoParams = []; if ($pageType === 'lottery_detail' && isset($_GET['expect'])) { $seoParams['expect'] = $_GET['expect']; } elseif ($pageType === 'news_detail' && isset($newsDetail)) { $seoParams['title'] = $newsDetail['title']; $seoParams['summary'] = $newsDetail['summary']; } // 打印 seoParams 数据到控制台 if (isset($_GET['debug'])) { echo "\n"; } // 首先尝试获取域名特定的SEO配置 $domainSeoResult = $domainService->getSeoConfig($currentHost, $lotteryType, $pageType); if ($domainSeoResult['success'] && !empty($domainSeoResult['data'])) { $seo = $domainSeoResult['data']; } else { // 如果没有域名特定配置,使用默认SEO配置 $seo = getSeoInfo($pageType, $lotteryType, $seoParams); } // 统一整理 TDK 字段 $tdk = [ 'title' => $seo['title'] ?? '', 'keywords' => $seo['keywords'] ?? '', 'description' => $seo['description'] ?? '', 'links' => $config['domain_config']['friendlyLinks'] ?? '' ]; // 使用 convertToHtmlEntities 对 TDK 内容进行 HTML 实体转码 $GLOBALS['firstKeyword'] = convertToHtmlEntities(explode(',', $tdk['keywords'])[0] ?? ''); $GLOBALS['description'] = convertToHtmlEntities($tdk['description']); $GLOBALS['title'] = convertToHtmlEntities($tdk['title']); $GLOBALS['links'] = convertToHtmlEntities($tdk['links']); $GLOBALS['currentDomain'] = $config['domain'] ?? $currentHost; $GLOBALS['siteKeywords'] = convertToHtmlEntities($tdk['keywords']); // 页面模板继续使用这些转义后的变量 $title = $GLOBALS['title']; $keywords = $GLOBALS['siteKeywords']; $description = $GLOBALS['description']; $siteName = $config['site_name']; // 获取当前的域名 $domain = $config['domain'] ?? $currentHost; // 如果不存在就使用当前主机名 $config['copyright'] = 'Copyright © 2025 ' . $title . ' 版权所有'; $copyright = $config['copyright']; // 包含模板文件 $templateRoot = $config['template_root']; if (file_exists($templateRoot . 'layout.php')) { include $templateRoot . 'layout.php'; } else { echo "布局模板不存在!"; } // 性能优化: 输出缓冲结束并发送内容 if (ob_get_level() > 0) { ob_end_flush(); }