改良: AndyGod
名稱: 完美版 RSS for D4.0
版本: 4.0.212
說明:
1.解決現時以知的所有 BUG
2.改用全 Cache 讀取, 不再需要浪費 SQL
花了很多時間來改良這個 rss.php, 最後用了 Discuz! 3 的方法解決!
Discuz! 3 的 rss 是實真的比 Discuz! 4 好很多!
修改後有出錯不用多問, 必定是有地方改錯了 "Orz
- # 打開 \include\cache.func.php
- #找 (不心改錯)
- writetocache($plugin['identifier'], '', "\$_DPLUGIN['$plugin[identifier]'] = ".arrayeval($data), 'plugin_');
- }
- }
- # 在下行加入
- # RSS Cache HACK ADD By: AndyGod
- if($cachename == 'rss') {
- $fids = 0;
- $forums = array(0 => array('fid' => '0'));
- $query = $db->query("SELECT f.fid, f.name, ff.viewperm FROM {$tablepre}forums f, {$tablepre}forumfields ff WHERE ff.fid=f.fid AND ff.password=''");
- while($forum = $db->fetch_array($query)) {
- if(empty($forum['viewperm']) || ($forum['viewperm'] && strstr($forum['viewperm'], "\t7\t"))) {
- $forum['name'] = strip_tags($forum['name']);
- $forums[0]['fid'] .= ','.$forum['fid'];
- $forums[] = $forum;
- }
- }
- foreach($forums as $forum) {
- $data = array('lastupdate' => $GLOBALS['timestamp'], 'xml' => '');
- $data['xml'] = "<?xml version="1.0" encoding="".$GLOBALS['charset'].""?>\n".
- "<rss version="2.0">\n".
- "<channel>\n".
- (is_numeric($forum['fid']) ?
- "<title>$GLOBALS[bbname] - $forum[name]</title>\n".
- "<link>$GLOBALS[boardurl]forumdisplay.php?fid=$forum[fid]</link>\n".
- "<description>Latest 20 threads of $forum[name]</description>\n"
- :
- "<title>$GLOBALS[bbname] - RSS by AndyGod</title>\n".
- "<link>$GLOBALS[boardurl]index.php</link>\n".
- "<description>Latest 20 threads of all forums</description>\n"
- ).
- "<copyright>Copyright(C) ".strip_tags($GLOBALS['bbname'])."</copyright>\n".
- "<generator>UNetBoard by Comsenz Technology Ltd</generator>\n".
- "<lastBuildDate>".gmdate('r', $GLOBALS['timestamp'])."</lastBuildDate>\n".
- "<ttl>10</ttl>\n".
- "<image>\n".
- "<url>$GLOBALS[boardurl]images/common/rss.gif</url>\n".
- "<title>".dhtmlspecialchars($GLOBALS['bbname'])."</title>\n".
- "<link>$GLOBALS[boardurl]</link>\n".
- "</image>\n";
- $query = $db->query("SELECT f.name AS forumname, t.tid, t.author, t.dateline, t.subject, t.replies, p.message FROM {$tablepre}threads t
- LEFT JOIN {$tablepre}posts p ON p.tid=t.tid AND p.dateline=t.dateline AND p.authorid=t.authorid
- LEFT JOIN {$tablepre}forums f ON f.fid=t.fid
- WHERE t.fid IN ($forum[fid]) AND t.displayorder>='0' AND t.readperm>=0
- ORDER BY t.dateline DESC LIMIT 20");
- while($thread = $db->fetch_array($query)) {
- $thread['message'] = preg_replace("/\[hide=?\d*\](.+?)\[\/hide\]/is", "**** Hidden message ****", $thread['message']);
- $data['xml'] .= "<item>\n".
- "<title>$thread[subject]</title>\n".
- "<link>$GLOBALS[boardurl]viewthread.php?tid=$thread[tid]</link>\n".
- "<description><![CDATA[" . nl2br( dhtmlspecialchars( cutstr( strip_tags($thread['message']), 1000) ) ) . "]]></description>\n".
- "<category>".strip_tags($thread['forumname'])."</category>\n".
- "<author>$thread[author]</author>\n".
- "<pubDate>".gmdate('r', $thread['dateline'])."</pubDate>\n".
- "</item>\n";
- }
- $data['xml'] .= "</channel>\n</rss>";
- writetocache(intval($forum['fid']), '', getcachevars($data), 'rss_');
- if($forum['fid'] == $GLOBALS['fid']) {
- $GLOBALS['xml'] = $data['xml'];
- }
- } while($forum = $db->fetch_array($query));
- }
- # RSS FIX HACK END
- # 注意, 加入後正常在 # RSS FIX HACK END 下行有一個 "}" 就沒改錯了
- # 再用 rss.rar 內的 rss.php 最代舊這個就可以
- # 完成 ^^
复制代码
[ 本帖最后由 AndyGod 于 2006-2-12 07:50 编辑 ] |