From 5bf472619537c29f381d91ae564324562ef1f022 Mon Sep 17 00:00:00 2001 From: erangamapa Date: Thu, 14 Mar 2013 01:11:36 +0530 Subject: [PATCH 01/12] [ticket/11271] Displaying in-line attached images in ATOM feed. In-line attached images are not displaying as they are not parsing. Included 'parse_attachments' column name for data fetching queries in feed.php. Checked weather feeds have in-line attachments and parsed them by using parse_attachments() method. PHPBB3-11271 --- phpBB/feed.php | 38 +++++++++++++++++++++++++++++--------- 1 file changed, 29 insertions(+), 9 deletions(-) diff --git a/phpBB/feed.php b/phpBB/feed.php index 9816f0f303..9f0f0b2294 100644 --- a/phpBB/feed.php +++ b/phpBB/feed.php @@ -19,6 +19,7 @@ define('IN_PHPBB', true); $phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : './'; $phpEx = substr(strrchr(__FILE__, '.'), 1); include($phpbb_root_path . 'common.' . $phpEx); +include($phpbb_root_path . 'includes/functions_display.' . $phpEx); if (!$config['feed_enable']) { @@ -106,7 +107,7 @@ while ($row = $feed->get_item()) 'title' => censor_text($title), 'category' => ($config['feed_item_statistics'] && !empty($row['forum_id'])) ? $board_url . '/viewforum.' . $phpEx . '?f=' . $row['forum_id'] : '', 'category_name' => ($config['feed_item_statistics'] && isset($row['forum_name'])) ? $row['forum_name'] : '', - 'description' => censor_text(feed_generate_content($row[$feed->get('text')], $row[$feed->get('bbcode_uid')], $row[$feed->get('bitfield')], $options)), + 'description' => censor_text(feed_generate_content($row[$feed->get('text')], $row[$feed->get('bbcode_uid')], $row[$feed->get('bitfield')], $options, $row['forum_id'], $row['post_id'], $row['post_attachment'])), 'statistics' => '', ); @@ -273,9 +274,9 @@ function feed_format_date($time) /** * Generate text content **/ -function feed_generate_content($content, $uid, $bitfield, $options) +function feed_generate_content($content, $uid, $bitfield, $options, $forum_id, $post_id, $post_attachment) { - global $user, $config, $phpbb_root_path, $phpEx, $board_url; + global $user, $db, $config, $phpbb_root_path, $phpEx, $board_url; if (empty($content)) { @@ -322,6 +323,25 @@ function feed_generate_content($content, $uid, $bitfield, $options) // Remove some specials html tag, because somewhere there are a mod to allow html tags ;) $content = preg_replace( '#<(script|iframe)([^[]+)\1>#siU', ' $1 ', $content); + // Parse inline images to display with the feed + if ($post_attachment) + { + $sql = 'SELECT * + FROM ' . ATTACHMENTS_TABLE . ' + WHERE post_msg_id = ' . $post_id . ' + AND in_message = 0 + ORDER BY filetime DESC, post_msg_id ASC'; + $result = $db->sql_query($sql); + + while ($row = $db->sql_fetchrow($result)) + { + $attachments[$row['post_msg_id']][] = $row; + } + $db->sql_freeresult($result); + $update_count = array(); + parse_attachments($forum_id, $content, $attachments[$post_id], $update_count); + } + // Remove Comments from inline attachments [ia] $content = preg_replace('#
(.*?)(.*?)(.*?)
#si','$4',$content); @@ -795,7 +815,7 @@ class phpbb_feed_overall extends phpbb_feed_post_base // Get the actual data $this->sql = array( 'SELECT' => 'f.forum_id, f.forum_name, ' . - 'p.post_id, p.topic_id, p.post_time, p.post_edit_time, p.post_approved, p.post_subject, p.post_text, p.bbcode_bitfield, p.bbcode_uid, p.enable_bbcode, p.enable_smilies, p.enable_magic_url, ' . + 'p.post_id, p.topic_id, p.post_time, p.post_edit_time, p.post_approved, p.post_subject, p.post_text, p.bbcode_bitfield, p.bbcode_uid, p.enable_bbcode, p.enable_smilies, p.enable_magic_url, p.post_attachment, ' . 'u.username, u.user_id', 'FROM' => array( USERS_TABLE => 'u', @@ -927,7 +947,7 @@ class phpbb_feed_forum extends phpbb_feed_post_base } $this->sql = array( - 'SELECT' => 'p.post_id, p.topic_id, p.post_time, p.post_edit_time, p.post_approved, p.post_subject, p.post_text, p.bbcode_bitfield, p.bbcode_uid, p.enable_bbcode, p.enable_smilies, p.enable_magic_url, ' . + 'SELECT' => 'p.post_id, p.topic_id, p.post_time, p.post_edit_time, p.post_approved, p.post_subject, p.post_text, p.bbcode_bitfield, p.bbcode_uid, p.enable_bbcode, p.enable_smilies, p.enable_magic_url, p.post_attachment, ' . 'u.username, u.user_id', 'FROM' => array( POSTS_TABLE => 'p', @@ -1092,7 +1112,7 @@ class phpbb_feed_topic extends phpbb_feed_post_base global $auth, $db; $this->sql = array( - 'SELECT' => 'p.post_id, p.post_time, p.post_edit_time, p.post_approved, p.post_subject, p.post_text, p.bbcode_bitfield, p.bbcode_uid, p.enable_bbcode, p.enable_smilies, p.enable_magic_url, ' . + 'SELECT' => 'p.post_id, p.post_time, p.post_edit_time, p.post_approved, p.post_subject, p.post_text, p.bbcode_bitfield, p.bbcode_uid, p.enable_bbcode, p.enable_smilies, p.enable_magic_url, p.post_attachment, ' . 'u.username, u.user_id', 'FROM' => array( POSTS_TABLE => 'p', @@ -1257,7 +1277,7 @@ class phpbb_feed_news extends phpbb_feed_topic_base $this->sql = array( 'SELECT' => 'f.forum_id, f.forum_name, t.topic_id, t.topic_title, t.topic_poster, t.topic_first_poster_name, t.topic_replies, t.topic_replies_real, t.topic_views, t.topic_time, t.topic_last_post_time, - p.post_id, p.post_time, p.post_edit_time, p.post_text, p.bbcode_bitfield, p.bbcode_uid, p.enable_bbcode, p.enable_smilies, p.enable_magic_url', + p.post_id, p.post_time, p.post_edit_time, p.post_text, p.bbcode_bitfield, p.bbcode_uid, p.enable_bbcode, p.enable_smilies, p.enable_magic_url, p.post_attachment', 'FROM' => array( TOPICS_TABLE => 't', POSTS_TABLE => 'p', @@ -1330,7 +1350,7 @@ class phpbb_feed_topics extends phpbb_feed_topic_base $this->sql = array( 'SELECT' => 'f.forum_id, f.forum_name, t.topic_id, t.topic_title, t.topic_poster, t.topic_first_poster_name, t.topic_replies, t.topic_replies_real, t.topic_views, t.topic_time, t.topic_last_post_time, - p.post_id, p.post_time, p.post_edit_time, p.post_text, p.bbcode_bitfield, p.bbcode_uid, p.enable_bbcode, p.enable_smilies, p.enable_magic_url', + p.post_id, p.post_time, p.post_edit_time, p.post_text, p.bbcode_bitfield, p.bbcode_uid, p.enable_bbcode, p.enable_smilies, p.enable_magic_url, p.post_attachment', 'FROM' => array( TOPICS_TABLE => 't', POSTS_TABLE => 'p', @@ -1427,7 +1447,7 @@ class phpbb_feed_topics_active extends phpbb_feed_topic_base 'SELECT' => 'f.forum_id, f.forum_name, t.topic_id, t.topic_title, t.topic_replies, t.topic_replies_real, t.topic_views, t.topic_last_poster_id, t.topic_last_poster_name, t.topic_last_post_time, - p.post_id, p.post_time, p.post_edit_time, p.post_text, p.bbcode_bitfield, p.bbcode_uid, p.enable_bbcode, p.enable_smilies, p.enable_magic_url', + p.post_id, p.post_time, p.post_edit_time, p.post_text, p.bbcode_bitfield, p.bbcode_uid, p.enable_bbcode, p.enable_smilies, p.enable_magic_url, p.post_attachment', 'FROM' => array( TOPICS_TABLE => 't', POSTS_TABLE => 'p', From a41e2ca380d0d4a142229f1655db4d429f109e50 Mon Sep 17 00:00:00 2001 From: erangamapa Date: Thu, 14 Mar 2013 01:38:24 +0530 Subject: [PATCH 02/12] [ticket/11271] Removed in-line attachment comments properly. Added a new regex to remove in-line attachment comments. PHPBB3-11271 --- phpBB/feed.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpBB/feed.php b/phpBB/feed.php index 9f0f0b2294..5a42ca6c37 100644 --- a/phpBB/feed.php +++ b/phpBB/feed.php @@ -343,7 +343,7 @@ function feed_generate_content($content, $uid, $bitfield, $options, $forum_id, $ } // Remove Comments from inline attachments [ia] - $content = preg_replace('#
(.*?)(.*?)(.*?)
#si','$4',$content); + $content = preg_replace('#
(.*?)
#','',$content); // Replace some entities with their unicode counterpart $entities = array( From 91a14a9e636e761ef18632e850518d4ba5b7eb90 Mon Sep 17 00:00:00 2001 From: erangamapa Date: Sun, 17 Mar 2013 02:17:52 +0530 Subject: [PATCH 03/12] [ticket/11271] Fetched feed attachments before loop. Fetched feed attachments before looping through feed items and send them to method 'feed_generate_content' for each feed item. PHPBB3-11271 --- phpBB/feed.php | 54 +++++++++++++++++++++++++++++++++++--------------- 1 file changed, 38 insertions(+), 16 deletions(-) diff --git a/phpBB/feed.php b/phpBB/feed.php index 5a42ca6c37..570240fe93 100644 --- a/phpBB/feed.php +++ b/phpBB/feed.php @@ -72,6 +72,40 @@ if ($feed === false) trigger_error('NO_FEED'); } +$sql_array = array( + 'SELECT' => 'a.*', + 'FROM' => array( + ATTACHMENTS_TABLE => 'a' + ), + 'WHERE' => 'a.in_message = 0 ', + 'ORDER_BY' => 'a.filetime DESC, a.post_msg_id ASC' + ); + +if ($topic_id) +{ + $sql_array['WHERE'] .= 'AND a.topic_id = ' . $topic_id; +} +else if ($forum_id) +{ + $sql_array['LEFT_JOIN'] = array( + array( + 'FROM' => array(TOPICS_TABLE => 't'), + 'ON' => 'a.topic_id = t.topic_id' + ) + ); + $sql_array['WHERE'] .= 'AND t.forum_id = ' . $forum_id; +} + +$sql = $db->sql_build_query('SELECT', $sql_array); +$result = $db->sql_query($sql); + +// Set attachments in feed items +while ($row = $db->sql_fetchrow($result)) +{ + $attachments[$row['post_msg_id']][] = $row; +} +$db->sql_freeresult($result); + // Open Feed $feed->open(); @@ -107,7 +141,7 @@ while ($row = $feed->get_item()) 'title' => censor_text($title), 'category' => ($config['feed_item_statistics'] && !empty($row['forum_id'])) ? $board_url . '/viewforum.' . $phpEx . '?f=' . $row['forum_id'] : '', 'category_name' => ($config['feed_item_statistics'] && isset($row['forum_name'])) ? $row['forum_name'] : '', - 'description' => censor_text(feed_generate_content($row[$feed->get('text')], $row[$feed->get('bbcode_uid')], $row[$feed->get('bitfield')], $options, $row['forum_id'], $row['post_id'], $row['post_attachment'])), + 'description' => censor_text(feed_generate_content($row[$feed->get('text')], $row[$feed->get('bbcode_uid')], $row[$feed->get('bitfield')], $options, $row['forum_id'], (($row['post_attachment']) ? $attachments[$row['post_id']] : null))), 'statistics' => '', ); @@ -274,7 +308,7 @@ function feed_format_date($time) /** * Generate text content **/ -function feed_generate_content($content, $uid, $bitfield, $options, $forum_id, $post_id, $post_attachment) +function feed_generate_content($content, $uid, $bitfield, $options, $forum_id, $post_attachments) { global $user, $db, $config, $phpbb_root_path, $phpEx, $board_url; @@ -324,22 +358,10 @@ function feed_generate_content($content, $uid, $bitfield, $options, $forum_id, $ $content = preg_replace( '#<(script|iframe)([^[]+)\1>#siU', ' $1 ', $content); // Parse inline images to display with the feed - if ($post_attachment) + if ($post_attachments != null) { - $sql = 'SELECT * - FROM ' . ATTACHMENTS_TABLE . ' - WHERE post_msg_id = ' . $post_id . ' - AND in_message = 0 - ORDER BY filetime DESC, post_msg_id ASC'; - $result = $db->sql_query($sql); - - while ($row = $db->sql_fetchrow($result)) - { - $attachments[$row['post_msg_id']][] = $row; - } - $db->sql_freeresult($result); $update_count = array(); - parse_attachments($forum_id, $content, $attachments[$post_id], $update_count); + parse_attachments($forum_id, $content, $post_attachments, $update_count); } // Remove Comments from inline attachments [ia] From 85861711872c0f9a9064e0043764f6c752a915d7 Mon Sep 17 00:00:00 2001 From: erangamapa Date: Sat, 6 Apr 2013 20:13:46 +0530 Subject: [PATCH 04/12] [ticket/11271] Separated attachment fetching query Removed external query used to fetch related attachments. Added attachments fetching method with database query to post based feed. PHPBB3-11271 --- phpBB/feed.php | 79 ++++++++++++++++++++++++++++---------------------- 1 file changed, 44 insertions(+), 35 deletions(-) diff --git a/phpBB/feed.php b/phpBB/feed.php index 570240fe93..6a83bba562 100644 --- a/phpBB/feed.php +++ b/phpBB/feed.php @@ -72,39 +72,8 @@ if ($feed === false) trigger_error('NO_FEED'); } -$sql_array = array( - 'SELECT' => 'a.*', - 'FROM' => array( - ATTACHMENTS_TABLE => 'a' - ), - 'WHERE' => 'a.in_message = 0 ', - 'ORDER_BY' => 'a.filetime DESC, a.post_msg_id ASC' - ); - -if ($topic_id) -{ - $sql_array['WHERE'] .= 'AND a.topic_id = ' . $topic_id; -} -else if ($forum_id) -{ - $sql_array['LEFT_JOIN'] = array( - array( - 'FROM' => array(TOPICS_TABLE => 't'), - 'ON' => 'a.topic_id = t.topic_id' - ) - ); - $sql_array['WHERE'] .= 'AND t.forum_id = ' . $forum_id; -} - -$sql = $db->sql_build_query('SELECT', $sql_array); -$result = $db->sql_query($sql); - -// Set attachments in feed items -while ($row = $db->sql_fetchrow($result)) -{ - $attachments[$row['post_msg_id']][] = $row; -} -$db->sql_freeresult($result); +// Get attachments for this feed +$feed->fetch_attachments(); // Open Feed $feed->open(); @@ -141,7 +110,7 @@ while ($row = $feed->get_item()) 'title' => censor_text($title), 'category' => ($config['feed_item_statistics'] && !empty($row['forum_id'])) ? $board_url . '/viewforum.' . $phpEx . '?f=' . $row['forum_id'] : '', 'category_name' => ($config['feed_item_statistics'] && isset($row['forum_name'])) ? $row['forum_name'] : '', - 'description' => censor_text(feed_generate_content($row[$feed->get('text')], $row[$feed->get('bbcode_uid')], $row[$feed->get('bitfield')], $options, $row['forum_id'], (($row['post_attachment']) ? $attachments[$row['post_id']] : null))), + 'description' => censor_text(feed_generate_content($row[$feed->get('text')], $row[$feed->get('bbcode_uid')], $row[$feed->get('bitfield')], $options, $row['forum_id'], (($row['post_attachment']) ? $feed->attachments[$row['post_id']] : null))), 'statistics' => '', ); @@ -358,7 +327,7 @@ function feed_generate_content($content, $uid, $bitfield, $options, $forum_id, $ $content = preg_replace( '#<(script|iframe)([^[]+)\1>#siU', ' $1 ', $content); // Parse inline images to display with the feed - if ($post_attachments != null) + if (count($post_attachments) > 0) { $update_count = array(); parse_attachments($forum_id, $content, $post_attachments, $update_count); @@ -702,6 +671,7 @@ class phpbb_feed_base class phpbb_feed_post_base extends phpbb_feed_base { var $num_items = 'feed_limit_post'; + var $attachments = array(); function set_keys() { @@ -735,6 +705,45 @@ class phpbb_feed_post_base extends phpbb_feed_base . (($this->is_moderator_approve_forum($row['forum_id']) && !$row['post_approved']) ? ' ' . $this->separator_stats . ' ' . $user->lang['POST_UNAPPROVED'] : ''); } } + + function fetch_attachments() + { + global $db; + + $sql_array = array( + 'SELECT' => 'a.*', + 'FROM' => array( + ATTACHMENTS_TABLE => 'a' + ), + 'WHERE' => 'a.in_message = 0 ', + 'ORDER_BY' => 'a.filetime DESC, a.post_msg_id ASC' + ); + + if (isset($this->topic_id)) + { + $sql_array['WHERE'] .= 'AND a.topic_id = ' . $this->topic_id; + } + else if (isset($this->forum_id)) + { + $sql_array['LEFT_JOIN'] = array( + array( + 'FROM' => array(TOPICS_TABLE => 't'), + 'ON' => 'a.topic_id = t.topic_id' + ) + ); + $sql_array['WHERE'] .= 'AND t.forum_id = ' . $this->forum_id; + } + + $sql = $db->sql_build_query('SELECT', $sql_array); + $result = $db->sql_query($sql); + + // Set attachments in feed items + while ($row = $db->sql_fetchrow($result)) + { + $this->attachments[$row['post_msg_id']][] = $row; + } + $db->sql_freeresult($result); + } } /** From cca4067694137f32dd08705e239e62bd5b0980ee Mon Sep 17 00:00:00 2001 From: erangamapa Date: Sat, 6 Apr 2013 22:29:32 +0530 Subject: [PATCH 05/12] [ticket/11271] Removing unnecessary database object Removed unnecessary global database object from 'feed_generate_content' Method. PHPBB3-11271 --- phpBB/feed.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpBB/feed.php b/phpBB/feed.php index 6a83bba562..1b854c1705 100644 --- a/phpBB/feed.php +++ b/phpBB/feed.php @@ -279,7 +279,7 @@ function feed_format_date($time) **/ function feed_generate_content($content, $uid, $bitfield, $options, $forum_id, $post_attachments) { - global $user, $db, $config, $phpbb_root_path, $phpEx, $board_url; + global $user, $config, $phpbb_root_path, $phpEx, $board_url; if (empty($content)) { From 08d69de933e2ca9ef40a6bf4f9273bae88de0199 Mon Sep 17 00:00:00 2001 From: erangamapa Date: Mon, 8 Apr 2013 08:10:36 +0530 Subject: [PATCH 06/12] [ticket/11271] Formatting code and removing null assignment. Formatted code and replaced null assignment with empty array assignment to attachments parameter in method 'feed_generate_content'. PHPBB3-11271 --- phpBB/feed.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) mode change 100644 => 100755 phpBB/feed.php diff --git a/phpBB/feed.php b/phpBB/feed.php old mode 100644 new mode 100755 index 1b854c1705..d19aa48f17 --- a/phpBB/feed.php +++ b/phpBB/feed.php @@ -110,7 +110,7 @@ while ($row = $feed->get_item()) 'title' => censor_text($title), 'category' => ($config['feed_item_statistics'] && !empty($row['forum_id'])) ? $board_url . '/viewforum.' . $phpEx . '?f=' . $row['forum_id'] : '', 'category_name' => ($config['feed_item_statistics'] && isset($row['forum_name'])) ? $row['forum_name'] : '', - 'description' => censor_text(feed_generate_content($row[$feed->get('text')], $row[$feed->get('bbcode_uid')], $row[$feed->get('bitfield')], $options, $row['forum_id'], (($row['post_attachment']) ? $feed->attachments[$row['post_id']] : null))), + 'description' => censor_text(feed_generate_content($row[$feed->get('text')], $row[$feed->get('bbcode_uid')], $row[$feed->get('bitfield')], $options, $row['forum_id'], (($row['post_attachment']) ? $feed->attachments[$row['post_id']] : array()))), 'statistics' => '', ); @@ -334,7 +334,7 @@ function feed_generate_content($content, $uid, $bitfield, $options, $forum_id, $ } // Remove Comments from inline attachments [ia] - $content = preg_replace('#
(.*?)
#','',$content); + $content = preg_replace('#
(.*?)
#','',$content); // Replace some entities with their unicode counterpart $entities = array( @@ -709,7 +709,7 @@ class phpbb_feed_post_base extends phpbb_feed_base function fetch_attachments() { global $db; - + $sql_array = array( 'SELECT' => 'a.*', 'FROM' => array( @@ -718,7 +718,7 @@ class phpbb_feed_post_base extends phpbb_feed_base 'WHERE' => 'a.in_message = 0 ', 'ORDER_BY' => 'a.filetime DESC, a.post_msg_id ASC' ); - + if (isset($this->topic_id)) { $sql_array['WHERE'] .= 'AND a.topic_id = ' . $this->topic_id; @@ -736,7 +736,7 @@ class phpbb_feed_post_base extends phpbb_feed_base $sql = $db->sql_build_query('SELECT', $sql_array); $result = $db->sql_query($sql); - + // Set attachments in feed items while ($row = $db->sql_fetchrow($result)) { From 62263c13d4ab5fd0cdb44edec1d93350e8cddaa3 Mon Sep 17 00:00:00 2001 From: erangamapa Date: Thu, 11 Apr 2013 08:59:40 +0530 Subject: [PATCH 07/12] [ticket/11271] Changed executable bit. Changed executable bit value from 755 to 644. PHPBB3-11271 --- phpBB/feed.php | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100755 => 100644 phpBB/feed.php diff --git a/phpBB/feed.php b/phpBB/feed.php old mode 100755 new mode 100644 From dc37f3a0e352a13ba029b45643d1babacc6aa477 Mon Sep 17 00:00:00 2001 From: Dhruv Date: Sun, 15 Sep 2013 20:40:32 +0530 Subject: [PATCH 08/12] [ticket/11271] Use absolute path for displaying inline attachments in feeds PHPBB3-11271 --- phpBB/feed.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/phpBB/feed.php b/phpBB/feed.php index d19aa48f17..64850c0109 100644 --- a/phpBB/feed.php +++ b/phpBB/feed.php @@ -352,6 +352,9 @@ function feed_generate_content($content, $uid, $bitfield, $options, $forum_id, $ // Other control characters $content = preg_replace('#(?:[\x00-\x1F\x7F]+|(?:\xC2[\x80-\x9F])+)#', '', $content); + // Convert attachments' relative path to absolute path + $content = str_replace($phpbb_root_path . 'download', $board_url . '/download', $content); + return $content; } From 3bae72d164455e8dacd3033540e36d1e1bd313d0 Mon Sep 17 00:00:00 2001 From: Dhruv Date: Fri, 4 Oct 2013 20:51:17 +0530 Subject: [PATCH 09/12] [ticket/11271] Typecast forum and topic id to integer PHPBB3-11271 --- phpBB/feed.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/phpBB/feed.php b/phpBB/feed.php index 64850c0109..602b7f90b3 100644 --- a/phpBB/feed.php +++ b/phpBB/feed.php @@ -724,7 +724,7 @@ class phpbb_feed_post_base extends phpbb_feed_base if (isset($this->topic_id)) { - $sql_array['WHERE'] .= 'AND a.topic_id = ' . $this->topic_id; + $sql_array['WHERE'] .= 'AND a.topic_id = ' . (int) $this->topic_id; } else if (isset($this->forum_id)) { @@ -734,7 +734,7 @@ class phpbb_feed_post_base extends phpbb_feed_base 'ON' => 'a.topic_id = t.topic_id' ) ); - $sql_array['WHERE'] .= 'AND t.forum_id = ' . $this->forum_id; + $sql_array['WHERE'] .= 'AND t.forum_id = ' . (int) $this->forum_id; } $sql = $db->sql_build_query('SELECT', $sql_array); From 6611329d837b1698f24d9d0713cdad9c60007e4f Mon Sep 17 00:00:00 2001 From: Dhruv Date: Fri, 8 Nov 2013 16:19:18 +0530 Subject: [PATCH 10/12] [ticket/11271] Remove unnecessary inclusion of functions_display PHPBB3-11271 --- phpBB/feed.php | 1 - 1 file changed, 1 deletion(-) diff --git a/phpBB/feed.php b/phpBB/feed.php index 602b7f90b3..86d74bc3b7 100644 --- a/phpBB/feed.php +++ b/phpBB/feed.php @@ -19,7 +19,6 @@ define('IN_PHPBB', true); $phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : './'; $phpEx = substr(strrchr(__FILE__, '.'), 1); include($phpbb_root_path . 'common.' . $phpEx); -include($phpbb_root_path . 'includes/functions_display.' . $phpEx); if (!$config['feed_enable']) { From f7c764986f9578c703258943404f7cadda3bd858 Mon Sep 17 00:00:00 2001 From: Dhruv Date: Thu, 26 Dec 2013 23:59:26 +0530 Subject: [PATCH 11/12] [ticket/11271] Fix tabs and use !empty( ) instead of count( ) PHPBB3-11271 --- phpBB/feed.php | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/phpBB/feed.php b/phpBB/feed.php index 86d74bc3b7..a3528ddd71 100644 --- a/phpBB/feed.php +++ b/phpBB/feed.php @@ -326,7 +326,7 @@ function feed_generate_content($content, $uid, $bitfield, $options, $forum_id, $ $content = preg_replace( '#<(script|iframe)([^[]+)\1>#siU', ' $1 ', $content); // Parse inline images to display with the feed - if (count($post_attachments) > 0) + if (!empty($post_attachments)) { $update_count = array(); parse_attachments($forum_id, $content, $post_attachments, $update_count); @@ -713,13 +713,13 @@ class phpbb_feed_post_base extends phpbb_feed_base global $db; $sql_array = array( - 'SELECT' => 'a.*', - 'FROM' => array( - ATTACHMENTS_TABLE => 'a' - ), - 'WHERE' => 'a.in_message = 0 ', - 'ORDER_BY' => 'a.filetime DESC, a.post_msg_id ASC' - ); + 'SELECT' => 'a.*', + 'FROM' => array( + ATTACHMENTS_TABLE => 'a' + ), + 'WHERE' => 'a.in_message = 0 ', + 'ORDER_BY' => 'a.filetime DESC, a.post_msg_id ASC', + ); if (isset($this->topic_id)) { @@ -728,11 +728,11 @@ class phpbb_feed_post_base extends phpbb_feed_base else if (isset($this->forum_id)) { $sql_array['LEFT_JOIN'] = array( - array( - 'FROM' => array(TOPICS_TABLE => 't'), - 'ON' => 'a.topic_id = t.topic_id' - ) - ); + array( + 'FROM' => array(TOPICS_TABLE => 't'), + 'ON' => 'a.topic_id = t.topic_id', + ) + ); $sql_array['WHERE'] .= 'AND t.forum_id = ' . (int) $this->forum_id; } From a71625ca76344098a6e207928b839de576cdabb6 Mon Sep 17 00:00:00 2001 From: Dhruv Date: Fri, 27 Dec 2013 00:38:42 +0530 Subject: [PATCH 12/12] [ticket/11271] Add docblock of feed_generate_content( ) PHPBB3-11271 --- phpBB/feed.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/phpBB/feed.php b/phpBB/feed.php index a3528ddd71..ccc1c6ec1e 100644 --- a/phpBB/feed.php +++ b/phpBB/feed.php @@ -275,6 +275,14 @@ function feed_format_date($time) /** * Generate text content +* +* @param string $content is feed text content +* @param string $uid is bbcode_uid +* @param string $bitfield is bbcode bitfield +* @param int $options bbcode flag options +* @param int $forum_id is the forum id +* @param array $post_attachments is an array containing the attachments and their respective info +* @return string the html content to be printed for the feed **/ function feed_generate_content($content, $uid, $bitfield, $options, $forum_id, $post_attachments) {