吉日查询主题模板 主题说明
简介:专为"吉日查询"场景打造的响应式主题,覆盖结婚、订婚、开业、搬家等十大择吉场景,对接逗号API智能生成黄道吉日,内置老黄历查询,并自带收益转化。
主题截图
文章详情页截图
文章列表页截图
开业吉日截图
结婚吉日截图
首页截图
老黄历截图
安装方法
- 下载逗号CMS → 登录后台 → 主题管理 → 主题列表,找到「吉日查询主题模板」主题,点击免费安装
- 进入后台 → 网站设置 → SEO 设置,配置首页、文章分类列表页、文章详情页的 SEO 信息。可选:打开模板/templates/jiri/header.php,修改配置各页面的 SEO 信息。
- 进入 后台 → 网站设置 → 顶部导航,配置顶部导航及链接。
- 进入后台 → 网站设置,设置联盟ID。改为你自己在伍柒联盟union.632757.com的ID(右上角),所有收益就像归于您自己名下。【必须是V7.0以上】
- 进入内容管理 → 广告管理 → 网站横幅,上传顶部横幅广告图(吉日主题所有页面顶部都调用此广告位,想不同页面调用不同的广告图,只要在后台新增广告位,然后复制广告位的标签函数到对应的页面即可。)温馨提示:添加广告位必须要选择投放页面,请选择产品分类页面即可。
必看
页面显示403或者访问受限请按照下面方法操作
- 显示403:复制下面前端路由规则代码到:后台 → 管理 → 前端路由管理 → 全选覆盖路由规则 → 保存配置即可
- 测试显示访问受限:后台 → 统计安全 → 安全设置 → 关闭SQL注入。仅7月27日前下载的V6.9版本的部分IIS有此问题,若你遇到此问题未成功解决可以联系QQ:26505555588 反馈。
配置 API
吉日查询依赖「逗号API」接口:https://api.douhao.com/api/k/%E5%90%89%E6%97%A5
老黄历调用API接口:https://api.douhao.com/jie/16.html
每次调用将消耗1积分(注册有赠送50积分),199元初级代理就可以免费调用
代理权益列表:https://api.douhao.com/daili 。
获取 API 密钥
- 访问 逗号API网站 注册账号
- 登录逗号API后台首页,进入「API密钥管理」
- 复制 API 密钥
配置 API 密钥
- 后台 → 系统管理 → 网站设置
- 在「逗号API密钥」输入框粘贴密钥
- 保存设置
接口参数一览
如积分不足,请前往逗号API网站充值。账户积分与文章生成价格可在「AI自动撰文」页面查看。
前端路由规则
<?php
/**
* 逗号CMS - 前端路由配置(吉日查询网专版)
*/
function parse_rewrite_url($uri, $setting, $db, $prefix) {
// 吉日查询网路由
$jiri_routes = [
'/jiehun' => 'jiehun',
'/dinghun' => 'dinghun',
'/kaiye' => 'kaiye',
'/banjia' => 'banjia',
'/chuxing' => 'chuxing',
'/dongtu' => 'dongtu',
'/tiche' => 'tiche',
'/zhuangxiu' => 'zhuangxiu',
'/ruzhai' => 'ruzhai',
'/anmen' => 'anmen',
];
if (isset($jiri_routes[$uri])) {
return $jiri_routes[$uri];
}
// ============================================================
// 留言本路由
// 访问:/ubb 或 /ubb/{slug}
// ============================================================
if ($uri === '/ubb' || $uri === '/ubb/') {
return 'ubb_index';
}
if (preg_match('/^\/ubb\/([a-zA-Z0-9_\-]+)\/?$/', $uri, $matches)) {
$_GET['slug'] = $matches[1];
return 'ubb_page';
}
// ============================================================
// 老黄历独立页面
// 访问:/laohuangli 或 /laohuangli/2026-09-15
// ============================================================
if ($uri === '/laohuangli' || $uri === '/laohuangli/') {
return 'laohuangli';
}
if (preg_match('#^/laohuangli/(\d{4}-\d{2}-\d{2})/?$#', $uri, $m)) {
$_GET['date'] = $m[1];
return 'laohuangli';
}
// 老黄历 AJAX 接口
if ($uri === '/ajax_huangli' || $uri === '/ajax_huangli.php') {
return 'ajax_huangli';
}
// 文章详情页
$article_prefix = preg_quote($setting['article_prefix'] ?? 'article-', '/');
if (preg_match('/^\/' . $article_prefix . '([0-9a-zA-Z]+)\.html$/', $uri, $matches)) {
$url_id = $matches[1];
if ($setting['url_mode'] == 1) {
$_GET['id'] = intval($url_id);
} else {
$field = ($setting['url_mode'] == 2) ? 'hash_id' : 'md5_id';
$stmt = $db->prepare("SELECT id FROM {$prefix}article WHERE $field = ? LIMIT 1");
if ($stmt) {
$stmt->bind_param("s", $url_id);
$stmt->execute();
$res = $stmt->get_result();
if ($res && $res->num_rows > 0) {
$row = $res->fetch_assoc();
$_GET['id'] = $row['id'];
} else {
http_response_code(404);
require_once ROOT_PATH . 'set/404.php';
exit;
}
$stmt->close();
} else {
http_response_code(404);
require_once ROOT_PATH . 'set/404.php';
exit;
}
}
return 'article';
}
// 文章分类页
$category_prefix = preg_quote($setting['category_prefix'] ?? 'category-', '/');
if (preg_match('/^\/' . $category_prefix . '([0-9a-zA-Z]+)\.html$/', $uri, $matches)) {
$url_id = $matches[1];
$cat_url_mode = $setting['category_url_mode'] ?? 1;
if ($cat_url_mode == 1) {
$_GET['id'] = intval($url_id);
} else {
$field = ($cat_url_mode == 2) ? 'hash_id' : 'md5_id';
$stmt = $db->prepare("SELECT id FROM {$prefix}category WHERE $field = ? LIMIT 1");
if ($stmt) {
$stmt->bind_param("s", $url_id);
$stmt->execute();
$res = $stmt->get_result();
if ($res && $res->num_rows > 0) {
$row = $res->fetch_assoc();
$_GET['id'] = $row['id'];
} else {
http_response_code(404);
require_once ROOT_PATH . 'set/404.php';
exit;
}
$stmt->close();
} else {
http_response_code(404);
require_once ROOT_PATH . 'set/404.php';
exit;
}
}
return 'category';
}
// 产品列表页
if (preg_match('/^\/product\.html$/', $uri)) {
return 'product_list';
}
// 产品分类页
$product_category_prefix = preg_quote($setting['product_category_prefix'] ?? 'product-category-', '/');
if (preg_match('/^\/' . $product_category_prefix . '([0-9a-zA-Z]+)\.html$/', $uri, $matches)) {
$url_id = $matches[1];
$product_cat_url_mode = $setting['product_category_url_mode'] ?? 1;
if ($product_cat_url_mode == 1) {
$_GET['id'] = intval($url_id);
} else {
$field = ($product_cat_url_mode == 2) ? 'hash_id' : 'md5_id';
$stmt = $db->prepare("SELECT id FROM {$prefix}product_category WHERE $field = ? LIMIT 1");
if ($stmt) {
$stmt->bind_param("s", $url_id);
$stmt->execute();
$res = $stmt->get_result();
if ($res && $res->num_rows > 0) {
$row = $res->fetch_assoc();
$_GET['id'] = $row['id'];
} else {
http_response_code(404);
require_once ROOT_PATH . 'set/404.php';
exit;
}
$stmt->close();
} else {
http_response_code(404);
require_once ROOT_PATH . 'set/404.php';
exit;
}
}
return 'product_list';
}
// 产品详情页
$product_prefix = preg_quote($setting['product_prefix'] ?? 'product-', '/');
if (preg_match('/^\/' . $product_prefix . '([0-9a-zA-Z]+)\.html$/', $uri, $matches)) {
$url_id = $matches[1];
$product_url_mode = $setting['product_url_mode'] ?? 1;
if ($product_url_mode == 1) {
$_GET['id'] = intval($url_id);
} else {
$field = ($product_url_mode == 2) ? 'hash_id' : 'md5_id';
$stmt = $db->prepare("SELECT id FROM {$prefix}product WHERE $field = ? LIMIT 1");
if ($stmt) {
$stmt->bind_param("s", $url_id);
$stmt->execute();
$res = $stmt->get_result();
if ($res && $res->num_rows > 0) {
$row = $res->fetch_assoc();
$_GET['id'] = $row['id'];
} else {
http_response_code(404);
require_once ROOT_PATH . 'set/404.php';
exit;
}
$stmt->close();
} else {
http_response_code(404);
require_once ROOT_PATH . 'set/404.php';
exit;
}
}
return 'product_detail';
}
// 文章列表页
if ($uri === '/list.html' || preg_match('/^\/list-([0-9]+)\.html$/', $uri, $matches)) {
if (isset($matches[1])) $_GET['page'] = intval($matches[1]);
return 'list';
}
// 首页
if ($uri === '/' || $uri === '/index.php') {
return 'index';
}
return '404';
}
function route_dispatch($action, $db, $prefix, $setting, $template_path) {
if ($action === '404') {
http_response_code(404);
require_once ROOT_PATH . 'set/404.php';
exit;
}
$jiri_actions = ['jiehun','dinghun','kaiye','banjia','chuxing','dongtu','tiche','zhuangxiu','ruzhai','anmen'];
// ============================================================
// 留言本首页
// ============================================================
if ($action === 'ubb_index') {
$seo_row = $db->query("SELECT * FROM {$prefix}seo WHERE page_name = 'ubb_index' LIMIT 1")->fetch_assoc();
$site_name = $setting['site_name'] ?? '逗号CMS';
if ($seo_row) {
$seo = [
'title' => str_replace('{site_name}', $site_name, $seo_row['title'] ?: ('留言本 - ' . $site_name)),
'keywords' => str_replace('{site_name}', $site_name, $seo_row['keywords']),
'description' => str_replace('{site_name}', $site_name, $seo_row['description']),
];
} else {
$seo = [
'title' => '留言本 - ' . $site_name,
'keywords' => '留言本,在线留言,反馈',
'description' => '欢迎使用在线留言本,选择您想要留言的页面'
];
}
$GLOBALS['jiri_page_key'] = 'ubb';
$GLOBALS['jiri_seo'] = $seo;
include $template_path . 'header.php';
require ROOT_PATH . 'set/ubb/index.php';
include $template_path . 'footer.php';
return true;
}
// ============================================================
// 留言本详情页
// ============================================================
if ($action === 'ubb_page') {
$slug = isset($_GET['slug']) ? trim($_GET['slug']) : '';
$page_info_row = $db->query("SELECT * FROM {$prefix}ubb_pages WHERE slug = '" . $db->real_escape_string($slug) . "' AND status = 1 LIMIT 1")->fetch_assoc();
$site_name = $setting['site_name'] ?? '逗号CMS';
if ($page_info_row) {
$seo_row = $db->query("SELECT * FROM {$prefix}seo WHERE page_name = 'ubb_page' LIMIT 1")->fetch_assoc();
$replace_map = [
'{page_name}' => $page_info_row['name'],
'{page_description}' => $page_info_row['description'] ?: $page_info_row['name'],
'{site_name}' => $site_name,
];
if ($seo_row) {
$seo = [
'title' => str_replace(array_keys($replace_map), array_values($replace_map), $seo_row['title'] ?: ($page_info_row['name'] . ' - ' . $site_name)),
'keywords' => str_replace(array_keys($replace_map), array_values($replace_map), $seo_row['keywords']),
'description' => str_replace(array_keys($replace_map), array_values($replace_map), $seo_row['description']),
];
} else {
$seo = [
'title' => $page_info_row['name'] . ' - ' . $site_name,
'keywords' => $page_info_row['name'],
'description' => $page_info_row['description'] ?: $page_info_row['name']
];
}
} else {
$seo = [
'title' => '留言页 - ' . $site_name,
'keywords' => '',
'description' => ''
];
}
$GLOBALS['jiri_page_key'] = 'ubb';
$GLOBALS['jiri_seo'] = $seo;
include $template_path . 'header.php';
require ROOT_PATH . 'set/ubb/page.php';
include $template_path . 'footer.php';
return true;
}
// ============================================================
// 老黄历 AJAX 接口
// ============================================================
if ($action === 'ajax_huangli') {
header('Content-Type: application/json; charset=utf-8');
$date = trim($_POST['date'] ?? $_GET['date'] ?? date('Y-m-d'));
if (!preg_match('/^\d{4}-\d{2}-\d{2}$/', $date)) {
$date = date('Y-m-d');
}
$__hl_cache_file = CACHE_PATH . 'huangli_' . str_replace('-', '', $date) . '.json';
if (file_exists($__hl_cache_file)) {
$__cached = json_decode(file_get_contents($__hl_cache_file), true);
if (!empty($__cached)) {
echo json_encode(['status' => 1, 'data' => $__cached], JSON_UNESCAPED_UNICODE);
exit;
}
}
$__api_key = get_setting('douhao_api_key');
if (empty($__api_key)) {
echo json_encode(['status' => 0, 'msg' => '未配置API密钥'], JSON_UNESCAPED_UNICODE);
exit;
}
$__payload = json_encode([
'api_id' => 16,
'endpoint_id' => 'ep_c6f67706125a859b1ad1cda4b0138919',
'method' => 'POST',
'date' => $date,
], JSON_UNESCAPED_UNICODE);
$__ch = curl_init('https://api.douhao.com/gateway');
curl_setopt_array($__ch, [
CURLOPT_POST => true,
CURLOPT_POSTFIELDS => $__payload,
CURLOPT_HTTPHEADER => [
'Content-Type: application/json; charset=utf-8',
'X-API-Key: ' . $__api_key
],
CURLOPT_RETURNTRANSFER => true,
CURLOPT_TIMEOUT => 10,
CURLOPT_CONNECTTIMEOUT => 5,
CURLOPT_SSL_VERIFYPEER => false,
]);
$__resp = curl_exec($__ch);
curl_close($__ch);
if (!$__resp) {
echo json_encode(['status' => 0, 'msg' => '接口请求失败'], JSON_UNESCAPED_UNICODE);
exit;
}
$__data = json_decode($__resp, true);
if (empty($__data['success']) || empty($__data['data'])) {
echo json_encode(['status' => 0, 'msg' => $__data['msg'] ?? 'API返回错误'], JSON_UNESCAPED_UNICODE);
exit;
}
if (!is_dir(CACHE_PATH)) {
@mkdir(CACHE_PATH, 0755, true);
}
@file_put_contents(
$__hl_cache_file,
json_encode($__data['data'], JSON_UNESCAPED_UNICODE)
);
echo json_encode(['status' => 1, 'data' => $__data['data']], JSON_UNESCAPED_UNICODE);
exit;
}
// ============================================================
// 老黄历独立页面
// ============================================================
if ($action === 'laohuangli') {
$GLOBALS['jiri_page_key'] = 'laohuangli';
$tpl = $template_path . 'laohuangli.php';
if (!file_exists($tpl)) {
http_response_code(404);
require_once ROOT_PATH . 'set/404.php';
exit;
}
include $template_path . 'header.php';
include $tpl;
include $template_path . 'footer.php';
return true;
}
// ============================================================
// 首页:获取老黄历数据(带缓存)
// ============================================================
if ($action === 'index') {
$GLOBALS['jiri_huangli'] = null;
$__hl_cache_file = CACHE_PATH . 'huangli_' . date('Ymd') . '.json';
if (file_exists($__hl_cache_file)) {
$__hl_cached = json_decode(file_get_contents($__hl_cache_file), true);
if (!empty($__hl_cached)) {
$GLOBALS['jiri_huangli'] = $__hl_cached;
}
}
if (empty($GLOBALS['jiri_huangli'])) {
$__api_key = get_setting('douhao_api_key');
if (!empty($__api_key)) {
$__today = date('Y-m-d');
$__huangli_payload = json_encode([
'api_id' => 16,
'endpoint_id' => 'ep_c6f67706125a859b1ad1cda4b0138919',
'method' => 'POST',
'date' => $__today,
], JSON_UNESCAPED_UNICODE);
$__ch = curl_init('https://api.douhao.com/gateway');
curl_setopt_array($__ch, [
CURLOPT_POST => true,
CURLOPT_POSTFIELDS => $__huangli_payload,
CURLOPT_HTTPHEADER => [
'Content-Type: application/json; charset=utf-8',
'X-API-Key: ' . $__api_key
],
CURLOPT_RETURNTRANSFER => true,
CURLOPT_TIMEOUT => 10,
CURLOPT_CONNECTTIMEOUT => 5,
CURLOPT_SSL_VERIFYPEER => false,
]);
$__resp = curl_exec($__ch);
curl_close($__ch);
if ($__resp) {
$__data = json_decode($__resp, true);
if (!empty($__data['success']) && !empty($__data['data'])) {
$GLOBALS['jiri_huangli'] = $__data['data'];
if (!is_dir(CACHE_PATH)) {
@mkdir(CACHE_PATH, 0755, true);
}
@file_put_contents(
$__hl_cache_file,
json_encode($__data['data'], JSON_UNESCAPED_UNICODE)
);
}
}
}
}
}
// ============================================================
// 吉日查询 - API 提交处理
// ============================================================
if (in_array($action, $jiri_actions)
&& $_SERVER['REQUEST_METHOD'] === 'POST'
&& isset($_POST['action'])
&& $_POST['action'] === 'query_wedding_date') {
header('Content-Type: application/json; charset=utf-8');
$api_key = get_setting('douhao_api_key');
if (empty($api_key)) {
echo json_encode(['status' => 0, 'msg' => '系统未配置API密钥,请先到后台设置'], JSON_UNESCAPED_UNICODE);
exit;
}
$fmt_date = function($d) {
$d = trim($d);
if (preg_match('/^(\d{4})[-\/](\d{1,2})[-\/](\d{1,2})$/', $d, $m)) {
return sprintf('%04d-%02d-%02d', intval($m[1]), intval($m[2]), intval($m[3]));
}
return $d;
};
$allowed_ranges = ['1month','3months','6months','1year'];
$range = trim($_POST['weddingTime'] ?? '1month');
if (!in_array($range, $allowed_ranges)) $range = '1month';
$api_config_map = [
'jiehun' => ['api_id' => 20, 'endpoint_id' => 'ep_6d4354d20de1363c2515e00d6ec302cf'],
'dinghun' => ['api_id' => 58, 'endpoint_id' => 'ep_488e17e627217e2c5bf3ec110c0570ca'],
'kaiye' => ['api_id' => 59, 'endpoint_id' => 'ep_3d49744ec21bbd334b68039ae3876dcf'],
'banjia' => ['api_id' => 60, 'endpoint_id' => 'ep_45d63f4f422b4ac7ccef3fba49ba54a4'],
'chuxing' => ['api_id' => 61, 'endpoint_id' => 'ep_6af4348cb62375492af22bdbf006800b'],
'dongtu' => ['api_id' => 62, 'endpoint_id' => 'ep_49c3425790f8e3adbb4bbba959877a26'],
'tiche' => ['api_id' => 63, 'endpoint_id' => 'ep_3ad377bfb0eed7e5ab512eabc47e3519'],
'zhuangxiu' => ['api_id' => 64, 'endpoint_id' => 'ep_e6923d25ea8922bf1c7db407cbec7ffc'],
'ruzhai' => ['api_id' => 65, 'endpoint_id' => 'ep_1d5a8aa4ff2840095d940eaaade1b1f8'],
'anmen' => ['api_id' => 66, 'endpoint_id' => 'ep_37dd9e9db49598594fb21e0370cad312'],
];
$current_api = $api_config_map[$action] ?? $api_config_map['jiehun'];
if ($action === 'kaiye' || $action === 'dongtu') {
$bossHour = intval($_POST['bossHour'] ?? 0);
if ($bossHour < 0 || $bossHour > 23) $bossHour = 0;
$api_data = [
'api_id' => $current_api['api_id'],
'endpoint_id' => $current_api['endpoint_id'],
'method' => 'POST',
'bossName' => trim($_POST['bossName'] ?? ''),
'bossBirthday' => $fmt_date($_POST['bossBirthday'] ?? ''),
'bossHour' => $bossHour,
'range' => $range,
];
if (empty($api_data['bossName']) || empty($api_data['bossBirthday'])) {
echo json_encode(['status' => 0, 'msg' => '请填写完整的老板姓名与生日', 'debug' => ['api_params' => $api_data]], JSON_UNESCAPED_UNICODE);
exit;
}
$type_mode = 'boss';
} elseif ($action === 'chuxing') {
$travelerHour = intval($_POST['travelerHour'] ?? 0);
if ($travelerHour < 0 || $travelerHour > 23) $travelerHour = 0;
$api_data = [
'api_id' => $current_api['api_id'],
'endpoint_id' => $current_api['endpoint_id'],
'method' => 'POST',
'travelerName' => trim($_POST['travelerName'] ?? ''),
'travelerBirthday' => $fmt_date($_POST['travelerBirthday'] ?? ''),
'travelerHour' => $travelerHour,
'range' => $range,
];
if (empty($api_data['travelerName']) || empty($api_data['travelerBirthday'])) {
echo json_encode(['status' => 0, 'msg' => '请填写完整的出行人姓名与生日', 'debug' => ['api_params' => $api_data]], JSON_UNESCAPED_UNICODE);
exit;
}
$type_mode = 'traveler';
} elseif ($action === 'tiche') {
$buyerHour = intval($_POST['buyerHour'] ?? 0);
if ($buyerHour < 0 || $buyerHour > 23) $buyerHour = 0;
$api_data = [
'api_id' => $current_api['api_id'],
'endpoint_id' => $current_api['endpoint_id'],
'method' => 'POST',
'buyerName' => trim($_POST['buyerName'] ?? ''),
'buyerBirthday' => $fmt_date($_POST['buyerBirthday'] ?? ''),
'buyerHour' => $buyerHour,
'range' => $range,
];
if (empty($api_data['buyerName']) || empty($api_data['buyerBirthday'])) {
echo json_encode(['status' => 0, 'msg' => '请填写完整的买车人姓名与生日', 'debug' => ['api_params' => $api_data]], JSON_UNESCAPED_UNICODE);
exit;
}
$type_mode = 'buyer';
} elseif (in_array($action, ['banjia', 'zhuangxiu', 'ruzhai', 'anmen'])) {
$ownerHour = intval($_POST['ownerHour'] ?? 0);
$owner2Hour = intval($_POST['owner2Hour'] ?? 0);
if ($ownerHour < 0 || $ownerHour > 23) $ownerHour = 0;
if ($owner2Hour < 0 || $owner2Hour > 23) $owner2Hour = 0;
$owner2Name = trim($_POST['owner2Name'] ?? '');
$owner2Birthday = trim($_POST['owner2Birthday'] ?? '');
$api_data = [
'api_id' => $current_api['api_id'],
'endpoint_id' => $current_api['endpoint_id'],
'method' => 'POST',
'ownerName' => trim($_POST['ownerName'] ?? ''),
'ownerBirthday' => $fmt_date($_POST['ownerBirthday'] ?? ''),
'ownerHour' => $ownerHour,
'range' => $range,
];
if (!empty($owner2Name) && !empty($owner2Birthday)) {
$api_data['owner2Name'] = $owner2Name;
$api_data['owner2Birthday'] = $fmt_date($owner2Birthday);
$api_data['owner2Hour'] = $owner2Hour;
}
if (empty($api_data['ownerName']) || empty($api_data['ownerBirthday'])) {
echo json_encode(['status' => 0, 'msg' => '请填写完整的业主一姓名与生日', 'debug' => ['api_params' => $api_data]], JSON_UNESCAPED_UNICODE);
exit;
}
$type_mode = 'owner';
} else {
$maleHour = intval($_POST['maleHour'] ?? 0);
$femaleHour = intval($_POST['femaleHour'] ?? 0);
if ($maleHour < 0 || $maleHour > 23) $maleHour = 0;
if ($femaleHour < 0 || $femaleHour > 23) $femaleHour = 0;
$api_data = [
'api_id' => $current_api['api_id'],
'endpoint_id' => $current_api['endpoint_id'],
'method' => 'POST',
'maleName' => trim($_POST['maleName'] ?? ''),
'maleBirthday' => $fmt_date($_POST['maleBirthday'] ?? ''),
'maleHour' => $maleHour,
'femaleName' => trim($_POST['femaleName'] ?? ''),
'femaleBirthday' => $fmt_date($_POST['femaleBirthday'] ?? ''),
'femaleHour' => $femaleHour,
'range' => $range,
];
if (empty($api_data['maleName']) || empty($api_data['maleBirthday'])
|| empty($api_data['femaleName']) || empty($api_data['femaleBirthday'])) {
echo json_encode(['status' => 0, 'msg' => '请填写完整的男女双方姓名与生日', 'debug' => ['api_params' => $api_data]], JSON_UNESCAPED_UNICODE);
exit;
}
$type_mode = 'couple';
}
$json_payload = json_encode($api_data, JSON_UNESCAPED_UNICODE);
$ch = curl_init('https://api.douhao.com/gateway');
curl_setopt_array($ch, [
CURLOPT_POST => true,
CURLOPT_POSTFIELDS => $json_payload,
CURLOPT_HTTPHEADER => [
'Content-Type: application/json; charset=utf-8',
'X-API-Key: ' . $api_key
],
CURLOPT_RETURNTRANSFER => true,
CURLOPT_TIMEOUT => 120,
CURLOPT_SSL_VERIFYPEER => false,
]);
$response = curl_exec($ch);
$http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
$curl_err = curl_error($ch);
curl_close($ch);
if ($http_code !== 200 || empty($response)) {
echo json_encode([
'status' => 0,
'msg' => '接口请求失败:' . ($curl_err ?: 'HTTP ' . $http_code),
'debug' => ['http_code' => $http_code, 'curl_err' => $curl_err, 'json_sent' => $json_payload, 'raw' => mb_substr((string)$response, 0, 1000)],
], JSON_UNESCAPED_UNICODE);
exit;
}
$result = json_decode($response, true);
if (!$result) {
echo json_encode([
'status' => 0,
'msg' => 'API返回内容无法解析(非JSON)',
'debug' => ['json_sent' => $json_payload, 'raw' => mb_substr($response, 0, 1000)],
], JSON_UNESCAPED_UNICODE);
exit;
}
if (empty($result['success'])) {
echo json_encode([
'status' => 0,
'msg' => $result['msg'] ?? $result['message'] ?? 'API返回错误',
'debug' => ['json_sent' => $json_payload, 'api_result' => $result, 'raw' => mb_substr($response, 0, 1000)],
], JSON_UNESCAPED_UNICODE);
exit;
}
$api_data_resp = $result['data'] ?? [];
$persons = $api_data_resp['persons'] ?? [];
$goodDays = $api_data_resp['goodDays'] ?? [];
$range_labels = ['1month'=>'1个月内','3months'=>'3个月内','6months'=>'半年内','1year'=>'一年内'];
$build_bazi = function($p) {
$s = "姓名:" . ($p['name'] ?? '') . "\n";
$s .= "生日:" . ($p['birthday'] ?? '') . "\n";
$s .= "八字:" . ($p['bazi'] ?? '') . "\n";
$s .= "生肖:" . ($p['animal'] ?? '') . " 纳音:" . ($p['nayin'] ?? '') . "\n";
$s .= "避讳:冲" . ($p['avoid']['animal'] ?? '') . "(" . ($p['avoid']['zhi'] ?? '') . ")、煞" . ($p['avoid']['sha'] ?? '');
return $s;
};
if ($type_mode === 'boss') {
$query_info = [
'bossName' => htmlspecialchars($api_data['bossName']),
'bossBirthday' => $api_data['bossBirthday'] . ' ' . $api_data['bossHour'] . '时',
'weddingTime' => $range_labels[$api_data['range']] ?? '1个月内',
'boss_bazi' => !empty($persons[0]) ? $build_bazi($persons[0]) : '',
];
} elseif ($type_mode === 'traveler') {
$query_info = [
'travelerName' => htmlspecialchars($api_data['travelerName']),
'travelerBirthday' => $api_data['travelerBirthday'] . ' ' . $api_data['travelerHour'] . '时',
'weddingTime' => $range_labels[$api_data['range']] ?? '1个月内',
'traveler_bazi' => !empty($persons[0]) ? $build_bazi($persons[0]) : '',
];
} elseif ($type_mode === 'buyer') {
$query_info = [
'buyerName' => htmlspecialchars($api_data['buyerName']),
'buyerBirthday' => $api_data['buyerBirthday'] . ' ' . $api_data['buyerHour'] . '时',
'weddingTime' => $range_labels[$api_data['range']] ?? '1个月内',
'buyer_bazi' => !empty($persons[0]) ? $build_bazi($persons[0]) : '',
];
} elseif ($type_mode === 'owner') {
$owner_bazi = !empty($persons[0]) ? $build_bazi($persons[0]) : '';
$owner2_bazi = !empty($persons[1]) ? $build_bazi($persons[1]) : '';
$query_info = [
'ownerName' => htmlspecialchars($api_data['ownerName']),
'ownerBirthday' => $api_data['ownerBirthday'] . ' ' . $api_data['ownerHour'] . '时',
'owner2Name' => !empty($api_data['owner2Name']) ? htmlspecialchars($api_data['owner2Name']) : '',
'owner2Birthday' => !empty($api_data['owner2Birthday']) ? ($api_data['owner2Birthday'] . ' ' . ($api_data['owner2Hour'] ?? 0) . '时') : '',
'weddingTime' => $range_labels[$api_data['range']] ?? '1个月内',
'owner_bazi' => $owner_bazi,
'owner2_bazi' => $owner2_bazi,
];
} else {
$male_bazi = !empty($persons[0]) ? $build_bazi($persons[0]) : '';
$female_bazi = !empty($persons[1]) ? $build_bazi($persons[1]) : '';
$query_info = [
'maleName' => htmlspecialchars($api_data['maleName']),
'maleBirthday' => $api_data['maleBirthday'] . ' ' . $api_data['maleHour'] . '时',
'femaleName' => htmlspecialchars($api_data['femaleName']),
'femaleBirthday' => $api_data['femaleBirthday'] . ' ' . $api_data['femaleHour'] . '时',
'weddingTime' => $range_labels[$api_data['range']] ?? '1个月内',
'male_bazi' => $male_bazi,
'female_bazi' => $female_bazi,
];
}
$list = [];
foreach ($goodDays as $day) {
$lunar = $day['lunar'] ?? [];
$zhiShen = $day['zhiShen'] ?? [];
$star = $day['star'] ?? [];
$lunarStr = '农历' . ($lunar['lunarYear'] ?? '') . '年'
. intval($lunar['lunarMonth'] ?? 0) . '月'
. intval($lunar['lunarDay'] ?? 0) . '日';
$zhiShenName = $zhiShen['name'] ?? '';
$zhiShenType = $zhiShen['type'] ?? '';
$liyou = $zhiShenName . '(' . $zhiShenType . '吉日)';
$fangwei = $day['caishen'] ?? '';
$starName = $star['name'] ?? '';
$starDesc = $day['starDesc'] ?? '';
$xingsu = $starName . ($starDesc ? ':' . $starDesc : '');
$fenxi = $day['comment'] ?? '';
$list[] = [
'riqi' => $day['date'] . ' ' . $lunarStr,
'rating' => 5,
'liyou' => $liyou,
'fangwei' => $fangwei,
'xingsu' => $xingsu,
'fenxi' => $fenxi,
];
}
echo json_encode([
'status' => 1,
'data' => $list,
'query_info' => $query_info,
], JSON_UNESCAPED_UNICODE);
exit;
}
if (in_array($action, $jiri_actions)) {
$GLOBALS['jiri_page_key'] = $action;
$tpl = $template_path . $action . '.php';
if (!file_exists($tpl)) {
$tpl = $template_path . 'jiehun.php';
}
include $template_path . 'header.php';
include $tpl;
include $template_path . 'footer.php';
return true;
}
if ($action === 'search') {
$keyword = isset($_GET['keyword']) ? trim($_GET['keyword']) : '';
if (!empty($keyword)) {
if (!check_sensitive_words($keyword)) die('搜索内容包含敏感词');
$keyword = str_replace(['%', '_'], ['\\%', '\\_'], $keyword);
save_search_keyword($keyword);
$articles = get_articles("title LIKE '%" . $db->real_escape_string($keyword) . "%'", 50);
} else {
$articles = [];
}
$GLOBALS['jiri_page_key'] = 'list';
$GLOBALS['jiri_seo'] = get_seo('search', ['keyword' => htmlspecialchars($keyword)]);
include $template_path . 'header.php';
include $template_path . 'category.php';
include $template_path . 'footer.php';
return true;
}
if ($action === 'list') {
$page = isset($_GET['page']) ? max(1, intval($_GET['page'])) : 1;
$page_size = 20;
$total = get_article_count();
$offset = ($page - 1) * $page_size;
$articles = get_articles('', "$offset, $page_size");
$base_url = "/list.html?";
$pagination = pagination($total, $page_size, $page, $base_url);
$seo = get_seo('category', ['category_name' => '全部文章']);
$GLOBALS['jiri_page_key'] = 'list';
$GLOBALS['jiri_seo'] = $seo;
include $template_path . 'header.php';
include $template_path . 'category.php';
include $template_path . 'footer.php';
return true;
}
if ($action === 'category') {
$category_id = isset($_GET['id']) ? intval($_GET['id']) : 0;
$page = isset($_GET['page']) ? max(1, intval($_GET['page'])) : 1;
$page_size = 20;
$category_name = '';
$categories = get_categories();
foreach ($categories as $cat) {
if ($cat['id'] == $category_id) { $category_name = $cat['name']; break; }
}
if (!$category_name) {
http_response_code(404);
require_once ROOT_PATH . 'set/404.php';
exit;
}
$seo = get_seo('category', ['category_name' => $category_name]);
$where = "category_id = $category_id";
$total = get_article_count($where);
$offset = ($page - 1) * $page_size;
$articles = get_articles($where, "$offset, $page_size");
$base_url = "/" . ($setting['category_prefix'] ?? 'category-') . build_url_id('category', $category_id) . ".html?";
$pagination = pagination($total, $page_size, $page, $base_url);
$GLOBALS['jiri_page_key'] = 'list';
$GLOBALS['jiri_seo'] = $seo;
include $template_path . 'header.php';
include $template_path . 'category.php';
include $template_path . 'footer.php';
return true;
}
if ($action === 'article') {
$id = isset($_GET['id']) ? intval($_GET['id']) : 0;
$article = get_article($id);
if (!$article) {
http_response_code(404);
require_once ROOT_PATH . 'set/404.php';
exit;
}
update_views($id);
$category_name = '';
$categories = get_categories();
foreach ($categories as $cat) {
if ($cat['id'] == $article['category_id']) { $category_name = $cat['name']; break; }
}
$seo = get_seo('article', [
'article_title' => $article['title'],
'article_description' => $article['description'] ?: mb_substr(strip_tags($article['content']), 0, 150),
'category_name' => $category_name
]);
$GLOBALS['jiri_page_key'] = 'article';
$GLOBALS['jiri_seo'] = $seo;
include $template_path . 'header.php';
include $template_path . 'article.php';
include $template_path . 'footer.php';
return true;
}
if ($action === 'index') {
$GLOBALS['jiri_page_key'] = 'index';
$seo = get_seo('index');
$GLOBALS['jiri_seo'] = $seo;
$ads = get_ads(5);
$recommend_articles = get_articles('is_recommend = 1', $seo['recommend_count']);
$latest_articles = get_articles('', $seo['latest_count']);
$latest_searches = get_latest_search(5);
include $template_path . 'header.php';
include $template_path . 'index.php';
include $template_path . 'footer.php';
return true;
}
return false;
}
功能特色
十大吉日场景
结婚、订婚、开业、搬家、出行、动土、提车、装修、入宅、安门,一站式覆盖。
老黄历查询
内置独立老黄历页面,支持按日期翻页,展示宜忌、值神、星宿、时辰吉凶等完整信息。
AI 智能择吉
对接逗号API,根据生辰八字与黄历智能筛选,输出值神、星宿、评语多维度分析。
PC/手机自适应
一套模板自动适配各种屏幕尺寸,手机端时间范围两列排布,体验更佳。
红金喜庆主题
中国红 + 富贵金配色,配合楷体"囍/吉/日/良/辰/喜"大背景字,仪式感十足。
广告位支持
顶部横幅广告位,可在后台「广告管理 → 网站横幅」中配置图片/代码/文字广告。
双入口查询
每个吉日页面同时提供「立即查询」和「专业分析」双入口,满足不同用户需求。
页面列表
主题包含以下页面文件,全部位于 /templates/jiri/ 目录:
| 文件名 | 页面说明 | URL |
|---|---|---|
header.php | 公共头部(导航 + SEO) | - |
footer.php | 公共底部 | - |
index.php | 网站首页 | / |
jiehun.php | 结婚吉日查询 | /jiehun |
dinghun.php | 订婚吉日查询 | /dinghun |
kaiye.php | 开业吉日查询 | /kaiye |
banjia.php | 搬家吉日查询 | /banjia |
chuxing.php | 出行吉日查询 | /chuxing |
dongtu.php | 动土吉日查询 | /dongtu |
tiche.php | 提车吉日查询 | /tiche |
zhuangxiu.php | 装修吉日查询 | /zhuangxiu |
ruzhai.php | 入宅吉日查询 | /ruzhai |
anmen.php | 安门吉日查询 | /anmen |
laohuangli.php | 老黄历独立页面 | /laohuangli、/laohuangli/yyyy-mm-dd |
huangli_ajax.php | 老黄历 AJAX 接口 | /templates/jiri/huangli_ajax.php |
category.php | 文章分类列表页 | /list.html、/category-x.html |
article.php | 文章详情页 | /article-x.html |
其他资源
| 文件 | 说明 |
|---|---|
/templates/jiri/css/style.css | 主题全局样式 |
/templates/jiri/js/union.js | 第三方跳转公共逻辑 |
广告位配置
吉日主题中,所有页面顶部都调用了「网站横幅」广告位:
<!-- ========== 网站横幅 ========== -->
<div class="home-banner">
<?php echo get_ad_position('header_banner'); ?>
</div>
如何配置顶部横幅广告?
- 后台 → 内容管理 → 广告管理
- 找到 「网站横幅」 广告位,点击「广告设置」
- 点击「添加广告」,填写标题、选择投放页面(首页/分类页/文章详情/产品分类/产品详情)
- 选择广告模板(图片/代码/文字)
- 设置排序、状态(启用),保存
如需不同页面显示不同广告图,可在后台新增广告位,然后将对应的调用代码复制到相应页面的横幅区域即可。
更新日志
V1.4
新增自定义导航功能
2026-09-30
1、新增自定义导航2、新增联盟ID后台设置(在后台-网站设置 里设置)3、优化若干细节注意:升级此版本,必须是逗号CMS V7.0才可以哦。不是V7.0版本顶部导航会错误。
V1.3
新增功能及优化
2026-09-20
1、增加留言本路由,可以创建咨询老师等留言栏目(需要将版本更新至V6.7);2、底部文件增加后台备案号调用3、修复若干样式布局错位;
逗号CMS