header("Content-type: text/xml");
header('HTTP/1.1 200 OK');
require 'zb_system/function/c_system_base.php';
global $zbp;
$zbp->host = 'http://' . $_SERVER['SERVER_NAME'] . '/';
$str = '<?xml version="1.0" encoding="UTF-8"?>';
$str .= '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:mobile="http://www.google.com/schemas/sitemap-mobile/1.0">';
if (!isset($_GET['index'])) {
$str .= '<url>';
$str .= '<loc>' . $zbp->host . '</loc>';
$str .= '<mobile:mobile type="pc,mobile"/>';
$str .= '<lastmod>' . date('Y-m-d', time()) . '</lastmod>';
$str .= '<changefreq>daily</changefreq>';
$str .= '<priority>1.0</priority>';
$str .= '</url>';
$allCats = $zbp->GetCategoryList();
foreach ($allCats as $cat) {
$str .= '<url>';
$str .= '<loc>' . $cat->Url . '</loc>';
// $str .= '<mobile:mobile type="pc,mobile"/>';
$str .= '<lastmod>' . date('Y-m-d', time()) . '</lastmod>';
$str .= '<changefreq>daily</changefreq>';
$str .= '<priority>0.8</priority>';
$str .= '</url>';
}
$allTags = $zbp->GetTagList();
foreach ($allTags as $tag) {
$str .= '<url>';
$str .= '<loc>' . $tag->Url . '</loc>';
// $str .= '<mobile:mobile type="pc,mobile"/>';
// $str .= '<lastmod>' . date('Y-m-d', time()) . '</lastmod>';
$str .= '<changefreq>weekly</changefreq>';
$str .= '<priority>0.6</priority>';
$str .= '</url>';
}
$allAuthors = $zbp->GetMemberList('*', array(array('>', 'mem_ID', 1), array('>', 'mem_Articles', 0)), array('mem_Level' => 'ASC'), 2000, null);
foreach ($allAuthors as $member) {
$str .= '<url>';
$str .= '<loc>' . $member->Url . '</loc>';
// $str .= '<mobile:mobile type="pc,mobile"/>';
// $str .= '<lastmod>' . date('Y-m-d', time()) . '</lastmod>';
$str .= '<changefreq>weekly</changefreq>';
$str .= '<priority>0.6</priority>';
$str .= '</url>';
}
} else {//文章
$index = $_GET['index'];
$db = $zbp->db->sql->get();
$sql = $db->select($zbp->table['Post'])->where(array('=', 'log_Status', '0'))->orderBy(array('log_PostTime' => 'DESC'))->limit(array(1000 * $index, 1000))->sql;
$array = $zbp->GetListType('Post', $sql);
foreach ($array as $post) {
$str .= '<url>';
$str .= '<loc>' . $post->Url . '</loc>';
// $str .= '<mobile:mobile type="pc,mobile"/>';
$str .= '<lastmod>' . $post->Time('Y-m-d') . '</lastmod>';
$str .= '<changefreq>monthly</changefreq>';
$str .= '<priority>0.4</priority>';
$str .= '</url>';
}
}
$str .= '</urlset>';
echo $str;
unset($str);
?>
sitemap,zlbog php 版本写法,美食汇网站地图,zblog版本,其他框架,请自行获取文章函数
nginx 重定向配置
rewrite ^/sitemap\.xml$ /sitemap.php last;