码迷,mamicode.com
首页 > Web开发 > 详细

discuz sitemap生成代码

时间:2015-07-13 11:42:25      阅读:742      评论:0      收藏:0      [点我收藏+]

标签:

<?php

/*
 *    $ cron_sitemap.php  2012-5-28  网站地图 计划任务版www.zhixiaotang.com
 */

if(!defined(‘IN_DISCUZ‘)) {
    exit(‘Access Denied‘);
}

$filename=‘sitemap.xml‘;
//以下五项根据具体情况修改即可
$cfg_updateperi=‘60‘;//协议文件更新周期的上限,单位为分钟
$web_root=$_G[‘siteurl‘];//根网址
$CHARSET=‘gbk‘;// or utf-8 //选择编码方式
/***********************************************************************************************/
//网站地图sitemap.xml
$sitemap="<?xml version=\"1.0\" encoding=\"gb2312\"?>\n";
$sitemap.="<urlset\n";
$sitemap.="xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\"\n";
$sitemap.="xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n";
$sitemap.="xsi:schemaLocation=\"http://www.sitemaps.org/schemas/sitemap/0.9\n";
$sitemap.="http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd\">\n";
    $querys = DB::query("SELECT a.tid FROM ".DB::table(‘forum_thread‘)." a inner join ".DB::table(‘forum_forum‘)." b on a.fid=b.fid ORDER BY a.tid DESC  LIMIT 0,10000");
    while($threadfid = DB::fetch($querys))
    {
        $turl=$web_root.‘thread-‘.$threadfid[‘tid‘].‘-1-1.html‘;//注意静态规则
        $link = $turl;
        $t=time();
        $riqi=date("Y-m-d",$t);
        $priority=rand(1,10)/10;
//date("D F d Y",$t);
$sitemap.="<url>\n";
$sitemap.="<loc>$link</loc>\n";
$sitemap.="<priority>$priority</priority>\n";
$sitemap.="<lastmod>$riqi</lastmod>\n";
$sitemap.="<changefreq>weekly</changefreq>\n";
$sitemap.="</url>\n";
    }
    $sitemap .= "</urlset>\n";
    $fp = fopen(DISCUZ_ROOT.‘/‘.$filename,‘w‘);
    fwrite($fp,$sitemap);
    fclose($fp);
?>

 

网页版

<?php
/*ÍøÕ¾µØͼ ÍøÒ³°æ GBK±àÂë*/
define(‘APPTYPEID‘, 127);
define(‘CURSCRIPT‘, ‘sitemap‘);
require ‘./source/class/class_core.php‘;
$discuz = & discuz_core::instance();
$discuz->cachelist = $cachelist;
$discuz->init();
$urlnum=100;//ÍøÖ·Êý
$navtitle=‘ÍøÕ¾µØͼ‘;
$metakeywords=$_G[‘seokeywords‘][‘forum‘];
$metadescription=$_G[‘bbname‘].$_G[‘seodescription‘][‘forum‘];
include template(‘common/header‘);
echo ‘<div style="height:1400px">‘;
echo ‘<style type="text/css">.newtid{width:100%;float:left}.newtid li{padding-left:2%;font-size: 14px;width:48%;float:left;line-height: 25px;}.newtid li a{color: #036;}.newtit strong a{position: absolute;bottom: 98765px;}.newtid h2{font-size: 16px;line-height: 45px;}</style><h2 class="newtit"><a href="">×îз¢±íµÄÌû×Ó:</a></h2><ul class="newtid">‘;
$querys = DB::query("SELECT a.tid,a.subject,a.fid,b.name FROM ".DB::table(‘forum_thread‘)." a inner join ".DB::table(‘forum_forum‘)." b on a.fid=b.fid where a.displayorder!=-2 ORDER BY a.tid DESC  LIMIT 0,$urlnum");
$i=0;while($threadfid = DB::fetch($querys))
    {$i++;
    echo ‘<li class="newsitemap">‘.$i.‘¡¢<a href="forum.php?mod=forumdisplay&fid=‘.$threadfid[‘fid‘].‘" title="‘.$threadfid[‘name‘].‘" target="_blank">[‘.$threadfid[‘name‘].‘]</a> <a href="forum.php?mod=viewthread&tid=‘.$threadfid[‘tid‘].‘" target="_blank" title="‘.$threadfid[‘subject‘].‘">‘.$threadfid[‘subject‘].‘</a></li>‘;
    }
echo ‘</ul>‘;
echo ‘</div>‘;
    include template(‘common/footer‘);
?>

 

discuz sitemap生成代码

标签:

原文地址:http://www.cnblogs.com/LoveJulin/p/4642329.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!