Web: send News notices containing images/video only to 7.3+ clients

This commit is contained in:
David Anderson 2014-05-08 00:50:22 -07:00
parent 0d5f41a0c1
commit ac476a23b5
2 changed files with 16 additions and 3 deletions

View File

@ -22,7 +22,16 @@ require_once("../inc/util.inc");
require_once("../inc/text_transform.inc");
require_once("../project/project.inc");
function show_forum_rss_item($thread, $userid, $threads_only) {
// 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) {
$unique_url=URL_BASE."forum_thread.php?id=".$thread->id;
$clause2 = " and hidden=0 ";
@ -42,6 +51,7 @@ function show_forum_rss_item($thread, $userid, $threads_only) {
$options->htmlitems = false;
}
$t = output_transform($post->content, $options);
if ($no_images && contains_image_or_video($t)) return;
echo "<item>
<title><![CDATA[".sanitize_tags(bb2html($thread->title))."]]></title>
<link>$unique_url</link>
@ -112,7 +122,7 @@ function forum_rss($forumid, $userid, $threads_only, $ndays) {
";
foreach ($threads as $thread) {
show_forum_rss_item($thread, $userid, $threads_only);
show_forum_rss_item($thread, $userid, $threads_only, false);
}
echo "

View File

@ -97,6 +97,9 @@ foreach ($threads as $t) {
usort($items, 'notice_cmp');
$client_version = boinc_client_version();
$no_images = ($client_version < 73000);
notices_rss_start();
foreach ($items as $item) {
switch ($item->type) {
@ -104,7 +107,7 @@ foreach ($items as $item) {
show_notify_rss_item($item->val);
break;
case 1:
show_forum_rss_item($item->val, 0, 1, 0);
show_forum_rss_item($item->val, 0, 1, $no_images);
break;
}
}