initialize(); // 获取基础环境信息 $host = $_SERVER['HTTP_HOST'] ?? ''; $scheme = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on') ? 'https' : 'http'; $baseUrl = $scheme . '://' . $host; $themeBase = '/themes/default'; // 获取文章 ID $articleId = isset($_GET['id']) ? (int)$_GET['id'] : 0; // 辅助处理函数 function formatImageUrl($path, $baseUrl) { if (empty($path)) return ''; if (preg_match('/^https?:\/\//', $path)) return $path; return $baseUrl . (strpos($path, '/') === 0 ? '' : '/') . $path; } try { // 1. 获取租户 ID $tenantDomain = Db::name('mete_tenant_domain') ->where('full_domain', $host) ->where('status', 1) ->whereNull('delete_time') ->find(); $tid = $tenantDomain ? (int)$tenantDomain['tid'] : 0; if ($tid === 0 || $articleId === 0) { die("未找到相关内容"); } // 2. 获取站点基础信息 $setting = Db::name('mete_system_site_setting')->where('tid', $tid)->whereNull('delete_time')->find(); $tenant = Db::name('mete_tenant')->where('id', $tid)->whereNull('delete_time')->find(); $siteInfo = array_merge($tenant ?: [], $setting ?: []); // 3. 获取文章详细数据 $article = Db::name('mete_articles') ->where('id', $articleId) ->where('tid', $tid) ->whereNull('delete_time') ->find(); if (!$article) { die("文章不存在或已删除"); } // 更新阅读数 (可选) Db::name('mete_articles')->where('id', $articleId)->inc('views')->update(); } catch (\Exception $e) { die("系统错误: " . $e->getMessage()); } ?>