. // get a forum (possibly filtered by user) as RSS feed require_once("../project/project.inc"); require_once("../inc/db.inc"); $forumid = get_int('forumid'); $forum = BoincForum::lookup_id($forumid); if (!$forum) error_page("no such forum"); if (get_int('setup', true)) { page_head("$forum->name RSS feed"); echo " This message board is available as an RSS feed. Options:

Include only posts by user ID (default: all users).

Include only the most recent posts (default: 20).

"; page_tail(); exit; } $userid = get_int('userid', true); $nitems = get_int('nitems', true); if(!$nitems || $nitems < "1" || $nitems > "20") { $nitems = "20"; } $clause = "forum=$forumid "; if ($userid) { $user = BoincUser::lookup_id($userid); if (!$user) error_page("no such user"); $clause .= " and owner=$userid"; } class Int { }; $db = BoincDb::get(); $x = $db->lookup_fields( "thread", "Int", "max(timestamp) as foo", "$clause and status=0 and hidden=0 and sticky=0" ); $last_mod_time = $x->foo; $threads = BoincThread::enum("$clause and status=0 and hidden=0 and sticky=0 order by create_time desc limit $nitems" ); // Get unix time that last modification was made to the news source // $create_date = gmdate('D, d M Y H:i:s', $last_mod_time) . ' GMT'; // Now construct header // header ("Expires: " . gmdate('D, d M Y H:i:s', time()+86400) . " GMT"); header ("Last-Modified: " . $create_date); header ("Content-Type: application/xml"); // Create channel header and open XML content // $description = PROJECT.": $forum->description"; if ($user) { $description .= " (posts by $user->name)"; } $channel_image = URL_BASE . "rss_image.gif"; $language = "en-us"; echo " ".$description." ".URL_BASE." ".$description." ".COPYRIGHT_HOLDER." ".$create_date." ".$language." ".$channel_image." ".PROJECT." ".URL_BASE." "; // write news items // foreach ($threads as $thread) { $post_date=gmdate('D, d M Y H:i:s',$thread->create_time).' GMT'; $unique_url=URL_BASE."forum_thread.php?id=".$thread->id; $clause2 = $userid?"and user=$userid":""; $posts = BoincPost::enum("thread=$thread->id $clause2 order by timestamp limit 1"); $post = $posts[0]; echo " ".strip_tags($thread->title)." $unique_url $unique_url ".htmlspecialchars(htmlspecialchars(substr($post->content,0,255)))." . . . $post_date "; } // Close XML content // echo " "; ?>