require_once $_SERVER['DOCUMENT_ROOT'] . '/php/coon.php';
//服务
$url = 'https://你的域名/';
$cs = '.html';
$txt3 = $url.'service';
$url1 = array();
//修改成你的数据库没有分类的生成
$rs = $pdo->query("select * from web_txt where nav = 7 or nav = 9 or nav = 11 or nav = 12 ");
$t1 = 0;
while ($row = $rs->fetch()) {
$url1[$t1] = $txt3.$row['id'].$cs;
$t1++;
}
//第二个表有分类的列表页生成
$txt9 = $url.'page';
$rs4 = $pdo->query("select * from web_news_left order by orders desc,id desc");
$n=10;
while ($row4 = $rs4->fetch()) {
$url1[$t1] = $txt9.$n.$cs;
if($n == 10){
$url1[$t1] = $txt9.'4'.$cs;
}
$t1++;
$n++;
}
//第三个表有分类的详细页生成
$txt10 = $url.'news';
$rs5 = $pdo->query("select * from web_news order by id desc");
while ($row5 = $rs5->fetch()) {
$url1[$t1] = $txt10.$row5['id'].$cs;
$t1++;
}
//其他单页面生成
$url1[$t1] = $url.'index.html';
$t1++;
$url1[$t1] = $url.'page1.html';
$t1++;
$url1[$t1] = $url.'page6.html';
$t1++;
$url1[$t1] = $url.'page5.html';
$t1++;
$url1[$t1] = $url.'page3.html';
//将所有数据生成sitemap
$content='<?xml version="1.0" encoding="UTF-8"?>
xmlns:mobile="http://www.baidu.com/schemas/sitemap-mobile/1/">';
$num = count($url1);
for($i=0; $i
$content.="
";
$content.="".$url1[$i]."
";
//电脑站的标识 手机站为$content.='';
$content.='';
$content.="
";
}
$content.='
';$fp=fopen('../sitemap.xml','w+');
fwrite($fp,$content);
fclose($fp);
echo '生成PC Sitemap.xml 成功
';