updatersscache($num); break; } else { list($thread['description'], $attachremote, $attachfile, $attachsize) = explode("\t", $thread['description']); if ($attachfile) { if ($attachremote) { $filename = $_G['setting']['ftp']['attachurl'] . 'forum/' . $attachfile; } else { $filename = $_G['siteurl'] . $_G['setting']['attachurl'] . 'forum/' . $attachfile; } } echo " <item>\n" . " <title>" . $thread['subject'] . "</title>\n" . " <link>{$_G['siteurl']}" . ($trewriteflag ? rewriteoutput('forum_viewthread', 1, '', $thread['tid']) : "forum.php?mod=viewthread&tid={$thread['tid']}") . "</link>\n" . " <description><![CDATA[" . dhtmlspecialchars($thread['description']) . "]]></description>\n" . " <category>" . dhtmlspecialchars($thread['forum']) . "</category>\n" . " <author>" . dhtmlspecialchars($thread['author']) . "</author>\n" . ($attachfile ? '<enclosure url="' . $filename . '" length="' . $attachsize . '" type="image/jpeg" />' : '') . " <pubDate>" . gmdate('r', $thread['dateline']) . "</pubDate>\n" . " </item>\n"; } } } else { updatersscache($num); } } echo " </channel>\n" . "</rss>"; function updatersscache($num) { global $_G; $processname = 'forum_rss_cache'; if (discuz_process::islocked($processname, 600)) { return false; } C::t('forum_rsscache')->truncate(); require_once libfile('function/post'); foreach ($_G['cache']['forums'] as $fid => $forum) { if ($forum['type'] != 'group') { $forum['name'] = addslashes($forum['name']);
} dheader("Content-type: application/xml"); echo "<?xml version=\"1.0\" encoding=\"" . $charset . "\"?>\n" . "<rss version=\"2.0\">\n" . " <channel>\n" . (count($fidarray) > 1 ? " <title>{$bbname}</title>\n" . " <link>{$boardurl}" . $_DCACHE[settings][indexname] . "</link>\n" . " <description>Latest {$num} threads of all forums</description>\n" : " <title>{$bbname} - {$forumname}</title>\n" . " <link>{$boardurl}forumdisplay.php?fid={$rssfid}</link>\n" . " <description>Latest {$num} threads of {$forumname}</description>\n") . " <copyright>Copyright(C) {$bbname}</copyright>\n" . " <generator>Discuz! Board by Comsenz Inc.</generator>\n" . " <lastBuildDate>" . gmdate('r', $timestamp) . "</lastBuildDate>\n" . " <ttl>{$ttl}</ttl>\n" . " <image>\n" . " <url>{$boardurl}images/logo.gif</url>\n" . " <title>{$bbname}</title>\n" . " <link>{$boardurl}</link>\n" . " </image>\n"; if ($fidarray) { $query = $db->query("SELECT * FROM {$tablepre}rsscaches WHERE fid IN (" . implode(',', $fidarray) . ") ORDER BY dateline DESC LIMIT {$num}"); if ($db->num_rows($query)) { while ($thread = $db->fetch_array($query)) { if ($timestamp - $thread['lastupdate'] > $ttl * 60) { updatersscache(); break; } else { echo " <item>\n" . " <title>" . dhtmlspecialchars($thread['subject']) . "</title>\n" . " <link>{$boardurl}viewthread.php?tid={$thread['tid']}</link>\n" . " <description><![CDATA[{$thread['description']}]]></description>\n" . " <category>" . dhtmlspecialchars($thread['forum']) . "</category>\n" . " <author>" . dhtmlspecialchars($thread['author']) . "</author>\n" . " <pubDate>" . gmdate('r', $thread['dateline']) . "</pubDate>\n" . " </item>\n"; } } } else { updatersscache(); } } echo " </channel>\n" . "</rss>"; function rssforumperm($forum) { global $groupid, $discuz_uid; return $forum['type'] != 'group' && (!$forum['viewperm'] || $forum['viewperm'] && forumperm($forum['viewperm']) || $accessmasks); } function updatersscache() { global $_DCACHE, $timestamp, $num, $tablepre, $db; $db->query("DELETE FROM {$tablepre}rsscaches"); foreach ($_DCACHE['forums'] as $fid => $forum) { if ($forum['type'] != 'group') { $query = $db->query("SELECT t.tid, t.readperm, t.price, t.author, t.dateline, t.subject, p.message, p.status\r\n\t\t\t\tFROM {$tablepre}threads t\r\n\t\t\t\tLEFT JOIN {$tablepre}posts p ON p.tid=t.tid AND p.first='1'\r\n\t\t\t\tWHERE t.fid='{$fid}' AND t.displayorder>='0'\r\n\t\t\t\tORDER BY t.dateline DESC LIMIT {$num}");