Skip to content
Snippets Groups Projects
Commit ac476a23 authored by David Anderson's avatar David Anderson
Browse files

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

parent 0d5f41a0
No related branches found
No related tags found
No related merge requests found
...@@ -22,7 +22,16 @@ require_once("../inc/util.inc"); ...@@ -22,7 +22,16 @@ require_once("../inc/util.inc");
require_once("../inc/text_transform.inc"); require_once("../inc/text_transform.inc");
require_once("../project/project.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; $unique_url=URL_BASE."forum_thread.php?id=".$thread->id;
$clause2 = " and hidden=0 "; $clause2 = " and hidden=0 ";
...@@ -42,6 +51,7 @@ function show_forum_rss_item($thread, $userid, $threads_only) { ...@@ -42,6 +51,7 @@ function show_forum_rss_item($thread, $userid, $threads_only) {
$options->htmlitems = false; $options->htmlitems = false;
} }
$t = output_transform($post->content, $options); $t = output_transform($post->content, $options);
if ($no_images && contains_image_or_video($t)) return;
echo "<item> echo "<item>
<title><![CDATA[".sanitize_tags(bb2html($thread->title))."]]></title> <title><![CDATA[".sanitize_tags(bb2html($thread->title))."]]></title>
<link>$unique_url</link> <link>$unique_url</link>
...@@ -112,7 +122,7 @@ function forum_rss($forumid, $userid, $threads_only, $ndays) { ...@@ -112,7 +122,7 @@ function forum_rss($forumid, $userid, $threads_only, $ndays) {
"; ";
foreach ($threads as $thread) { foreach ($threads as $thread) {
show_forum_rss_item($thread, $userid, $threads_only); show_forum_rss_item($thread, $userid, $threads_only, false);
} }
echo " echo "
......
...@@ -97,6 +97,9 @@ foreach ($threads as $t) { ...@@ -97,6 +97,9 @@ foreach ($threads as $t) {
usort($items, 'notice_cmp'); usort($items, 'notice_cmp');
$client_version = boinc_client_version();
$no_images = ($client_version < 73000);
notices_rss_start(); notices_rss_start();
foreach ($items as $item) { foreach ($items as $item) {
switch ($item->type) { switch ($item->type) {
...@@ -104,7 +107,7 @@ foreach ($items as $item) { ...@@ -104,7 +107,7 @@ foreach ($items as $item) {
show_notify_rss_item($item->val); show_notify_rss_item($item->val);
break; break;
case 1: case 1:
show_forum_rss_item($item->val, 0, 1, 0); show_forum_rss_item($item->val, 0, 1, $no_images);
break; break;
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment