测算联盟版 主题说明
简介:专为测算类网站打造的全功能联盟主题,内置 19 个测算项目,全部对接伍柒联盟(union.632757.com),自带高转化跳转与收益分成,开箱即用。用户付款后站长直接在联盟提现。整站采用红色联盟风配色,搭配中国风的顶部横幅与金色按钮,突出测算娱乐感与信任感。
主题截图
首页截图
测算页面截图
未命名
文章页截图
移动端首页
移动端测算页
安装方法
- 下载逗号CMS → 登录后台 → 主题管理 → 主题列表,找到「测算联盟版主题模板」主题,点击免费安装。
- 进入 后台 → 网站设置 → 顶部导航,配置顶部导航及链接(测算栏目顶部模板自带,若需要修改在header.php文件中修改)。
- 进入 后台 → 网站设置 → 联盟ID,配置您的联盟收款ID。
- 进入 后台 → 网站设置 → 参数设置,配置首页、分类页、文章页的文章显示数量。(测算页右侧调用的文章需要自行到文章管理中去添加,分类都是一一对应好的,请勿删除。)
- 进入网站设置 → SEO 设置,配置首页、文章分类列表页、文章详情页的 SEO 信息。测算页面在管理 → 前端路由管理 → 修改SEO信息
重要提醒:本主题的测算功能全部跳转至伍柒联盟,若想要站内版,请耐心等待,后期将会推出。
功能特色
19个测算项目
缘份测试、流年运程、八字合婚、八字精批、姓名详批、宝宝起名、六道轮回、事业测算等热门项目全覆盖。
联盟跳转收益
所有测算按钮对接第三方测算联盟,只需配置联盟 ID,所有收益直接进入您的账户。
PC/手机自适应
一套模板自动适配各种屏幕尺寸,手机端表单纵向排列,按钮加大更易点击。
红色联盟风配色
中国红主色调,搭配金色发光按钮和跑马灯声明,营造测算类网站特有的信任感。
一键提交跳转
表单提交后自动拼接联盟参数跳转第三方,用户无感知,转化路径短。
防重复提交
表单带锁定机制,防止用户连续点击重复提交,减轻服务器压力。
页面列表
主题包含以下页面文件,全部位于 /templates/cesuan/ 目录:
| 文件名 | 页面说明 | URL |
|---|---|---|
header.php | 公共头部(导航 + SEO) | - |
footer.php | 公共底部 | - |
index.php | 网站首页(测算项目聚合 + 文章) | / |
aiqingddp.php | 缘份测试 | /aiqingddp |
liunian.php | 流年运程 | /liunian |
bazihehun.php | 八字合婚 | /bazihehun |
baobaoqm.php | 宝宝起名 | /baobaoqm |
liudaolunhui.php | 六道轮回 | /liudaolunhui |
shiniandy.php | 十年大运 | /shiniandy |
bazicy.php | 八字财运 | /bazicy |
yunyincs.php | 个人姻缘 | /yunyincs |
bazijingpi.php | 八字精批 | /bazijingpi |
taohua.php | 测桃花运 | /taohua |
bzzsy.php | 测终生运 | /bzzsy |
shengxiao.php | 生肖运势 | /shengxiao |
bazisyy.php | 事业测算 | /bazisyy |
gerenzhanxing.php | 个人占星 | /gerenzhanxing |
jieming.php | 姓名详批 | /jieming |
ziweidoushu.php | 紫微命格 | /ziweidoushu |
xzhepanpeidui.php | 星座配对 | /xzhepanpeidui |
xmpd.php | 姓名配对 | /xmpd |
haomajixiong.php | 号码吉凶 | /haomajixiong |
category.php | 文章分类列表页 / 搜索页 | /list.html、/category-x.html |
article.php | 文章详情页 | /article-x.html |
search_rs.php | 热搜标签聚合页 | /rs |
route.php | 主题路由文件 | - |
upgrade.php | 主题安装脚本(自动删除) | - |
其他资源
| 文件 | 说明 |
|---|---|
/templates/cesuan/css/style.css | 主题全局样式 |
/templates/cesuan/css/aiqingddp.css | 缘份测试页专属样式 |
/templates/cesuan/css/baobaoqm.css | 宝宝起名页专属样式 |
/templates/cesuan/img/union.js | 第三方跳转公共逻辑 |
配置 API
前端路由规则
<?php
function parse_rewrite_url($uri, $setting, $db, $prefix) {
if ($uri === '/aiqingddp' || $uri === '/aiqingddp/') return 'cesuan_aiqingddp';
if ($uri === '/liunian' || $uri === '/liunian/') return 'cesuan_liunian';
if ($uri === '/liudaolunhui' || $uri === '/liudaolunhui/') return 'cesuan_liudaolunhui';
if ($uri === '/shiniandy' || $uri === '/shiniandy/') return 'cesuan_shiniandy';
if ($uri === '/bazihehun' || $uri === '/bazihehun/') return 'cesuan_bazihehun';
if ($uri === '/bazicy' || $uri === '/bazicy/') return 'cesuan_bazicy';
if ($uri === '/yunyincs' || $uri === '/yunyincs/') return 'cesuan_yunyincs';
if ($uri === '/bazijingpi' || $uri === '/bazijingpi/') return 'cesuan_bazijingpi';
if ($uri === '/taohua' || $uri === '/taohua/') return 'cesuan_taohua';
if ($uri === '/bzzsy' || $uri === '/bzzsy/') return 'cesuan_bzzsy';
if ($uri === '/shengxiao' || $uri === '/shengxiao/') return 'cesuan_shengxiao';
if ($uri === '/baobaoqm' || $uri === '/baobaoqm/') return 'cesuan_baobaoqm';
if ($uri === '/bazisyy' || $uri === '/bazisyy/') return 'cesuan_bazisyy';
if ($uri === '/gerenzhanxing' || $uri === '/gerenzhanxing/') return 'cesuan_gerenzhanxing';
if ($uri === '/jieming' || $uri === '/jieming/') return 'cesuan_jieming';
if ($uri === '/ziweidoushu' || $uri === '/ziweidoushu/') return 'cesuan_ziweidoushu';
if ($uri === '/xzhepanpeidui' || $uri === '/xzhepanpeidui/') return 'cesuan_xzhepanpeidui';
if ($uri === '/xmpd' || $uri === '/xmpd/') return 'cesuan_xmpd';
if ($uri === '/haomajixiong' || $uri === '/haomajixiong/') return 'cesuan_haomajixiong';
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'; }
if ($uri === '/rs' || $uri === '/rs/') return 'search_rs_index';
if (preg_match('/^\/rs\/(.+?)\/?$/', $uri, $matches)) { $keyword = urldecode($matches[1]); $keyword = trim($keyword); if ($keyword !== '') { $_GET['keyword'] = $keyword; return 'search'; } }
$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) { $_GET['id'] = $res->fetch_assoc()['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) { $_GET['id'] = $res->fetch_assoc()['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) { $_GET['id'] = $res->fetch_assoc()['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) { $_GET['id'] = $res->fetch_assoc()['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; }
if (strpos($action, 'cesuan_') === 0) {
$site_name = $setting['site_name'] ?? '在线测算';
$map = [
'cesuan_yuanfencs' => [
'缘份测试_姓名缘分在线测算_缘分指数查询',
'缘份测试,缘分测试,测缘分,姓名缘分测试,缘分指数,在线缘分测试',
'缘份测试在线免费测算,输入双方姓名即可测试你和TA的缘分深浅,分析缘分指数、相处契合度。'
],
'cesuan_aiqingddp' => [
'爱情配对_情侣姓名配对测试_爱情契合度在线测算',
'爱情配对,情侣配对,姓名配对,爱情测试,缘分测试,在线爱情测试',
'爱情配对在线测算,根据双方姓名与出生日期分析你们的爱情契合度、相处模式与情感走向。'
],
'cesuan_liunian' => [
'流年运程_2027流年运势在线测算_年度运势查询',
'流年运程,流年运势,2027流年运程,流年运势测算,年度运势,在线流年运程',
'流年运程在线测算,结合出生信息分析你当年的整体运势、事业、财运、感情与健康走向,助你提前规划。'
],
'cesuan_liudaolunhui' => [
'六道轮回_前世今生测试_前世身份在线查询',
'六道轮回,前世今生,前世测试,轮回测试,前世身份,在线六道轮回',
'六道轮回在线测算,探索你的前世今生,分析前世身份、因果牵绊与今生课题。'
],
'cesuan_shiniandy' => [
'十年大运_未来十年运势测算_人生大运在线查询',
'十年大运,大运测算,十年运势,人生大运,大运流年,在线十年大运',
'十年大运在线测算,分析你未来十年的大运走势、吉凶祸福与关键转折点,帮助你把握人生节奏。'
],
'cesuan_bazihehun' => [
'八字合婚_生辰八字合婚测试_男女婚姻配对在线测算',
'八字合婚,合婚测试,生辰八字合婚,男女合婚,婚姻配对,在线八字合婚',
'八字合婚在线测算,根据男女双方出生信息分析八字匹配度、婚姻契合度与相处建议。'
],
'cesuan_bazicy' => [
'八字财运_八字看财运_求财方向在线测算',
'八字财运,财运测算,八字看财运,财运分析,发财方向,在线八字财运',
'八字财运在线测算,分析你的财运格局、求财方向、财富积累节奏与理财建议。'
],
'cesuan_yunyincs' => [
'个人姻缘_姻缘测算_正缘出现时间在线查询',
'个人姻缘,姻缘测算,姻缘分析,婚姻运势,正缘时间,在线姻缘测算',
'个人姻缘在线测算,分析你的姻缘走势、正缘出现时间、感情特点与婚姻建议。'
],
'cesuan_bazijingpi' => [
'八字精批_生辰八字详解_四柱八字在线测算',
'八字精批,八字测算,生辰八字,八字分析,四柱八字,在线八字精批',
'八字精批在线测算,全面分析你的性格特点、事业财运、婚姻感情与健康走势。'
],
'cesuan_taohua' => [
'测桃花运_正缘桃花测试_桃花运势在线查询',
'测桃花运,桃花运测试,正缘桃花,桃花运势,姻缘桃花,在线测桃花运',
'测桃花运在线测算,分析你的桃花运势、正缘桃花出现时机与感情发展走向。'
],
'cesuan_bzzsy' => [
'测终生运_一生运势测算_人生运势在线查询',
'测终生运,终生运势,一生运势,命运测算,人生运势,在线测终生运',
'测终生运在线测算,综合分析你一生的运势走向、事业财富、婚姻家庭与健康走势。'
],
'cesuan_shengxiao' => [
'生肖运程_十二生肖运势_属相运程在线测算',
'生肖运程,生肖运势,十二生肖运程,生肖测算,属相运势,在线生肖运程',
'生肖运程在线测算,结合生肖与出生信息分析你当年的运势走势、事业财运与感情健康。'
],
'cesuan_baobaoqm' => [
'宝宝起名_宝宝取名_免费起名字',
'宝宝起名,宝宝取名,姓名测试,取名测名,名字吉凶,在线起名改名',
'宝宝起名,结合生辰八字与五行分析名字吉凶,提供宝宝取名建议。'
],
'cesuan_bazisyy' => [
'事业测算_八字看事业_职业方向在线查询',
'事业测算,八字看事业,事业运势,职业方向,事业财运,在线事业测算',
'事业测算在线测算,分析你的事业格局、适合的职业方向、事业发展节奏与贵人运势。'
],
'cesuan_pibazi' => [
'八字详批_生辰八字详解_四柱命理在线测算',
'八字详批,八字详解,生辰八字详批,四柱详批,八字命理,在线八字详批',
'八字详批在线测算,逐柱分析你的八字命理,涵盖性格、事业、财运、婚姻与健康。'
],
'cesuan_gerenzhanxing' => [
'个人占星_个人星盘分析_星座运势在线测算',
'个人占星,占星测算,星盘分析,星座运势,个人星盘,在线个人占星',
'个人占星在线测算,结合出生信息分析你的星盘格局、性格特质、情感模式与人生方向。'
],
'cesuan_jieming' => [
'姓名详批_姓名吉凶测试_名字五行在线分析',
'姓名详批,姓名测算,名字吉凶,姓名分析,起名测名,在线姓名详批',
'姓名详批在线测算,分析姓氏与名字的五行、数理与寓意,解读姓名对事业、财运与感情的影响。'
],
'cesuan_ziweidoushu' => [
'紫微命格_紫微斗数排盘_命格格局在线测算',
'紫微命格,紫微斗数,紫微排盘,命格测算,紫微命盘,在线紫微命格',
'紫微命格在线测算,通过紫微斗数排盘分析你的命格格局、事业财运与人生走势。'
],
'cesuan_xzhepanpeidui' => [
'星座配对_十二星座爱情配对_星座契合度查询',
'星座配对,十二星座配对,星座契合度,星座爱情,星座缘分,在线星座配对',
'星座配对在线测算,分析十二星座之间的爱情契合度、相处模式与感情走向。'
],
'cesuan_xmpd' => [
'姓名配对_姓名缘分测试_名字契合度在线查询',
'姓名配对,姓名缘分,名字配对,姓名测试,缘分指数,在线姓名配对',
'姓名配对在线测算,通过双方姓名笔画与五行分析缘分深浅、相处契合度与感情走向。'
],
'cesuan_haomajixiong' => [
'号码吉凶_手机号码测吉凶_数字吉凶在线查询',
'号码吉凶,手机号码测吉凶,手机号吉凶,号码测算,数字吉凶,在线号码吉凶',
'号码吉凶在线测算,分析手机号码的数理组合与吉凶寓意,解读号码对运势的影响。'
],
];
$info = $map[$action] ?? ['在线测算', '在线测算'];
$seo = [
'title' => $info[0] . ' - ' . $site_name,
'keywords' => $info[1],
'description' => $info[1],
];
$key = substr($action, 7);
$GLOBALS['__page_css'] = '/templates/cesuan/css/' . $key . '.css';
include $template_path . 'header.php';
include $template_path . $key . '.php';
include $template_path . 'footer.php';
return true;
}
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'] ?? '在线测算';
$seo = $seo_row ? ['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'])] : ['title' => '留言本 - ' . $site_name, 'keywords' => '留言本', 'description' => '在线留言'];
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'] ?? '在线测算';
$seo = ['title' => ($page_info_row['name'] ?? '留言页') . ' - ' . $site_name, 'keywords' => $page_info_row['name'] ?? '', 'description' => $page_info_row['description'] ?? ''];
include $template_path . 'header.php';
require ROOT_PATH . 'set/ubb/page.php';
include $template_path . 'footer.php';
return true;
}
if ($action === 'search_rs_index') {
$site_name = $setting['site_name'] ?? '在线测算';
$seo_row = $db->query("SELECT * FROM {$prefix}seo WHERE page_name = 'search_rs_index' LIMIT 1")->fetch_assoc();
$seo = $seo_row ? ['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'])] : ['title' => '热搜标签 - ' . $site_name, 'keywords' => '热搜', 'description' => '热搜标签'];
include $template_path . 'header.php';
include $template_path . 'search_rs.php';
include $template_path . 'footer.php';
return true;
}
if ($action === 'search') {
$_GET['action'] = 'search';
$keyword = isset($_GET['keyword']) ? trim($_GET['keyword']) : '';
$keyword_display = $keyword;
if (!empty($keyword)) {
if (!check_sensitive_words($keyword)) { http_response_code(404); require_once ROOT_PATH . 'set/404.php'; exit; }
record_hot_search($keyword);
$keyword_escaped = str_replace(['%', '_'], ['\\%', '\\_'], $keyword);
save_search_keyword($keyword_escaped);
$keywords = split_search_keywords_by_api($keyword);
if (empty($keywords)) $keywords = split_search_keywords($keyword);
$page = isset($_GET['page']) ? max(1, intval($_GET['page'])) : 1;
$page_size = 20;
$search_result = search_articles_by_keywords($keywords, $page, $page_size);
$articles = $search_result['articles'];
$total = $search_result['total'];
$base_url = "/rs/" . rawurlencode($keyword) . "?";
$pagination = pagination($total, $page_size, $page, $base_url);
} else { $articles = []; $total = 0; $pagination = ''; $search_result = ['keywords' => []]; }
$seo = get_seo('search', ['keyword' => $keyword_display]);
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' => '全部文章']);
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 = '';
foreach (get_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);
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 = '';
foreach (get_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]);
include $template_path . 'header.php';
include $template_path . 'article.php';
include $template_path . 'footer.php';
return true;
}
if ($action === 'product_list') {
$category_id = isset($_GET['id']) ? intval($_GET['id']) : 0;
$page = isset($_GET['page']) ? max(1, intval($_GET['page'])) : 1;
$page_size = 12;
$category_name = '全部产品';
if ($category_id > 0) { $cats = $db->query("SELECT * FROM {$prefix}product_category ORDER BY sort ASC"); while ($cat = $cats->fetch_assoc()) { if ($cat['id'] == $category_id) { $category_name = $cat['name']; break; } } }
$seo = get_seo('product_list', ['category_name' => $category_name]);
if ($category_id > 0) { $where = "WHERE category_id = $category_id"; $total = $db->query("SELECT COUNT(*) as t FROM {$prefix}product $where")->fetch_assoc()['t']; }
else { $where = ''; $total = $db->query("SELECT COUNT(*) as t FROM {$prefix}product")->fetch_assoc()['t']; }
$offset = ($page - 1) * $page_size;
$products = $db->query("SELECT * FROM {$prefix}product $where ORDER BY id DESC LIMIT $offset, $page_size");
$product_cats = $db->query("SELECT * FROM {$prefix}product_category ORDER BY sort ASC");
include $template_path . 'header.php';
include $template_path . 'product_list.php';
include $template_path . 'footer.php';
return true;
}
if ($action === 'product_detail') {
$id = isset($_GET['id']) ? intval($_GET['id']) : 0;
$product = $db->query("SELECT p.*, c.name as category_name FROM {$prefix}product p LEFT JOIN {$prefix}product_category c ON p.category_id = c.id WHERE p.id = $id")->fetch_assoc();
if (!$product) { http_response_code(404); require_once ROOT_PATH . '/set/404.php'; exit; }
$db->query("UPDATE {$prefix}product SET views = views + 1 WHERE id = $id");
$gallery = json_decode($product['gallery'], true);
if (!is_array($gallery)) $gallery = [];
$seo = get_seo('product_detail', ['product_title' => $product['title'], 'product_description' => $product['description'], 'category_name' => $product['category_name'] ?? '']);
include $template_path . 'header.php';
include $template_path . 'product_detail.php';
include $template_path . 'footer.php';
return true;
}
if ($action === 'index') {
$seo = get_seo('index');
$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;
}
逗号CMS