2009-12-16 22:35:08 +00:00
|
|
|
<?php
|
|
|
|
// This file is part of BOINC.
|
|
|
|
// http://boinc.berkeley.edu
|
|
|
|
// Copyright (C) 2009 University of California
|
|
|
|
//
|
|
|
|
// BOINC is free software; you can redistribute it and/or modify it
|
|
|
|
// under the terms of the GNU Lesser General Public License
|
|
|
|
// as published by the Free Software Foundation,
|
|
|
|
// either version 3 of the License, or (at your option) any later version.
|
|
|
|
//
|
|
|
|
// BOINC is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
// See the GNU Lesser General Public License for more details.
|
|
|
|
//
|
|
|
|
// You should have received a copy of the GNU Lesser General Public License
|
|
|
|
// along with BOINC. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
2015-02-09 16:37:12 +00:00
|
|
|
require_once("../inc/forum.inc");
|
2009-12-16 22:35:08 +00:00
|
|
|
require_once("../inc/boinc_db.inc");
|
|
|
|
require_once("../inc/text_transform.inc");
|
|
|
|
|
2014-05-08 07:50:22 +00:00
|
|
|
// return true if the given HTML may contain images or video
|
|
|
|
//
|
|
|
|
function contains_image_or_video($x) {
|
|
|
|
if (strstr($x, "<img ")) return true;
|
|
|
|
if (strstr($x, "<object ")) return true;
|
|
|
|
if (strstr($x, "<iframe ")) return true;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
function show_forum_rss_item($thread, $userid, $threads_only, $no_images) {
|
2015-11-30 08:36:29 +00:00
|
|
|
$unique_url=secure_url_base()."forum_thread.php?id=".$thread->id;
|
2010-01-12 21:53:40 +00:00
|
|
|
|
|
|
|
$clause2 = " and hidden=0 ";
|
|
|
|
if ($userid) $clause2 .= "and user=$userid";
|
|
|
|
if ($threads_only) {
|
|
|
|
$posts = BoincPost::enum("thread=$thread->id $clause2 order by id limit 1");
|
|
|
|
} else {
|
|
|
|
$posts = BoincPost::enum("thread=$thread->id $clause2 order by timestamp desc limit 1");
|
|
|
|
}
|
2010-10-17 20:12:14 +00:00
|
|
|
if (!count($posts)) return;
|
2010-01-12 21:53:40 +00:00
|
|
|
$post = $posts[0];
|
|
|
|
$post_date = gmdate('D, d M Y H:i:s',$post->timestamp).' GMT';
|
2014-03-15 22:33:38 +00:00
|
|
|
$post_user = BOincUser::lookup_id($post->user);
|
|
|
|
BoincForumPrefs::lookup($post_user);
|
|
|
|
$options = new output_options();
|
|
|
|
if (is_admin($post_user)) {
|
|
|
|
$options->htmlitems = false;
|
2010-01-12 21:53:40 +00:00
|
|
|
}
|
2014-03-15 22:33:38 +00:00
|
|
|
$t = output_transform($post->content, $options);
|
2014-05-08 07:50:22 +00:00
|
|
|
if ($no_images && contains_image_or_video($t)) return;
|
2010-01-12 21:53:40 +00:00
|
|
|
echo "<item>
|
2011-08-26 18:30:13 +00:00
|
|
|
<title><![CDATA[".sanitize_tags(bb2html($thread->title))."]]></title>
|
2010-01-12 21:53:40 +00:00
|
|
|
<link>$unique_url</link>
|
|
|
|
<guid isPermaLink=\"true\">$unique_url</guid>
|
2010-01-13 17:28:59 +00:00
|
|
|
<description><![CDATA[\n$t\n]]></description>
|
2010-01-12 21:53:40 +00:00
|
|
|
<pubDate>$post_date</pubDate>
|
|
|
|
</item>
|
|
|
|
";
|
|
|
|
}
|
|
|
|
|
2014-03-15 22:33:38 +00:00
|
|
|
function forum_rss($forumid, $userid, $threads_only, $ndays) {
|
2009-12-16 22:35:08 +00:00
|
|
|
$clause = "forum=$forumid ";
|
|
|
|
|
|
|
|
if ($userid) {
|
|
|
|
$user = BoincUser::lookup_id($userid);
|
|
|
|
if (!$user) error_page("no such user");
|
|
|
|
$clause .= " and owner=$userid";
|
|
|
|
}
|
|
|
|
|
|
|
|
$tlimit = time() - $ndays*86400;
|
|
|
|
|
|
|
|
if ($threads_only) {
|
2011-10-24 04:24:44 +00:00
|
|
|
$q = "$clause and hidden=0 and create_time > $tlimit order by create_time desc";
|
2009-12-16 22:35:08 +00:00
|
|
|
} else {
|
2011-10-25 17:22:18 +00:00
|
|
|
$q = "$clause and hidden=0 and timestamp > $tlimit order by timestamp desc";
|
2009-12-16 22:35:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
$threads = BoincThread::enum($q);
|
|
|
|
|
|
|
|
// Get unix time that last modification was made to the news source
|
|
|
|
//
|
|
|
|
|
|
|
|
// Now construct header
|
|
|
|
//
|
|
|
|
header ("Expires: " . gmdate('D, d M Y H:i:s', time()+86400) . " GMT");
|
|
|
|
if (sizeof($threads)) {
|
|
|
|
$t = $threads[0];
|
|
|
|
$last_mod_time = $threads_only?$t->create_time:$t->timestamp;
|
|
|
|
$create_date = gmdate('D, d M Y H:i:s', $last_mod_time) . ' GMT';
|
|
|
|
header ("Last-Modified: " . $create_date);
|
2014-03-24 22:13:06 +00:00
|
|
|
} else {
|
|
|
|
$create_date = gmdate('D, d M Y H:i:s') . ' GMT';
|
2009-12-16 22:35:08 +00:00
|
|
|
}
|
|
|
|
header ("Content-Type: application/xml");
|
|
|
|
|
2010-03-29 22:28:20 +00:00
|
|
|
$forum=BoincForum::lookup_id($forumid);
|
2009-12-16 22:35:08 +00:00
|
|
|
// Create channel header and open XML content
|
|
|
|
//
|
2010-03-29 22:28:20 +00:00
|
|
|
$description = PROJECT.": $forum->title";
|
2010-09-27 20:34:47 +00:00
|
|
|
if ($userid) {
|
2009-12-16 22:35:08 +00:00
|
|
|
$description .= " (posts by $user->name)";
|
|
|
|
}
|
2015-11-30 08:36:29 +00:00
|
|
|
$channel_image = secure_url_base() . "rss_image.gif";
|
2009-12-16 22:35:08 +00:00
|
|
|
$language = "en-us";
|
2010-12-24 19:35:08 +00:00
|
|
|
echo "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>
|
2009-12-16 22:35:08 +00:00
|
|
|
<rss version=\"2.0\">
|
|
|
|
<channel>
|
|
|
|
<title>".$description."</title>
|
2018-12-24 05:53:51 +00:00
|
|
|
<description>".$description."</description>
|
2015-11-30 08:36:29 +00:00
|
|
|
<link>".secure_url_base()."</link>
|
2009-12-16 22:35:08 +00:00
|
|
|
<copyright>".COPYRIGHT_HOLDER."</copyright>
|
|
|
|
<lastBuildDate>".$create_date."</lastBuildDate>
|
|
|
|
<language>".$language."</language>
|
|
|
|
<image>
|
|
|
|
<url>".$channel_image."</url>
|
|
|
|
<title>".PROJECT."</title>
|
2015-11-30 08:36:29 +00:00
|
|
|
<link>".secure_url_base()."</link>
|
2009-12-16 22:35:08 +00:00
|
|
|
</image>
|
|
|
|
";
|
|
|
|
|
|
|
|
foreach ($threads as $thread) {
|
2014-05-08 07:50:22 +00:00
|
|
|
show_forum_rss_item($thread, $userid, $threads_only, false);
|
2009-12-16 22:35:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
echo "
|
|
|
|
</channel>
|
|
|
|
</rss>
|
|
|
|
";
|
|
|
|
}
|
|
|
|
|
|
|
|
?>
|