专注于高品质PHP技术等信息服务于一体 [STIEMAP] [RSS]

百度提供的广告:
PHP
当前位置:首页 > 技术文档 > PHP >  > 
dedecms 生成整站RSS
dedecms 中的 RSS 是针对每个栏目生成的RSS ,现在多是一个网站只需要一个 RSS 订阅,下面介绍如何修改源码,完成生成整站的RSS 功能。
测试版本DEDECMS V5.7 UTF-8 版
修改 DEDE 管理员目录下的 makehtml_rss_action.php
修改具体代码如下:
<?php
require_once(dirname(__FILE__)."/config.php");
CheckPurview('sys_MakeHtml');
require_once(DEDEINC."/arc.rssview.class.php");
$isremote = empty($isremote)? 0 : $isremote;
$serviterm = empty($serviterm)? "" : $serviterm;

if(empty($tid)) $tid = 0;
if(empty($maxrecord)) $maxrecord = 50;
$rv = new RssView(1,$maxrecord);
$rssurl = $rv->MakeRss($isremote);
echo "完成所有文件更新!";
exit();

include / arc.rssview.class.php
    /**
     *  开始创建列表
     *
     * @access    public
     * @param     string  $isremote  是否远程
     * @return    string
     */
    function MakeRss($isremote=0)
    {
        global $cfg_remote_site;
        //$murl = $GLOBALS['cfg_cmspath']."/data/rss/".$this->TypeID.".xml";
        $murl = $GLOBALS['cfg_cmspath'].'/rss.xml'; // 重新给出生成路径
        $mfile = $GLOBALS['cfg_basedir'].$murl;
        $this->dtp->SaveTo($mfile);
        //如果启用远程站点则上传
        if($cfg_remote_site=='Y' && $isremote == 1)
        {
            //分析远程文件路径
            $remotefile = $murl;
            $localfile = '..'.$remotefile;
            $remotedir = preg_replace('/[^\/]*\.xml/', '',$remotefile);
            //不相等则说明已经切换目录则可以创建镜像
            $this->ftp->rmkdir($remotedir);
            $this->ftp->upload($localfile, $remotefile, 'acii');
        }
        return $murl;
    }

    /**
     *  获得文档列表
     *
     * @access    public
     * @param     string  $innertext  底层模板
     * @return    string
     */
    function GetArcList($innertext="")
    {
        $typeid=$this->TypeID;
        $innertext = trim($innertext);
        if($innertext=="")
        {
            $innertext = GetSysTemplets("rss.htm");
        }
        $orwhere = " arc.arcrank > -1 ";
        //$orwhere .= " AND (arc.typeid in (".GetSonIds($this->TypeID,$this->TypeFields['channeltype']).") ) "; //  去掉where条件
        $ordersql=" ORDER BY arc.id desc";
生成一下OK 了,测试地址:http://www.qingruxu.com/rss.xml