destoon8.0根据模块生成html地图,这样为了有利于收录。
在根目录新建个sitemaphtml.php
代码如下:
<?php
ini_set ('display_errors', 1);
ini_set ('error_reporting', E_USER_ERROR);
ini_set ('error_reporting', E_ALL);
require './common.inc.php';
$mid=$_GET['mid'];
$geturl=$MODULE[1]['linkurl'];
$module = $MODULE[$mid]['module'];
$modurl = $MODULE[$mid]['linkurl'];
if($mid==2){
$modulename="热门搜索";
$moddir="hotkey";
}else{
$modulename=$MODULE[$mid]['name'];
$moddir=$MODULE[$mid]['moduledir'];
}
$table = get_table($mid);
$condition = "status=3";
$page=$_GET['page'];
$total=$page*3000;
$data.="<!DOCTYPE html>";
$data.="<html lang='zh-CN'>";
$data.='<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />';
// 添加视口设置以支持移动端自适应
$data.='<meta name="viewport" content="width=device-width, initial-scale=1.0">';
$data.="<head>";
$data.= '<title>'.$DT[sitename]."-".$modulename."模块-第".$page."页地图".'</title>';
$data.= "<style type='text/css'>
/* 基础样式重置 */
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
font-family: 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
font-size: 16px;
line-height: 1.6;
color: #333;
background-color: #f8f9fa;
padding: 20px 0;
}
/* 容器样式 */
.container {
max-width: 1200px;
margin: 0 auto;
padding: 0 20px;
}
/* 标题样式 */
h1, h2, h3 {
color: #2c3e50;
margin-bottom: 20px;
text-align: center;
}
h2 {
font-size: 2rem;
margin: 30px 0;
position: relative;
padding-bottom: 15px;
}
h2:after {
content: '';
position: absolute;
bottom: 0;
left: 50%;
transform: translateX(-50%);
width: 80px;
height: 3px;
background-color: #3498db;
}
h3 {
font-size: 1.5rem;
text-align: left;
margin: 30px 0 20px;
padding-left: 15px;
border-left: 4px solid #3498db;
}
/* 内容区域样式 */
#content {
background-color: #fff;
border-radius: 8px;
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
padding: 30px;
margin-top: 20px;
}
/* 列表样式 */
ul {
list-style: none;
display: grid;
grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
gap: 15px;
}
li {
margin: 0;
transition: transform 0.2s ease;
}
li:hover {
transform: translateY(-3px);
}
/* 链接样式 */
a {
text-decoration: none;
color: #3498db;
display: block;
padding: 10px 15px;
background-color: #f9f9f9;
border-radius: 4px;
transition: all 0.3s ease;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
a:hover {
color: #2980b9;
background-color: #f0f7ff;
box-shadow: 0 2px 8px rgba(52, 152, 219, 0.15);
}
/* 分页导航 */
.pagination {
margin: 40px 0;
text-align: center;
}
.pagination a {
display: inline-block;
padding: 8px 16px;
margin: 0 5px;
background-color: #fff;
border: 1px solid #ddd;
border-radius: 4px;
}
.pagination a.active {
background-color: #3498db;
color: white;
border-color: #3498db;
}
/* 响应式调整 */
@media (max-width: 768px) {
ul {
grid-template-columns: 1fr;
}
h2 {
font-size: 1.5rem;
}
h3 {
font-size: 1.2rem;
}
#content {
padding: 20px 15px;
}
}
</style>";
$data.="</head>";
$data.="<body>";
$data.="<div class='container'>";
$data.="<h2>".$modulename."站点地图</h2>";
$data.="<div id='content'>";
$data.="<h3>".$modulename."sitemap</h3>";
$data.="<ul>";
if($mid==4){
$result = $db->query("SELECT linkurl,company from {$table} where userid>$total ORDER BY userid ASC LIMIT 0,3000");
while($r = $db->fetch_array($result)) {
$url="<li><a href='".$r['linkurl']."'>".$r['company']."</a></li>";
$data.=$url;
}
}
else if($mid==2){
$result = $db->query("SELECT itemid,word from ktcms_keyword where itemid>$total ORDER BY itemid ASC LIMIT 0,3000");
while($r = $db->fetch_array($result)) {
$url="<li><a href='".$geturl."s-".$r['itemid']."/'>".$r['word']."</a></li>";
$data.=$url;
}
}
else{
$result = $db->query("SELECT linkurl,title from {$table} where itemid>$total ORDER BY itemid ASC LIMIT 0,3000");
while($r = $db->fetch_array($result)) {
$url="<li><a href='".$modurl.$r['linkurl']."'>".$r['title']."</a></li>";
$data.=$url;
}
}
$data.="</ul>";
$data.="<div class='pagination'>";
if($page!=0){
$data.="<a href='{$geturl}sitemap/html/sitemap{$moddir}".($page-1).".html'>上一页</a>";
}
$data.="<a href='{$geturl}sitemap/html/sitemap{$moddir}".($page+1).".html'>下一页</a>";
$data.="</div>";
$data.="</div>";
$data.="</div>";
$data.="</body>";
if(!empty($url)){
$file = './sitemap/html';
if (file_exists($file)) {
file_put_contents('./sitemap/html/sitemap'.$moddir.$page.'.html', $data);
echo "地图生成成功!";
}else {
$dir = "./sitemap/html";
mkdir($dir, 0777, true);
file_put_contents('./sitemap/html/sitemap'.$moddir.$page.'.html', $data);
echo "地图生成成功!";
}
}else{
echo "页数超出,生成失败";
}
?>
执行参数为:sitemaphtml.php?mid=21&page=1
效果如下:
找校通-学校大全模块-第1页地图http://www.6983.net/sitemap/html/sitemapcompany1.html