<?php
session_start();
require 'include/common.php';

$statusCheckStmt = $pdo->query("SELECT v FROM " . table('settings') . " WHERE k = 'site_status'");
$siteStatus = $statusCheckStmt->fetchColumn(); // 获取网站状态

if ($siteStatus != '1') {
    die("");
}

$stmt = $pdo->query("SELECT v FROM " . table('settings') . " WHERE k = 'homepage_template'");
$templateName = $stmt->fetchColumn();

$templateFile = $_SERVER['DOCUMENT_ROOT'] .'/template/' . htmlspecialchars($templateName) . '/index.php';
if (!file_exists($templateFile)) {
    $defaultTemplateFile = '../template/default/index.php';
    if (file_exists($defaultTemplateFile)) {
        $templateFile = $defaultTemplateFile;
    } else {
        // 如果默认模板也不存在，可以显示错误信息
        die("找不到模板文件，请检查模板配置或创建默认模板。");
    }
}
?>
<?php include $templateFile; ?>
