root / branches / phpBB-3_0_0 / phpBB / feed.php
History | View | Annotate | Download (38.3 kB)
| 1 | 9575 | acydburn | <?php
|
|---|---|---|---|
| 2 | 9575 | acydburn | /**
|
| 3 | 9575 | acydburn | * @package phpBB3 |
| 4 | 9575 | acydburn | * @version $Id$ |
| 5 | 9575 | acydburn | * @copyright (c) 2009 phpBB Group |
| 6 | 9575 | acydburn | * @license http://opensource.org/licenses/gpl-license.php GNU Public License |
| 7 | 9575 | acydburn | * |
| 8 | 9575 | acydburn | * Idea and original RSS Feed 2.0 MOD (Version 1.0.8/9) by leviatan21 |
| 9 | 9575 | acydburn | * Original MOD: http://www.phpbb.com/community/viewtopic.php?f=69&t=1214645 |
| 10 | 9575 | acydburn | * MOD Author Profile: http://www.phpbb.com/community/memberlist.php?mode=viewprofile&u=345763 |
| 11 | 9575 | acydburn | * MOD Author Homepage: http://www.mssti.com/phpbb3/ |
| 12 | 9575 | acydburn | * |
| 13 | 9575 | acydburn | **/ |
| 14 | 9575 | acydburn | |
| 15 | 9575 | acydburn | /**
|
| 16 | 9575 | acydburn | * @ignore |
| 17 | 9575 | acydburn | **/ |
| 18 | 9575 | acydburn | define('IN_PHPBB', true); |
| 19 | 9575 | acydburn | $phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : './'; |
| 20 | 9575 | acydburn | $phpEx = substr(strrchr(__FILE__, '.'), 1); |
| 21 | 9575 | acydburn | include($phpbb_root_path . 'common.' . $phpEx); |
| 22 | 9575 | acydburn | |
| 23 | 9575 | acydburn | if (!$config['feed_enable']) |
| 24 | 9575 | acydburn | {
|
| 25 | 9575 | acydburn | trigger_error('NO_FEED_ENABLED'); |
| 26 | 9575 | acydburn | } |
| 27 | 9575 | acydburn | |
| 28 | 9575 | acydburn | // Start session
|
| 29 | 9575 | acydburn | $user->session_begin();
|
| 30 | 10430 | bantu | |
| 31 | 10430 | bantu | if (!empty($config['feed_http_auth']) && request_var('auth', '') == 'http') |
| 32 | 10430 | bantu | {
|
| 33 | 10430 | bantu | phpbb_http_login(array(
|
| 34 | 10430 | bantu | 'auth_message' => 'Feed', |
| 35 | 10430 | bantu | 'viewonline' => request_var('viewonline', true), |
| 36 | 10430 | bantu | )); |
| 37 | 10430 | bantu | } |
| 38 | 10430 | bantu | |
| 39 | 9575 | acydburn | $auth->acl($user->data); |
| 40 | 9575 | acydburn | $user->setup();
|
| 41 | 9575 | acydburn | |
| 42 | 9575 | acydburn | // Initial var setup
|
| 43 | 9575 | acydburn | $forum_id = request_var('f', 0); |
| 44 | 9575 | acydburn | $topic_id = request_var('t', 0); |
| 45 | 9575 | acydburn | $mode = request_var('mode', ''); |
| 46 | 9575 | acydburn | |
| 47 | 9575 | acydburn | // We do not use a template, therefore we simply define the global template variables here
|
| 48 | 9575 | acydburn | $global_vars = $item_vars = array(); |
| 49 | 10281 | bantu | $feed_updated_time = 0; |
| 50 | 9575 | acydburn | |
| 51 | 9575 | acydburn | // Generate params array for use in append_sid() to correctly link back to this page
|
| 52 | 10312 | bantu | $params = false; |
| 53 | 9575 | acydburn | if ($forum_id || $topic_id || $mode) |
| 54 | 9575 | acydburn | {
|
| 55 | 9575 | acydburn | $params = array( |
| 56 | 9575 | acydburn | 'f' => ($forum_id) ? $forum_id : NULL, |
| 57 | 9575 | acydburn | 't' => ($topic_id) ? $topic_id : NULL, |
| 58 | 9575 | acydburn | 'mode' => ($mode) ? $mode : NULL, |
| 59 | 9575 | acydburn | ); |
| 60 | 9575 | acydburn | } |
| 61 | 9575 | acydburn | |
| 62 | 9575 | acydburn | // This boards URL
|
| 63 | 9575 | acydburn | $board_url = generate_board_url();
|
| 64 | 9575 | acydburn | |
| 65 | 9575 | acydburn | // Get correct feed object
|
| 66 | 9575 | acydburn | $feed = phpbb_feed_factory::init($mode, $forum_id, $topic_id); |
| 67 | 9575 | acydburn | |
| 68 | 9575 | acydburn | // No feed found
|
| 69 | 9575 | acydburn | if ($feed === false) |
| 70 | 9575 | acydburn | {
|
| 71 | 9575 | acydburn | trigger_error('NO_FEED'); |
| 72 | 9575 | acydburn | } |
| 73 | 9575 | acydburn | |
| 74 | 9575 | acydburn | // Open Feed
|
| 75 | 10308 | bantu | $feed->open();
|
| 76 | 9575 | acydburn | |
| 77 | 9575 | acydburn | // Iterate through items
|
| 78 | 9575 | acydburn | while ($row = $feed->get_item()) |
| 79 | 9575 | acydburn | {
|
| 80 | 9575 | acydburn | // BBCode options to correctly disable urls, smilies, bbcode...
|
| 81 | 9575 | acydburn | if ($feed->get('options') === NULL) |
| 82 | 9575 | acydburn | {
|
| 83 | 9575 | acydburn | // Allow all combinations
|
| 84 | 9575 | acydburn | $options = 7; |
| 85 | 9575 | acydburn | |
| 86 | 9575 | acydburn | if ($feed->get('enable_bbcode') !== NULL && $feed->get('enable_smilies') !== NULL && $feed->get('enable_magic_url') !== NULL) |
| 87 | 9575 | acydburn | {
|
| 88 | 9575 | acydburn | $options = (($row[$feed->get('enable_bbcode')]) ? OPTION_FLAG_BBCODE : 0) + (($row[$feed->get('enable_smilies')]) ? OPTION_FLAG_SMILIES : 0) + (($row[$feed->get('enable_magic_url')]) ? OPTION_FLAG_LINKS : 0); |
| 89 | 9575 | acydburn | } |
| 90 | 9575 | acydburn | } |
| 91 | 9575 | acydburn | else
|
| 92 | 9575 | acydburn | {
|
| 93 | 9575 | acydburn | $options = $row[$feed->get('options')]; |
| 94 | 9575 | acydburn | } |
| 95 | 9575 | acydburn | |
| 96 | 10338 | bantu | $title = (isset($row[$feed->get('title')]) && $row[$feed->get('title')] !== '') ? $row[$feed->get('title')] : ((isset($row[$feed->get('title2')])) ? $row[$feed->get('title2')] : ''); |
| 97 | 9575 | acydburn | |
| 98 | 11003 | git-gate | $published = ($feed->get('published') !== NULL) ? (int) $row[$feed->get('published')] : 0; |
| 99 | 11003 | git-gate | $updated = ($feed->get('updated') !== NULL) ? (int) $row[$feed->get('updated')] : 0; |
| 100 | 10281 | bantu | |
| 101 | 9575 | acydburn | $item_row = array( |
| 102 | 9575 | acydburn | 'author' => ($feed->get('creator') !== NULL) ? $row[$feed->get('creator')] : '', |
| 103 | 11003 | git-gate | 'published' => ($published > 0) ? feed_format_date($published) : '', |
| 104 | 11003 | git-gate | 'updated' => ($updated > 0) ? feed_format_date($updated) : '', |
| 105 | 9575 | acydburn | 'link' => '', |
| 106 | 9575 | acydburn | 'title' => censor_text($title), |
| 107 | 10345 | bantu | 'category' => ($config['feed_item_statistics'] && !empty($row['forum_id'])) ? $board_url . '/viewforum.' . $phpEx . '?f=' . $row['forum_id'] : '', |
| 108 | 10345 | bantu | 'category_name' => ($config['feed_item_statistics'] && isset($row['forum_name'])) ? $row['forum_name'] : '', |
| 109 | 9575 | acydburn | 'description' => censor_text(feed_generate_content($row[$feed->get('text')], $row[$feed->get('bbcode_uid')], $row[$feed->get('bitfield')], $options)), |
| 110 | 9575 | acydburn | 'statistics' => '', |
| 111 | 9575 | acydburn | ); |
| 112 | 9575 | acydburn | |
| 113 | 9575 | acydburn | // Adjust items, fill link, etc.
|
| 114 | 9575 | acydburn | $feed->adjust_item($item_row, $row); |
| 115 | 9575 | acydburn | |
| 116 | 9575 | acydburn | $item_vars[] = $item_row; |
| 117 | 10281 | bantu | |
| 118 | 11003 | git-gate | $feed_updated_time = max($feed_updated_time, $published, $updated); |
| 119 | 9575 | acydburn | } |
| 120 | 9575 | acydburn | |
| 121 | 10281 | bantu | // If we do not have any items at all, sending the current time is better than sending no time.
|
| 122 | 10281 | bantu | if (!$feed_updated_time) |
| 123 | 10281 | bantu | {
|
| 124 | 10281 | bantu | $feed_updated_time = time(); |
| 125 | 10281 | bantu | } |
| 126 | 10281 | bantu | |
| 127 | 10281 | bantu | // Some default assignments
|
| 128 | 10281 | bantu | // FEED_IMAGE is not used (atom)
|
| 129 | 10289 | bantu | $global_vars = array_merge($global_vars, array( |
| 130 | 10281 | bantu | 'FEED_IMAGE' => ($user->img('site_logo', '', false, '', 'src')) ? $board_url . '/' . substr($user->img('site_logo', '', false, '', 'src'), strlen($phpbb_root_path)) : '', |
| 131 | 10281 | bantu | 'SELF_LINK' => feed_append_sid('/feed.' . $phpEx, $params), |
| 132 | 10281 | bantu | 'FEED_LINK' => $board_url . '/index.' . $phpEx, |
| 133 | 10281 | bantu | 'FEED_TITLE' => $config['sitename'], |
| 134 | 10281 | bantu | 'FEED_SUBTITLE' => $config['site_desc'], |
| 135 | 10312 | bantu | 'FEED_UPDATED' => feed_format_date($feed_updated_time), |
| 136 | 10281 | bantu | 'FEED_LANG' => $user->lang['USER_LANG'], |
| 137 | 10281 | bantu | 'FEED_AUTHOR' => $config['sitename'], |
| 138 | 10289 | bantu | )); |
| 139 | 10281 | bantu | |
| 140 | 9575 | acydburn | $feed->close();
|
| 141 | 9575 | acydburn | |
| 142 | 9575 | acydburn | // Output page
|
| 143 | 9575 | acydburn | |
| 144 | 9575 | acydburn | // gzip_compression
|
| 145 | 9575 | acydburn | if ($config['gzip_compress']) |
| 146 | 9575 | acydburn | {
|
| 147 | 9575 | acydburn | if (@extension_loaded('zlib') && !headers_sent()) |
| 148 | 9575 | acydburn | {
|
| 149 | 9575 | acydburn | ob_start('ob_gzhandler');
|
| 150 | 9575 | acydburn | } |
| 151 | 9575 | acydburn | } |
| 152 | 9575 | acydburn | |
| 153 | 9575 | acydburn | // IF debug extra is enabled and admin want to "explain" the page we need to set other headers...
|
| 154 | 10290 | bantu | if (defined('DEBUG_EXTRA') && request_var('explain', 0) && $auth->acl_get('a_')) |
| 155 | 9575 | acydburn | {
|
| 156 | 9575 | acydburn | header('Content-type: text/html; charset=UTF-8'); |
| 157 | 9575 | acydburn | header('Cache-Control: private, no-cache="set-cookie"'); |
| 158 | 9575 | acydburn | header('Expires: 0'); |
| 159 | 9575 | acydburn | header('Pragma: no-cache'); |
| 160 | 9575 | acydburn | |
| 161 | 9575 | acydburn | $mtime = explode(' ', microtime()); |
| 162 | 9575 | acydburn | $totaltime = $mtime[0] + $mtime[1] - $starttime; |
| 163 | 9575 | acydburn | |
| 164 | 9575 | acydburn | if (method_exists($db, 'sql_report')) |
| 165 | 9575 | acydburn | {
|
| 166 | 9575 | acydburn | $db->sql_report('display'); |
| 167 | 9575 | acydburn | } |
| 168 | 9575 | acydburn | |
| 169 | 9575 | acydburn | garbage_collection(); |
| 170 | 9575 | acydburn | exit_handler(); |
| 171 | 9575 | acydburn | } |
| 172 | 9575 | acydburn | |
| 173 | 10290 | bantu | header("Content-Type: application/atom+xml; charset=UTF-8"); |
| 174 | 10290 | bantu | header("Last-Modified: " . gmdate('D, d M Y H:i:s', $feed_updated_time) . ' GMT'); |
| 175 | 10290 | bantu | |
| 176 | 11387 | git-gate | if (!empty($user->data['is_bot'])) |
| 177 | 11387 | git-gate | {
|
| 178 | 11387 | git-gate | // Let reverse proxies know we detected a bot.
|
| 179 | 11387 | git-gate | header('X-PHPBB-IS-BOT: yes'); |
| 180 | 11387 | git-gate | } |
| 181 | 11387 | git-gate | |
| 182 | 9575 | acydburn | echo '<?xml version="1.0" encoding="UTF-8"?>' . "\n"; |
| 183 | 9721 | acydburn | echo '<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="' . $global_vars['FEED_LANG'] . '">' . "\n"; |
| 184 | 9721 | acydburn | echo '<link rel="self" type="application/atom+xml" href="' . $global_vars['SELF_LINK'] . '" />' . "\n\n"; |
| 185 | 9575 | acydburn | |
| 186 | 9721 | acydburn | echo (!empty($global_vars['FEED_TITLE'])) ? '<title>' . $global_vars['FEED_TITLE'] . '</title>' . "\n" : ''; |
| 187 | 9721 | acydburn | echo (!empty($global_vars['FEED_SUBTITLE'])) ? '<subtitle>' . $global_vars['FEED_SUBTITLE'] . '</subtitle>' . "\n" : ''; |
| 188 | 9721 | acydburn | echo (!empty($global_vars['FEED_LINK'])) ? '<link href="' . $global_vars['FEED_LINK'] .'" />' . "\n" : ''; |
| 189 | 9721 | acydburn | echo '<updated>' . $global_vars['FEED_UPDATED'] . '</updated>' . "\n\n"; |
| 190 | 9575 | acydburn | |
| 191 | 9721 | acydburn | echo '<author><name><![CDATA[' . $global_vars['FEED_AUTHOR'] . ']]></name></author>' . "\n"; |
| 192 | 9721 | acydburn | echo '<id>' . $global_vars['SELF_LINK'] . '</id>' . "\n"; |
| 193 | 9575 | acydburn | |
| 194 | 9575 | acydburn | foreach ($item_vars as $row) |
| 195 | 9575 | acydburn | {
|
| 196 | 9721 | acydburn | echo '<entry>' . "\n"; |
| 197 | 9575 | acydburn | |
| 198 | 9575 | acydburn | if (!empty($row['author'])) |
| 199 | 9575 | acydburn | {
|
| 200 | 9721 | acydburn | echo '<author><name><![CDATA[' . $row['author'] . ']]></name></author>' . "\n"; |
| 201 | 9575 | acydburn | } |
| 202 | 9575 | acydburn | |
| 203 | 11003 | git-gate | echo '<updated>' . ((!empty($row['updated'])) ? $row['updated'] : $row['published']) . '</updated>' . "\n"; |
| 204 | 11003 | git-gate | |
| 205 | 11003 | git-gate | if (!empty($row['published'])) |
| 206 | 11003 | git-gate | {
|
| 207 | 11003 | git-gate | echo '<published>' . $row['published'] . '</published>' . "\n"; |
| 208 | 11003 | git-gate | } |
| 209 | 11003 | git-gate | |
| 210 | 9721 | acydburn | echo '<id>' . $row['link'] . '</id>' . "\n"; |
| 211 | 9721 | acydburn | echo '<link href="' . $row['link'] . '"/>' . "\n"; |
| 212 | 9721 | acydburn | echo '<title type="html"><![CDATA[' . $row['title'] . ']]></title>' . "\n\n"; |
| 213 | 9575 | acydburn | |
| 214 | 10348 | bantu | if (!empty($row['category']) && isset($row['category_name']) && $row['category_name'] !== '') |
| 215 | 9575 | acydburn | {
|
| 216 | 9721 | acydburn | echo '<category term="' . $row['category_name'] . '" scheme="' . $row['category'] . '" label="' . $row['category_name'] . '"/>' . "\n"; |
| 217 | 9575 | acydburn | } |
| 218 | 9575 | acydburn | |
| 219 | 9721 | acydburn | echo '<content type="html" xml:base="' . $row['link'] . '"><![CDATA[' . "\n"; |
| 220 | 9575 | acydburn | echo $row['description']; |
| 221 | 9575 | acydburn | |
| 222 | 9575 | acydburn | if (!empty($row['statistics'])) |
| 223 | 9575 | acydburn | {
|
| 224 | 9575 | acydburn | echo '<p>' . $user->lang['STATISTICS'] . ': ' . $row['statistics'] . '</p>'; |
| 225 | 9575 | acydburn | } |
| 226 | 9575 | acydburn | |
| 227 | 10221 | acydburn | echo '<hr />' . "\n" . ']]></content>' . "\n"; |
| 228 | 9721 | acydburn | echo '</entry>' . "\n"; |
| 229 | 9575 | acydburn | } |
| 230 | 9575 | acydburn | |
| 231 | 9721 | acydburn | echo '</feed>'; |
| 232 | 9575 | acydburn | |
| 233 | 9575 | acydburn | garbage_collection(); |
| 234 | 9575 | acydburn | exit_handler(); |
| 235 | 9575 | acydburn | |
| 236 | 9575 | acydburn | /**
|
| 237 | 9575 | acydburn | * Run links through append_sid(), prepend generate_board_url() and remove session id |
| 238 | 9575 | acydburn | **/ |
| 239 | 9575 | acydburn | function feed_append_sid($url, $params) |
| 240 | 9575 | acydburn | {
|
| 241 | 9575 | acydburn | global $board_url; |
| 242 | 9575 | acydburn | |
| 243 | 10244 | acydburn | return append_sid($board_url . $url, $params, true, ''); |
| 244 | 9575 | acydburn | } |
| 245 | 9575 | acydburn | |
| 246 | 9575 | acydburn | /**
|
| 247 | 10312 | bantu | * Generate ISO 8601 date string (RFC 3339) |
| 248 | 10312 | bantu | **/ |
| 249 | 10312 | bantu | function feed_format_date($time) |
| 250 | 10312 | bantu | {
|
| 251 | 10312 | bantu | static $zone_offset; |
| 252 | 10312 | bantu | static $offset_string; |
| 253 | 10312 | bantu | |
| 254 | 10312 | bantu | if (empty($offset_string)) |
| 255 | 10312 | bantu | {
|
| 256 | 10312 | bantu | global $user; |
| 257 | 10312 | bantu | |
| 258 | 10312 | bantu | $zone_offset = (int) $user->timezone + (int) $user->dst; |
| 259 | 10312 | bantu | |
| 260 | 10312 | bantu | $sign = ($zone_offset < 0) ? '-' : '+'; |
| 261 | 10312 | bantu | $time_offset = abs($zone_offset); |
| 262 | 10312 | bantu | |
| 263 | 10312 | bantu | $offset_seconds = $time_offset % 3600; |
| 264 | 10312 | bantu | $offset_minutes = $offset_seconds / 60; |
| 265 | 10312 | bantu | $offset_hours = ($time_offset - $offset_seconds) / 3600; |
| 266 | 10312 | bantu | |
| 267 | 10312 | bantu | $offset_string = sprintf("%s%02d:%02d", $sign, $offset_hours, $offset_minutes); |
| 268 | 10312 | bantu | } |
| 269 | 10312 | bantu | |
| 270 | 10312 | bantu | return gmdate("Y-m-d\TH:i:s", $time + $zone_offset) . $offset_string; |
| 271 | 10312 | bantu | } |
| 272 | 10312 | bantu | |
| 273 | 10312 | bantu | /**
|
| 274 | 9575 | acydburn | * Generate text content |
| 275 | 9575 | acydburn | **/ |
| 276 | 9575 | acydburn | function feed_generate_content($content, $uid, $bitfield, $options) |
| 277 | 9575 | acydburn | {
|
| 278 | 9575 | acydburn | global $user, $config, $phpbb_root_path, $phpEx, $board_url; |
| 279 | 9575 | acydburn | |
| 280 | 9575 | acydburn | if (empty($content)) |
| 281 | 9575 | acydburn | {
|
| 282 | 9575 | acydburn | return ''; |
| 283 | 9575 | acydburn | } |
| 284 | 9575 | acydburn | |
| 285 | 9575 | acydburn | // Prepare some bbcodes for better parsing
|
| 286 | 9575 | acydburn | $content = preg_replace("#\[quote(=".*?")?:$uid\]\s*(.*?)\s*\[/quote:$uid\]#si", "[quote$1:$uid]<br />$2<br />[/quote:$uid]", $content); |
| 287 | 9575 | acydburn | |
| 288 | 9575 | acydburn | $content = generate_text_for_display($content, $uid, $bitfield, $options); |
| 289 | 9575 | acydburn | |
| 290 | 9663 | acydburn | // Add newlines
|
| 291 | 9663 | acydburn | $content = str_replace('<br />', '<br />' . "\n", $content); |
| 292 | 9663 | acydburn | |
| 293 | 10714 | git-gate | // Convert smiley Relative paths to Absolute path, Windows style
|
| 294 | 10714 | git-gate | $content = str_replace($phpbb_root_path . $config['smilies_path'], $board_url . '/' . $config['smilies_path'], $content); |
| 295 | 9575 | acydburn | |
| 296 | 9575 | acydburn | // Remove "Select all" link and mouse events
|
| 297 | 10202 | bantu | $content = str_replace('<a href="#" onclick="selectCode(this); return false;">' . $user->lang['SELECT_ALL_CODE'] . '</a>', '', $content); |
| 298 | 9575 | acydburn | $content = preg_replace('#(onkeypress|onclick)="(.*?)"#si', '', $content); |
| 299 | 9575 | acydburn | |
| 300 | 9721 | acydburn | // Firefox does not support CSS for feeds, though
|
| 301 | 9721 | acydburn | |
| 302 | 9575 | acydburn | // Remove font sizes
|
| 303 | 9721 | acydburn | // $content = preg_replace('#<span style="font-size: [0-9]+%; line-height: [0-9]+%;">([^>]+)</span>#iU', '\1', $content);
|
| 304 | 9575 | acydburn | |
| 305 | 9575 | acydburn | // Make text strong :P
|
| 306 | 9721 | acydburn | // $content = preg_replace('#<span style="font-weight: bold?">(.*?)</span>#iU', '<strong>\1</strong>', $content);
|
| 307 | 9575 | acydburn | |
| 308 | 9575 | acydburn | // Italic
|
| 309 | 9721 | acydburn | // $content = preg_replace('#<span style="font-style: italic?">([^<]+)</span>#iU', '<em>\1</em>', $content);
|
| 310 | 9575 | acydburn | |
| 311 | 9575 | acydburn | // Underline
|
| 312 | 9721 | acydburn | // $content = preg_replace('#<span style="text-decoration: underline?">([^<]+)</span>#iU', '<u>\1</u>', $content);
|
| 313 | 9575 | acydburn | |
| 314 | 9575 | acydburn | // Remove embed Windows Media Streams
|
| 315 | 9575 | acydburn | $content = preg_replace( '#<\!--\[if \!IE\]>-->([^[]+)<\!--<!\[endif\]-->#si', '', $content); |
| 316 | 9575 | acydburn | |
| 317 | 9575 | acydburn | // Do not use < and >, because we want to retain code contained in [code][/code]
|
| 318 | 9575 | acydburn | |
| 319 | 9575 | acydburn | // Remove embed and objects
|
| 320 | 9575 | acydburn | $content = preg_replace( '#<(object|embed)(.*?) (value|src)=(.*?) ([^[]+)(object|embed)>#si',' <a href=$4 target="_blank"><strong>$1</strong></a> ',$content); |
| 321 | 9575 | acydburn | |
| 322 | 9575 | acydburn | // Remove some specials html tag, because somewhere there are a mod to allow html tags ;)
|
| 323 | 9575 | acydburn | $content = preg_replace( '#<(script|iframe)([^[]+)\1>#siU', ' <strong>$1</strong> ', $content); |
| 324 | 9575 | acydburn | |
| 325 | 9575 | acydburn | // Remove Comments from inline attachments [ia]
|
| 326 | 9575 | acydburn | $content = preg_replace('#<div class="(inline-attachment|attachtitle)">(.*?)<!-- ia(.*?) -->(.*?)<!-- ia(.*?) -->(.*?)</div>#si','$4',$content); |
| 327 | 9575 | acydburn | |
| 328 | 9575 | acydburn | // Replace some entities with their unicode counterpart
|
| 329 | 9575 | acydburn | $entities = array( |
| 330 | 9870 | bantu | ' ' => "\xC2\xA0", |
| 331 | 9870 | bantu | '•' => "\xE2\x80\xA2", |
| 332 | 9870 | bantu | '·' => "\xC2\xB7", |
| 333 | 9870 | bantu | '©' => "\xC2\xA9", |
| 334 | 9575 | acydburn | ); |
| 335 | 9575 | acydburn | |
| 336 | 9575 | acydburn | $content = str_replace(array_keys($entities), array_values($entities), $content); |
| 337 | 9575 | acydburn | |
| 338 | 9721 | acydburn | // Remove CDATA blocks. ;)
|
| 339 | 9721 | acydburn | $content = preg_replace('#\<\!\[CDATA\[(.*?)\]\]\>#s', '', $content); |
| 340 | 9721 | acydburn | |
| 341 | 9575 | acydburn | // Other control characters
|
| 342 | 10388 | bantu | $content = preg_replace('#(?:[\x00-\x1F\x7F]+|(?:\xC2[\x80-\x9F])+)#', '', $content); |
| 343 | 9575 | acydburn | |
| 344 | 9575 | acydburn | return $content; |
| 345 | 9575 | acydburn | } |
| 346 | 9575 | acydburn | |
| 347 | 9575 | acydburn | /**
|
| 348 | 9575 | acydburn | * Factory class to return correct object |
| 349 | 9575 | acydburn | * @package phpBB3 |
| 350 | 9575 | acydburn | */ |
| 351 | 9575 | acydburn | class phpbb_feed_factory |
| 352 | 9575 | acydburn | {
|
| 353 | 9575 | acydburn | /**
|
| 354 | 9575 | acydburn | * Return correct object for specified mode |
| 355 | 9575 | acydburn | * |
| 356 | 9575 | acydburn | * @param string $mode The feeds mode. |
| 357 | 9575 | acydburn | * @param int $forum_id Forum id specified by the script if forum feed provided. |
| 358 | 9575 | acydburn | * @param int $topic_id Topic id specified by the script if topic feed provided. |
| 359 | 9575 | acydburn | * |
| 360 | 9575 | acydburn | * @return object Returns correct feeds object for specified mode. |
| 361 | 9575 | acydburn | */ |
| 362 | 9575 | acydburn | function init($mode, $forum_id, $topic_id) |
| 363 | 9575 | acydburn | {
|
| 364 | 9575 | acydburn | global $config; |
| 365 | 9575 | acydburn | |
| 366 | 9575 | acydburn | switch ($mode) |
| 367 | 9575 | acydburn | {
|
| 368 | 9575 | acydburn | case 'forums': |
| 369 | 9575 | acydburn | if (!$config['feed_overall_forums']) |
| 370 | 9575 | acydburn | {
|
| 371 | 9575 | acydburn | return false; |
| 372 | 9575 | acydburn | } |
| 373 | 9575 | acydburn | |
| 374 | 9575 | acydburn | return new phpbb_feed_forums(); |
| 375 | 9575 | acydburn | break;
|
| 376 | 9575 | acydburn | |
| 377 | 9575 | acydburn | case 'topics': |
| 378 | 10382 | bantu | case 'topics_new': |
| 379 | 10382 | bantu | if (!$config['feed_topics_new']) |
| 380 | 9575 | acydburn | {
|
| 381 | 9575 | acydburn | return false; |
| 382 | 9575 | acydburn | } |
| 383 | 9575 | acydburn | |
| 384 | 9575 | acydburn | return new phpbb_feed_topics(); |
| 385 | 9575 | acydburn | break;
|
| 386 | 9575 | acydburn | |
| 387 | 10380 | bantu | case 'topics_active': |
| 388 | 10380 | bantu | if (!$config['feed_topics_active']) |
| 389 | 10380 | bantu | {
|
| 390 | 10380 | bantu | return false; |
| 391 | 10380 | bantu | } |
| 392 | 10380 | bantu | |
| 393 | 10380 | bantu | return new phpbb_feed_topics_active(); |
| 394 | 10380 | bantu | break;
|
| 395 | 10380 | bantu | |
| 396 | 9575 | acydburn | case 'news': |
| 397 | 9965 | acydburn | global $db; |
| 398 | 9965 | acydburn | |
| 399 | 9965 | acydburn | // Get at least one news forum
|
| 400 | 9965 | acydburn | $sql = 'SELECT forum_id |
| 401 | 9965 | acydburn | FROM ' . FORUMS_TABLE . ' |
| 402 | 9965 | acydburn | WHERE ' . $db->sql_bit_and('forum_options', FORUM_OPTION_FEED_NEWS, '<> 0'); |
| 403 | 9965 | acydburn | $result = $db->sql_query_limit($sql, 1, 0, 600); |
| 404 | 9965 | acydburn | $s_feed_news = (int) $db->sql_fetchfield('forum_id'); |
| 405 | 9965 | acydburn | $db->sql_freeresult($result); |
| 406 | 9965 | acydburn | |
| 407 | 9965 | acydburn | if (!$s_feed_news) |
| 408 | 9575 | acydburn | {
|
| 409 | 9575 | acydburn | return false; |
| 410 | 9575 | acydburn | } |
| 411 | 9575 | acydburn | |
| 412 | 9575 | acydburn | return new phpbb_feed_news(); |
| 413 | 9575 | acydburn | break;
|
| 414 | 9575 | acydburn | |
| 415 | 9575 | acydburn | default:
|
| 416 | 10357 | bantu | if ($topic_id && $config['feed_topic']) |
| 417 | 9575 | acydburn | {
|
| 418 | 10357 | bantu | return new phpbb_feed_topic($topic_id); |
| 419 | 9575 | acydburn | } |
| 420 | 10357 | bantu | else if ($forum_id && $config['feed_forum']) |
| 421 | 9575 | acydburn | {
|
| 422 | 10357 | bantu | return new phpbb_feed_forum($forum_id); |
| 423 | 9575 | acydburn | } |
| 424 | 10364 | bantu | else if ($config['feed_overall']) |
| 425 | 10364 | bantu | {
|
| 426 | 10364 | bantu | return new phpbb_feed_overall(); |
| 427 | 10364 | bantu | } |
| 428 | 9575 | acydburn | |
| 429 | 10364 | bantu | return false; |
| 430 | 9575 | acydburn | break;
|
| 431 | 9575 | acydburn | } |
| 432 | 9575 | acydburn | } |
| 433 | 9575 | acydburn | } |
| 434 | 9575 | acydburn | |
| 435 | 9575 | acydburn | /**
|
| 436 | 10315 | bantu | * Base class with some generic functions and settings. |
| 437 | 10315 | bantu | * |
| 438 | 9575 | acydburn | * @package phpBB3 |
| 439 | 9575 | acydburn | */ |
| 440 | 10315 | bantu | class phpbb_feed_base |
| 441 | 9575 | acydburn | {
|
| 442 | 9575 | acydburn | /**
|
| 443 | 9575 | acydburn | * SQL Query to be executed to get feed items |
| 444 | 9575 | acydburn | */ |
| 445 | 10315 | bantu | var $sql = array(); |
| 446 | 9575 | acydburn | |
| 447 | 9575 | acydburn | /**
|
| 448 | 9575 | acydburn | * Keys specified for retrieval of title, content, etc. |
| 449 | 9575 | acydburn | */ |
| 450 | 9575 | acydburn | var $keys = array(); |
| 451 | 9575 | acydburn | |
| 452 | 9575 | acydburn | /**
|
| 453 | 10315 | bantu | * Number of items to fetch. Usually overwritten by $config['feed_something'] |
| 454 | 9575 | acydburn | */ |
| 455 | 10315 | bantu | var $num_items = 15; |
| 456 | 9575 | acydburn | |
| 457 | 9575 | acydburn | /**
|
| 458 | 9663 | acydburn | * Separator for title elements to separate items (for example forum / topic) |
| 459 | 9663 | acydburn | */ |
| 460 | 9870 | bantu | var $separator = "\xE2\x80\xA2"; // • |
| 461 | 9663 | acydburn | |
| 462 | 9663 | acydburn | /**
|
| 463 | 10285 | bantu | * Separator for the statistics row (Posted by, post date, replies, etc.) |
| 464 | 10285 | bantu | */ |
| 465 | 10285 | bantu | var $separator_stats = "\xE2\x80\x94"; // — |
| 466 | 10285 | bantu | |
| 467 | 10286 | bantu | /**
|
| 468 | 10315 | bantu | * Constructor |
| 469 | 9575 | acydburn | */ |
| 470 | 10315 | bantu | function phpbb_feed_base() |
| 471 | 9575 | acydburn | {
|
| 472 | 10359 | bantu | global $config; |
| 473 | 10359 | bantu | |
| 474 | 9575 | acydburn | $this->set_keys();
|
| 475 | 10359 | bantu | |
| 476 | 10359 | bantu | // Allow num_items to be string
|
| 477 | 10359 | bantu | if (is_string($this->num_items)) |
| 478 | 10359 | bantu | {
|
| 479 | 10359 | bantu | $this->num_items = (int) $config[$this->num_items]; |
| 480 | 10359 | bantu | |
| 481 | 10359 | bantu | // A precaution
|
| 482 | 10359 | bantu | if (!$this->num_items) |
| 483 | 10359 | bantu | {
|
| 484 | 10359 | bantu | $this->num_items = 10; |
| 485 | 10359 | bantu | } |
| 486 | 10359 | bantu | } |
| 487 | 9575 | acydburn | } |
| 488 | 9575 | acydburn | |
| 489 | 10315 | bantu | /**
|
| 490 | 10315 | bantu | * Set keys. |
| 491 | 10315 | bantu | */ |
| 492 | 9575 | acydburn | function set_keys() |
| 493 | 9575 | acydburn | {
|
| 494 | 9575 | acydburn | } |
| 495 | 9575 | acydburn | |
| 496 | 10315 | bantu | /**
|
| 497 | 10315 | bantu | * Open feed |
| 498 | 10315 | bantu | */ |
| 499 | 9575 | acydburn | function open() |
| 500 | 9575 | acydburn | {
|
| 501 | 9575 | acydburn | } |
| 502 | 9575 | acydburn | |
| 503 | 10315 | bantu | /**
|
| 504 | 10315 | bantu | * Close feed |
| 505 | 10315 | bantu | */ |
| 506 | 9575 | acydburn | function close() |
| 507 | 9575 | acydburn | {
|
| 508 | 10315 | bantu | global $db; |
| 509 | 10315 | bantu | |
| 510 | 9575 | acydburn | if (!empty($this->result)) |
| 511 | 9575 | acydburn | {
|
| 512 | 9575 | acydburn | $db->sql_freeresult($this->result); |
| 513 | 9575 | acydburn | } |
| 514 | 9575 | acydburn | } |
| 515 | 9575 | acydburn | |
| 516 | 9575 | acydburn | /**
|
| 517 | 9575 | acydburn | * Set key |
| 518 | 9575 | acydburn | */ |
| 519 | 9575 | acydburn | function set($key, $value) |
| 520 | 9575 | acydburn | {
|
| 521 | 9575 | acydburn | $this->keys[$key] = $value; |
| 522 | 9575 | acydburn | } |
| 523 | 9575 | acydburn | |
| 524 | 9575 | acydburn | /**
|
| 525 | 9575 | acydburn | * Get key |
| 526 | 9575 | acydburn | */ |
| 527 | 9575 | acydburn | function get($key) |
| 528 | 9575 | acydburn | {
|
| 529 | 9575 | acydburn | return (isset($this->keys[$key])) ? $this->keys[$key] : NULL; |
| 530 | 9575 | acydburn | } |
| 531 | 9575 | acydburn | |
| 532 | 10351 | bantu | function get_readable_forums() |
| 533 | 10351 | bantu | {
|
| 534 | 10351 | bantu | global $auth; |
| 535 | 10401 | bantu | static $forum_ids; |
| 536 | 10351 | bantu | |
| 537 | 10401 | bantu | if (!isset($forum_ids)) |
| 538 | 10401 | bantu | {
|
| 539 | 10570 | git-gate | $forum_ids = array_keys($auth->acl_getf('f_read', true)); |
| 540 | 10401 | bantu | } |
| 541 | 10401 | bantu | |
| 542 | 10401 | bantu | return $forum_ids; |
| 543 | 10351 | bantu | } |
| 544 | 10351 | bantu | |
| 545 | 10401 | bantu | function get_moderator_approve_forums() |
| 546 | 10400 | bantu | {
|
| 547 | 10400 | bantu | global $auth; |
| 548 | 10401 | bantu | static $forum_ids; |
| 549 | 10400 | bantu | |
| 550 | 10401 | bantu | if (!isset($forum_ids)) |
| 551 | 10401 | bantu | {
|
| 552 | 10592 | git-gate | $forum_ids = array_keys($auth->acl_getf('m_approve', true)); |
| 553 | 10401 | bantu | } |
| 554 | 10401 | bantu | |
| 555 | 10401 | bantu | return $forum_ids; |
| 556 | 10400 | bantu | } |
| 557 | 10400 | bantu | |
| 558 | 10595 | git-gate | function is_moderator_approve_forum($forum_id) |
| 559 | 10595 | git-gate | {
|
| 560 | 10595 | git-gate | static $forum_ids; |
| 561 | 10595 | git-gate | |
| 562 | 10595 | git-gate | if (!isset($forum_ids)) |
| 563 | 10595 | git-gate | {
|
| 564 | 10595 | git-gate | $forum_ids = array_flip($this->get_moderator_approve_forums()); |
| 565 | 10595 | git-gate | } |
| 566 | 10595 | git-gate | |
| 567 | 10595 | git-gate | if (!$forum_id) |
| 568 | 10595 | git-gate | {
|
| 569 | 10595 | git-gate | // Global announcement, your a moderator in any forum than it's okay.
|
| 570 | 10595 | git-gate | return (!empty($forum_ids)) ? true : false; |
| 571 | 10595 | git-gate | } |
| 572 | 10595 | git-gate | |
| 573 | 10595 | git-gate | return (isset($forum_ids[$forum_id])) ? true : false; |
| 574 | 10595 | git-gate | } |
| 575 | 10595 | git-gate | |
| 576 | 10351 | bantu | function get_excluded_forums() |
| 577 | 10351 | bantu | {
|
| 578 | 10351 | bantu | global $db, $cache; |
| 579 | 10351 | bantu | static $forum_ids; |
| 580 | 10351 | bantu | |
| 581 | 10354 | bantu | // Matches acp/acp_board.php
|
| 582 | 10351 | bantu | $cache_name = 'feed_excluded_forum_ids'; |
| 583 | 10351 | bantu | |
| 584 | 10351 | bantu | if (!isset($forum_ids) && ($forum_ids = $cache->get('_' . $cache_name)) === false) |
| 585 | 10351 | bantu | {
|
| 586 | 10351 | bantu | $sql = 'SELECT forum_id |
| 587 | 10351 | bantu | FROM ' . FORUMS_TABLE . ' |
| 588 | 10351 | bantu | WHERE ' . $db->sql_bit_and('forum_options', FORUM_OPTION_FEED_EXCLUDE, '<> 0'); |
| 589 | 10351 | bantu | $result = $db->sql_query($sql); |
| 590 | 10351 | bantu | |
| 591 | 10351 | bantu | $forum_ids = array(); |
| 592 | 10351 | bantu | while ($forum_id = (int) $db->sql_fetchfield('forum_id')) |
| 593 | 10351 | bantu | {
|
| 594 | 10351 | bantu | $forum_ids[$forum_id] = $forum_id; |
| 595 | 10351 | bantu | } |
| 596 | 10351 | bantu | $db->sql_freeresult($result); |
| 597 | 10351 | bantu | |
| 598 | 10354 | bantu | $cache->put('_' . $cache_name, $forum_ids); |
| 599 | 10351 | bantu | } |
| 600 | 10351 | bantu | |
| 601 | 10351 | bantu | return $forum_ids; |
| 602 | 10351 | bantu | } |
| 603 | 10351 | bantu | |
| 604 | 10351 | bantu | function is_excluded_forum($forum_id) |
| 605 | 10351 | bantu | {
|
| 606 | 10351 | bantu | $forum_ids = $this->get_excluded_forums(); |
| 607 | 10351 | bantu | |
| 608 | 10351 | bantu | return isset($forum_ids[$forum_id]) ? true : false; |
| 609 | 10351 | bantu | } |
| 610 | 10351 | bantu | |
| 611 | 10318 | bantu | function get_passworded_forums() |
| 612 | 10318 | bantu | {
|
| 613 | 11385 | git-gate | global $user; |
| 614 | 10318 | bantu | |
| 615 | 11385 | git-gate | return $user->get_passworded_forums(); |
| 616 | 9575 | acydburn | } |
| 617 | 9575 | acydburn | |
| 618 | 10315 | bantu | function get_item() |
| 619 | 10315 | bantu | {
|
| 620 | 10315 | bantu | global $db, $cache; |
| 621 | 10358 | bantu | static $result; |
| 622 | 10315 | bantu | |
| 623 | 10358 | bantu | if (!isset($result)) |
| 624 | 10315 | bantu | {
|
| 625 | 10358 | bantu | if (!$this->get_sql()) |
| 626 | 10315 | bantu | {
|
| 627 | 10358 | bantu | return false; |
| 628 | 10315 | bantu | } |
| 629 | 10315 | bantu | |
| 630 | 10358 | bantu | // Query database
|
| 631 | 10358 | bantu | $sql = $db->sql_build_query('SELECT', $this->sql); |
| 632 | 10358 | bantu | $result = $db->sql_query_limit($sql, $this->num_items); |
| 633 | 10315 | bantu | } |
| 634 | 10315 | bantu | |
| 635 | 10358 | bantu | return $db->sql_fetchrow($result); |
| 636 | 10315 | bantu | } |
| 637 | 10347 | bantu | |
| 638 | 10347 | bantu | function user_viewprofile($row) |
| 639 | 10347 | bantu | {
|
| 640 | 10347 | bantu | global $phpEx, $user; |
| 641 | 10347 | bantu | |
| 642 | 10347 | bantu | $author_id = (int) $row[$this->get('author_id')]; |
| 643 | 10347 | bantu | |
| 644 | 10347 | bantu | if ($author_id == ANONYMOUS) |
| 645 | 10347 | bantu | {
|
| 646 | 10347 | bantu | // Since we cannot link to a profile, we just return GUEST
|
| 647 | 10347 | bantu | // instead of $row['username']
|
| 648 | 10347 | bantu | return $user->lang['GUEST']; |
| 649 | 10347 | bantu | } |
| 650 | 10347 | bantu | |
| 651 | 10347 | bantu | return '<a href="' . feed_append_sid('/memberlist.' . $phpEx, 'mode=viewprofile&u=' . $author_id) . '">' . $row[$this->get('creator')] . '</a>'; |
| 652 | 10347 | bantu | } |
| 653 | 10315 | bantu | } |
| 654 | 10315 | bantu | |
| 655 | 10315 | bantu | /**
|
| 656 | 10357 | bantu | * Abstract class for post based feeds |
| 657 | 10357 | bantu | * |
| 658 | 10357 | bantu | * @package phpBB3 |
| 659 | 10357 | bantu | */ |
| 660 | 10357 | bantu | class phpbb_feed_post_base extends phpbb_feed_base |
| 661 | 10357 | bantu | {
|
| 662 | 10366 | bantu | var $num_items = 'feed_limit_post'; |
| 663 | 10359 | bantu | |
| 664 | 10357 | bantu | function set_keys() |
| 665 | 10357 | bantu | {
|
| 666 | 10357 | bantu | $this->set('title', 'post_subject'); |
| 667 | 10357 | bantu | $this->set('title2', 'topic_title'); |
| 668 | 10357 | bantu | |
| 669 | 10357 | bantu | $this->set('author_id', 'user_id'); |
| 670 | 10357 | bantu | $this->set('creator', 'username'); |
| 671 | 11003 | git-gate | $this->set('published', 'post_time'); |
| 672 | 11003 | git-gate | $this->set('updated', 'post_edit_time'); |
| 673 | 10357 | bantu | $this->set('text', 'post_text'); |
| 674 | 10357 | bantu | |
| 675 | 10357 | bantu | $this->set('bitfield', 'bbcode_bitfield'); |
| 676 | 10357 | bantu | $this->set('bbcode_uid','bbcode_uid'); |
| 677 | 10357 | bantu | |
| 678 | 10357 | bantu | $this->set('enable_bbcode', 'enable_bbcode'); |
| 679 | 10357 | bantu | $this->set('enable_smilies', 'enable_smilies'); |
| 680 | 10357 | bantu | $this->set('enable_magic_url', 'enable_magic_url'); |
| 681 | 10357 | bantu | } |
| 682 | 10357 | bantu | |
| 683 | 10357 | bantu | function adjust_item(&$item_row, &$row) |
| 684 | 10357 | bantu | {
|
| 685 | 10357 | bantu | global $phpEx, $config, $user; |
| 686 | 10357 | bantu | |
| 687 | 10357 | bantu | $item_row['link'] = feed_append_sid('/viewtopic.' . $phpEx, "t={$row['topic_id']}&p={$row['post_id']}#p{$row['post_id']}"); |
| 688 | 10357 | bantu | |
| 689 | 10357 | bantu | if ($config['feed_item_statistics']) |
| 690 | 10357 | bantu | {
|
| 691 | 10357 | bantu | $item_row['statistics'] = $user->lang['POSTED'] . ' ' . $user->lang['POST_BY_AUTHOR'] . ' ' . $this->user_viewprofile($row) |
| 692 | 11003 | git-gate | . ' ' . $this->separator_stats . ' ' . $user->format_date($row[$this->get('published')]) |
| 693 | 10595 | git-gate | . (($this->is_moderator_approve_forum($row['forum_id']) && !$row['post_approved']) ? ' ' . $this->separator_stats . ' ' . $user->lang['POST_UNAPPROVED'] : ''); |
| 694 | 10357 | bantu | } |
| 695 | 10357 | bantu | } |
| 696 | 10357 | bantu | } |
| 697 | 10357 | bantu | |
| 698 | 10357 | bantu | /**
|
| 699 | 10355 | bantu | * Abstract class for topic based feeds |
| 700 | 10355 | bantu | * |
| 701 | 10355 | bantu | * @package phpBB3 |
| 702 | 10355 | bantu | */ |
| 703 | 10355 | bantu | class phpbb_feed_topic_base extends phpbb_feed_base |
| 704 | 10355 | bantu | {
|
| 705 | 10366 | bantu | var $num_items = 'feed_limit_topic'; |
| 706 | 10366 | bantu | |
| 707 | 10355 | bantu | function set_keys() |
| 708 | 10355 | bantu | {
|
| 709 | 10355 | bantu | $this->set('title', 'topic_title'); |
| 710 | 10355 | bantu | $this->set('title2', 'forum_name'); |
| 711 | 10355 | bantu | |
| 712 | 10355 | bantu | $this->set('author_id', 'topic_poster'); |
| 713 | 10355 | bantu | $this->set('creator', 'topic_first_poster_name'); |
| 714 | 11003 | git-gate | $this->set('published', 'post_time'); |
| 715 | 11003 | git-gate | $this->set('updated', 'post_edit_time'); |
| 716 | 10355 | bantu | $this->set('text', 'post_text'); |
| 717 | 10355 | bantu | |
| 718 | 10355 | bantu | $this->set('bitfield', 'bbcode_bitfield'); |
| 719 | 10355 | bantu | $this->set('bbcode_uid','bbcode_uid'); |
| 720 | 10355 | bantu | |
| 721 | 10355 | bantu | $this->set('enable_bbcode', 'enable_bbcode'); |
| 722 | 10355 | bantu | $this->set('enable_smilies', 'enable_smilies'); |
| 723 | 10355 | bantu | $this->set('enable_magic_url', 'enable_magic_url'); |
| 724 | 10355 | bantu | } |
| 725 | 10355 | bantu | |
| 726 | 10355 | bantu | function adjust_item(&$item_row, &$row) |
| 727 | 10355 | bantu | {
|
| 728 | 10355 | bantu | global $phpEx, $config, $user; |
| 729 | 10355 | bantu | |
| 730 | 10355 | bantu | $item_row['link'] = feed_append_sid('/viewtopic.' . $phpEx, 't=' . $row['topic_id'] . '&p=' . $row['post_id'] . '#p' . $row['post_id']); |
| 731 | 10355 | bantu | |
| 732 | 10355 | bantu | if ($config['feed_item_statistics']) |
| 733 | 10355 | bantu | {
|
| 734 | 10355 | bantu | $item_row['statistics'] = $user->lang['POSTED'] . ' ' . $user->lang['POST_BY_AUTHOR'] . ' ' . $this->user_viewprofile($row) |
| 735 | 11003 | git-gate | . ' ' . $this->separator_stats . ' ' . $user->format_date($row[$this->get('published')]) |
| 736 | 10595 | git-gate | . ' ' . $this->separator_stats . ' ' . $user->lang['REPLIES'] . ' ' . (($this->is_moderator_approve_forum($row['forum_id'])) ? $row['topic_replies_real'] : $row['topic_replies']) |
| 737 | 10595 | git-gate | . ' ' . $this->separator_stats . ' ' . $user->lang['VIEWS'] . ' ' . $row['topic_views'] |
| 738 | 10595 | git-gate | . (($this->is_moderator_approve_forum($row['forum_id']) && ($row['topic_replies_real'] != $row['topic_replies'])) ? ' ' . $this->separator_stats . ' ' . $user->lang['POSTS_UNAPPROVED'] : ''); |
| 739 | 10355 | bantu | } |
| 740 | 10355 | bantu | } |
| 741 | 10355 | bantu | } |
| 742 | 10355 | bantu | |
| 743 | 10355 | bantu | /**
|
| 744 | 10357 | bantu | * Board wide feed (aka overall feed) |
| 745 | 10315 | bantu | * |
| 746 | 10357 | bantu | * This will give you the newest {$this->num_items} posts
|
| 747 | 10357 | bantu | * from the whole board. |
| 748 | 10357 | bantu | * |
| 749 | 10315 | bantu | * @package phpBB3 |
| 750 | 10315 | bantu | */ |
| 751 | 10357 | bantu | class phpbb_feed_overall extends phpbb_feed_post_base |
| 752 | 10315 | bantu | {
|
| 753 | 10357 | bantu | function get_sql() |
| 754 | 10357 | bantu | {
|
| 755 | 10400 | bantu | global $auth, $db; |
| 756 | 10315 | bantu | |
| 757 | 10357 | bantu | $forum_ids = array_diff($this->get_readable_forums(), $this->get_excluded_forums(), $this->get_passworded_forums()); |
| 758 | 10357 | bantu | if (empty($forum_ids)) |
| 759 | 10357 | bantu | {
|
| 760 | 10357 | bantu | return false; |
| 761 | 10357 | bantu | } |
| 762 | 10315 | bantu | |
| 763 | 10357 | bantu | // Add global forum id
|
| 764 | 10357 | bantu | $forum_ids[] = 0; |
| 765 | 10315 | bantu | |
| 766 | 10404 | bantu | // m_approve forums
|
| 767 | 10404 | bantu | $fid_m_approve = $this->get_moderator_approve_forums(); |
| 768 | 10404 | bantu | $sql_m_approve = (!empty($fid_m_approve)) ? 'OR ' . $db->sql_in_set('forum_id', $fid_m_approve) : ''; |
| 769 | 10404 | bantu | |
| 770 | 10400 | bantu | // Determine topics with recent activity
|
| 771 | 10400 | bantu | $sql = 'SELECT topic_id, topic_last_post_time |
| 772 | 10400 | bantu | FROM ' . TOPICS_TABLE . ' |
| 773 | 10400 | bantu | WHERE ' . $db->sql_in_set('forum_id', $forum_ids) . ' |
| 774 | 10403 | bantu | AND topic_moved_id = 0 |
| 775 | 10400 | bantu | AND (topic_approved = 1 |
| 776 | 10404 | bantu | ' . $sql_m_approve . ') |
| 777 | 10400 | bantu | ORDER BY topic_last_post_time DESC';
|
| 778 | 10357 | bantu | $result = $db->sql_query_limit($sql, $this->num_items); |
| 779 | 10315 | bantu | |
| 780 | 10400 | bantu | $topic_ids = array(); |
| 781 | 10402 | bantu | $min_post_time = 0; |
| 782 | 10400 | bantu | while ($row = $db->sql_fetchrow()) |
| 783 | 10357 | bantu | {
|
| 784 | 10400 | bantu | $topic_ids[] = (int) $row['topic_id']; |
| 785 | 10402 | bantu | |
| 786 | 10402 | bantu | $min_post_time = (int) $row['topic_last_post_time']; |
| 787 | 10357 | bantu | } |
| 788 | 10357 | bantu | $db->sql_freeresult($result); |
| 789 | 10315 | bantu | |
| 790 | 10400 | bantu | if (empty($topic_ids)) |
| 791 | 10398 | bantu | {
|
| 792 | 10398 | bantu | return false; |
| 793 | 10398 | bantu | } |
| 794 | 10398 | bantu | |
| 795 | 10400 | bantu | // Get the actual data
|
| 796 | 10357 | bantu | $this->sql = array( |
| 797 | 10400 | bantu | 'SELECT' => 'f.forum_id, f.forum_name, ' . |
| 798 | 11003 | git-gate | '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, ' .
|
| 799 | 10357 | bantu | 'u.username, u.user_id',
|
| 800 | 10357 | bantu | 'FROM' => array( |
| 801 | 10589 | git-gate | USERS_TABLE => 'u', |
| 802 | 10357 | bantu | POSTS_TABLE => 'p', |
| 803 | 10357 | bantu | ), |
| 804 | 10357 | bantu | 'LEFT_JOIN' => array( |
| 805 | 10357 | bantu | array(
|
| 806 | 10357 | bantu | 'FROM' => array(FORUMS_TABLE => 'f'), |
| 807 | 10357 | bantu | 'ON' => 'f.forum_id = p.forum_id', |
| 808 | 10357 | bantu | ), |
| 809 | 10357 | bantu | ), |
| 810 | 10400 | bantu | 'WHERE' => $db->sql_in_set('p.topic_id', $topic_ids) . ' |
| 811 | 10400 | bantu | AND (p.post_approved = 1 |
| 812 | 10404 | bantu | ' . str_replace('forum_id', 'p.forum_id', $sql_m_approve) . ') |
| 813 | 10402 | bantu | AND p.post_time >= ' . $min_post_time . ' |
| 814 | 10357 | bantu | AND u.user_id = p.poster_id',
|
| 815 | 10357 | bantu | 'ORDER_BY' => 'p.post_time DESC', |
| 816 | 10357 | bantu | ); |
| 817 | 10357 | bantu | |
| 818 | 10357 | bantu | return true; |
| 819 | 10315 | bantu | } |
| 820 | 10315 | bantu | |
| 821 | 10357 | bantu | function adjust_item(&$item_row, &$row) |
| 822 | 10315 | bantu | {
|
| 823 | 10357 | bantu | parent::adjust_item($item_row, $row); |
| 824 | 10315 | bantu | |
| 825 | 10357 | bantu | $item_row['title'] = (isset($row['forum_name']) && $row['forum_name'] !== '') ? $row['forum_name'] . ' ' . $this->separator . ' ' . $item_row['title'] : $item_row['title']; |
| 826 | 10357 | bantu | } |
| 827 | 10357 | bantu | } |
| 828 | 10315 | bantu | |
| 829 | 10357 | bantu | /**
|
| 830 | 10357 | bantu | * Forum feed |
| 831 | 10357 | bantu | * |
| 832 | 10357 | bantu | * This will give you the last {$this->num_items} posts made
|
| 833 | 10405 | bantu | * within a specific forum. |
| 834 | 10357 | bantu | * |
| 835 | 10357 | bantu | * @package phpBB3 |
| 836 | 10357 | bantu | */ |
| 837 | 10357 | bantu | class phpbb_feed_forum extends phpbb_feed_post_base |
| 838 | 10357 | bantu | {
|
| 839 | 10357 | bantu | var $forum_id = 0; |
| 840 | 10357 | bantu | var $forum_data = array(); |
| 841 | 10315 | bantu | |
| 842 | 10357 | bantu | function phpbb_feed_forum($forum_id) |
| 843 | 10357 | bantu | {
|
| 844 | 10357 | bantu | parent::phpbb_feed_base();
|
| 845 | 10357 | bantu | |
| 846 | 10357 | bantu | $this->forum_id = (int) $forum_id; |
| 847 | 10315 | bantu | } |
| 848 | 10315 | bantu | |
| 849 | 10315 | bantu | function open() |
| 850 | 10315 | bantu | {
|
| 851 | 10357 | bantu | global $db, $auth; |
| 852 | 10315 | bantu | |
| 853 | 10357 | bantu | // Check if forum exists
|
| 854 | 10405 | bantu | $sql = 'SELECT forum_id, forum_name, forum_password, forum_type, forum_options |
| 855 | 10357 | bantu | FROM ' . FORUMS_TABLE . ' |
| 856 | 10357 | bantu | WHERE forum_id = ' . $this->forum_id; |
| 857 | 10357 | bantu | $result = $db->sql_query($sql); |
| 858 | 10357 | bantu | $this->forum_data = $db->sql_fetchrow($result); |
| 859 | 10357 | bantu | $db->sql_freeresult($result); |
| 860 | 10357 | bantu | |
| 861 | 10357 | bantu | if (empty($this->forum_data)) |
| 862 | 10315 | bantu | {
|
| 863 | 10357 | bantu | trigger_error('NO_FORUM'); |
| 864 | 10357 | bantu | } |
| 865 | 10315 | bantu | |
| 866 | 10405 | bantu | // Forum needs to be postable
|
| 867 | 10405 | bantu | if ($this->forum_data['forum_type'] != FORUM_POST) |
| 868 | 10405 | bantu | {
|
| 869 | 10405 | bantu | trigger_error('NO_FEED'); |
| 870 | 10405 | bantu | } |
| 871 | 10405 | bantu | |
| 872 | 10357 | bantu | // Make sure forum is not excluded from feed
|
| 873 | 10357 | bantu | if (phpbb_optionget(FORUM_OPTION_FEED_EXCLUDE, $this->forum_data['forum_options'])) |
| 874 | 10357 | bantu | {
|
| 875 | 10357 | bantu | trigger_error('NO_FEED'); |
| 876 | 10357 | bantu | } |
| 877 | 10328 | bantu | |
| 878 | 10357 | bantu | // Make sure we can read this forum
|
| 879 | 10357 | bantu | if (!$auth->acl_get('f_read', $this->forum_id)) |
| 880 | 10357 | bantu | {
|
| 881 | 10357 | bantu | trigger_error('SORRY_AUTH_READ'); |
| 882 | 10357 | bantu | } |
| 883 | 10328 | bantu | |
| 884 | 10357 | bantu | // Make sure forum is not passworded or user is authed
|
| 885 | 10357 | bantu | if ($this->forum_data['forum_password']) |
| 886 | 10357 | bantu | {
|
| 887 | 10357 | bantu | $forum_ids_passworded = $this->get_passworded_forums(); |
| 888 | 10315 | bantu | |
| 889 | 10357 | bantu | if (isset($forum_ids_passworded[$this->forum_id])) |
| 890 | 10315 | bantu | {
|
| 891 | 10315 | bantu | trigger_error('SORRY_AUTH_READ'); |
| 892 | 10315 | bantu | } |
| 893 | 10316 | bantu | |
| 894 | 10357 | bantu | unset($forum_ids_passworded); |
| 895 | 10315 | bantu | } |
| 896 | 10315 | bantu | } |
| 897 | 10315 | bantu | |
| 898 | 9575 | acydburn | function get_sql() |
| 899 | 9575 | acydburn | {
|
| 900 | 10357 | bantu | global $auth, $db; |
| 901 | 9575 | acydburn | |
| 902 | 10434 | bantu | $m_approve = ($auth->acl_get('m_approve', $this->forum_id)) ? true : false; |
| 903 | 10405 | bantu | $forum_ids = array(0, $this->forum_id); |
| 904 | 9575 | acydburn | |
| 905 | 10405 | bantu | // Determine topics with recent activity
|
| 906 | 10405 | bantu | $sql = 'SELECT topic_id, topic_last_post_time |
| 907 | 10405 | bantu | FROM ' . TOPICS_TABLE . ' |
| 908 | 10405 | bantu | WHERE ' . $db->sql_in_set('forum_id', $forum_ids) . ' |
| 909 | 10405 | bantu | AND topic_moved_id = 0 |
| 910 | 10405 | bantu | ' . ((!$m_approve) ? 'AND topic_approved = 1' : '') . ' |
| 911 | 10405 | bantu | ORDER BY topic_last_post_time DESC';
|
| 912 | 10405 | bantu | $result = $db->sql_query_limit($sql, $this->num_items); |
| 913 | 9575 | acydburn | |
| 914 | 10405 | bantu | $topic_ids = array(); |
| 915 | 10405 | bantu | $min_post_time = 0; |
| 916 | 10405 | bantu | while ($row = $db->sql_fetchrow()) |
| 917 | 9575 | acydburn | {
|
| 918 | 10405 | bantu | $topic_ids[] = (int) $row['topic_id']; |
| 919 | 10405 | bantu | |
| 920 | 10405 | bantu | $min_post_time = (int) $row['topic_last_post_time']; |
| 921 | 10357 | bantu | } |
| 922 | 10357 | bantu | $db->sql_freeresult($result); |
| 923 | 9575 | acydburn | |
| 924 | 10405 | bantu | if (empty($topic_ids)) |
| 925 | 10357 | bantu | {
|
| 926 | 10357 | bantu | return false; |
| 927 | 10357 | bantu | } |
| 928 | 9575 | acydburn | |
| 929 | 10357 | bantu | $this->sql = array( |
| 930 | 11003 | git-gate | '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, ' . |
| 931 | 10357 | bantu | 'u.username, u.user_id',
|
| 932 | 10357 | bantu | 'FROM' => array( |
| 933 | 10357 | bantu | POSTS_TABLE => 'p', |
| 934 | 10357 | bantu | USERS_TABLE => 'u', |
| 935 | 10357 | bantu | ), |
| 936 | 10405 | bantu | 'WHERE' => $db->sql_in_set('p.topic_id', $topic_ids) . ' |
| 937 | 10405 | bantu | ' . ((!$m_approve) ? 'AND p.post_approved = 1' : '') . ' |
| 938 | 10405 | bantu | AND p.post_time >= ' . $min_post_time . ' |
| 939 | 10405 | bantu | AND p.poster_id = u.user_id',
|
| 940 | 10357 | bantu | 'ORDER_BY' => 'p.post_time DESC', |
| 941 | 10357 | bantu | ); |
| 942 | 10357 | bantu | |
| 943 | 10357 | bantu | return true; |
| 944 | 10357 | bantu | } |
| 945 | 10357 | bantu | |
| 946 | 10357 | bantu | function adjust_item(&$item_row, &$row) |
| 947 | 10357 | bantu | {
|
| 948 | 10357 | bantu | parent::adjust_item($item_row, $row); |
| 949 | 10357 | bantu | |
| 950 | 10357 | bantu | $item_row['title'] = (isset($row['forum_name']) && $row['forum_name'] !== '') ? $row['forum_name'] . ' ' . $this->separator . ' ' . $item_row['title'] : $item_row['title']; |
| 951 | 10357 | bantu | } |
| 952 | 10405 | bantu | |
| 953 | 10405 | bantu | function get_item() |
| 954 | 10405 | bantu | {
|
| 955 | 10405 | bantu | return ($row = parent::get_item()) ? array_merge($this->forum_data, $row) : $row; |
| 956 | 10405 | bantu | } |
| 957 | 10357 | bantu | } |
| 958 | 10357 | bantu | |
| 959 | 10357 | bantu | /**
|
| 960 | 10357 | bantu | * Topic feed for a specific topic |
| 961 | 10357 | bantu | * |
| 962 | 10357 | bantu | * This will give you the last {$this->num_items} posts made within this topic.
|
| 963 | 10357 | bantu | * |
| 964 | 10357 | bantu | * @package phpBB3 |
| 965 | 10357 | bantu | */ |
| 966 | 10357 | bantu | class phpbb_feed_topic extends phpbb_feed_post_base |
| 967 | 10357 | bantu | {
|
| 968 | 10357 | bantu | var $topic_id = 0; |
| 969 | 10357 | bantu | var $forum_id = 0; |
| 970 | 10357 | bantu | var $topic_data = array(); |
| 971 | 10357 | bantu | |
| 972 | 10357 | bantu | function phpbb_feed_topic($topic_id) |
| 973 | 10357 | bantu | {
|
| 974 | 10357 | bantu | parent::phpbb_feed_base();
|
| 975 | 10357 | bantu | |
| 976 | 10357 | bantu | $this->topic_id = (int) $topic_id; |
| 977 | 10357 | bantu | } |
| 978 | 10357 | bantu | |
| 979 | 10357 | bantu | function open() |
| 980 | 10357 | bantu | {
|
| 981 | 10357 | bantu | global $auth, $db, $user; |
| 982 | 10357 | bantu | |
| 983 | 10357 | bantu | $sql = 'SELECT f.forum_options, f.forum_password, t.topic_id, t.forum_id, t.topic_approved, t.topic_title, t.topic_time, t.topic_views, t.topic_replies, t.topic_type |
| 984 | 10357 | bantu | FROM ' . TOPICS_TABLE . ' t |
| 985 | 10357 | bantu | LEFT JOIN ' . FORUMS_TABLE . ' f |
| 986 | 10357 | bantu | ON (f.forum_id = t.forum_id) |
| 987 | 10357 | bantu | WHERE t.topic_id = ' . $this->topic_id; |
| 988 | 10357 | bantu | $result = $db->sql_query($sql); |
| 989 | 10357 | bantu | $this->topic_data = $db->sql_fetchrow($result); |
| 990 | 10357 | bantu | $db->sql_freeresult($result); |
| 991 | 10357 | bantu | |
| 992 | 10357 | bantu | if (empty($this->topic_data)) |
| 993 | 10357 | bantu | {
|
| 994 | 10357 | bantu | trigger_error('NO_TOPIC'); |
| 995 | 9575 | acydburn | } |
| 996 | 10357 | bantu | |
| 997 | 10357 | bantu | if ($this->topic_data['topic_type'] == POST_GLOBAL) |
| 998 | 9575 | acydburn | {
|
| 999 | 10357 | bantu | // We need to find at least one postable forum where feeds are enabled,
|
| 1000 | 10357 | bantu | // that the user can read and maybe also has approve permissions.
|
| 1001 | 10357 | bantu | $in_fid_ary = $this->get_readable_forums(); |
| 1002 | 10357 | bantu | |
| 1003 | 10357 | bantu | if (empty($in_fid_ary)) |
| 1004 | 9575 | acydburn | {
|
| 1005 | 10357 | bantu | // User cannot read any forums
|
| 1006 | 10357 | bantu | trigger_error('SORRY_AUTH_READ'); |
| 1007 | 9575 | acydburn | } |
| 1008 | 9575 | acydburn | |
| 1009 | 10357 | bantu | if (!$this->topic_data['topic_approved']) |
| 1010 | 10357 | bantu | {
|
| 1011 | 10357 | bantu | // Also require m_approve
|
| 1012 | 10592 | git-gate | $in_fid_ary = array_intersect($in_fid_ary, $this->get_moderator_approve_forums()); |
| 1013 | 9575 | acydburn | |
| 1014 | 10357 | bantu | if (empty($in_fid_ary)) |
| 1015 | 10357 | bantu | {
|
| 1016 | 10357 | bantu | trigger_error('SORRY_AUTH_READ'); |
| 1017 | 10357 | bantu | } |
| 1018 | 10357 | bantu | } |
| 1019 | 9575 | acydburn | |
| 1020 | 10357 | bantu | // Diff excluded forums
|
| 1021 | 10357 | bantu | $in_fid_ary = array_diff($in_fid_ary, $this->get_excluded_forums()); |
| 1022 | 10357 | bantu | |
| 1023 | 10357 | bantu | if (empty($in_fid_ary)) |
| 1024 | 9575 | acydburn | {
|
| 1025 | 10357 | bantu | trigger_error('SORRY_AUTH_READ'); |
| 1026 | 9575 | acydburn | } |
| 1027 | 9575 | acydburn | |
| 1028 | 10357 | bantu | // Also exclude passworded forums
|
| 1029 | 10357 | bantu | $in_fid_ary = array_diff($in_fid_ary, $this->get_passworded_forums()); |
| 1030 | 9575 | acydburn | |
| 1031 | 10357 | bantu | if (empty($in_fid_ary)) |
| 1032 | 9575 | acydburn | {
|
| 1033 | 10357 | bantu | trigger_error('SORRY_AUTH_READ'); |
| 1034 | 9575 | acydburn | } |
| 1035 | 10357 | bantu | |
| 1036 | 10398 | bantu | $sql = 'SELECT forum_id, left_id |
| 1037 | 10357 | bantu | FROM ' . FORUMS_TABLE . ' |
| 1038 | 10357 | bantu | WHERE forum_type = ' . FORUM_POST . ' |
| 1039 | 10357 | bantu | AND ' . $db->sql_in_set('forum_id', $in_fid_ary) . ' |
| 1040 | 10357 | bantu | ORDER BY left_id ASC';
|
| 1041 | 10357 | bantu | $result = $db->sql_query_limit($sql, 1); |
| 1042 | 10357 | bantu | $this->forum_data = $db->sql_fetchrow($result); |
| 1043 | 9575 | acydburn | $db->sql_freeresult($result); |
| 1044 | 10357 | bantu | |
| 1045 | 10357 | bantu | if (empty($this->forum_data)) |
| 1046 | 10357 | bantu | {
|
| 1047 | 10357 | bantu | // No forum found.
|
| 1048 | 10357 | bantu | trigger_error('SORRY_AUTH_READ'); |
| 1049 | 10357 | bantu | } |
| 1050 | 10357 | bantu | |
| 1051 | 10357 | bantu | unset($in_fid_ary); |
| 1052 | 9575 | acydburn | } |
| 1053 | 10357 | bantu | else
|
| 1054 | 9575 | acydburn | {
|
| 1055 | 10357 | bantu | $this->forum_id = (int) $this->topic_data['forum_id']; |
| 1056 | 10357 | bantu | |
| 1057 | 10357 | bantu | // Make sure topic is either approved or user authed
|
| 1058 | 10357 | bantu | if (!$this->topic_data['topic_approved'] && !$auth->acl_get('m_approve', $this->forum_id)) |
| 1059 | 9575 | acydburn | {
|
| 1060 | 10357 | bantu | trigger_error('SORRY_AUTH_READ'); |
| 1061 | 9575 | acydburn | } |
| 1062 | 9575 | acydburn | |
| 1063 | 10357 | bantu | // Make sure forum is not excluded from feed
|
| 1064 | 10357 | bantu | if (phpbb_optionget(FORUM_OPTION_FEED_EXCLUDE, $this->topic_data['forum_options'])) |
| 1065 | 10357 | bantu | {
|
| 1066 | 10357 | bantu | trigger_error('NO_FEED'); |
| 1067 | 10357 | bantu | } |
| 1068 | 9575 | acydburn | |
| 1069 | 10357 | bantu | // Make sure we can read this forum
|
| 1070 | 10357 | bantu | if (!$auth->acl_get('f_read', $this->forum_id)) |
| 1071 | 9575 | acydburn | {
|
| 1072 | 10357 | bantu | trigger_error('SORRY_AUTH_READ'); |
| 1073 | 9575 | acydburn | } |
| 1074 | 9575 | acydburn | |
| 1075 | 10357 | bantu | // Make sure forum is not passworded or user is authed
|
| 1076 | 10357 | bantu | if ($this->topic_data['forum_password']) |
| 1077 | 10357 | bantu | {
|
| 1078 | 10357 | bantu | $forum_ids_passworded = $this->get_passworded_forums(); |
| 1079 | 10357 | bantu | |
| 1080 | 10357 | bantu | if (isset($forum_ids_passworded[$this->forum_id])) |
| 1081 | 10357 | bantu | {
|
| 1082 | 10357 | bantu | trigger_error('SORRY_AUTH_READ'); |
| 1083 | 10357 | bantu | } |
| 1084 | 10357 | bantu | |
| 1085 | 10357 | bantu | unset($forum_ids_passworded); |
| 1086 | 10357 | bantu | } |
| 1087 | 9575 | acydburn | } |
| 1088 | 10357 | bantu | } |
| 1089 | 9575 | acydburn | |
| 1090 | 10357 | bantu | function get_sql() |
| 1091 | 10357 | bantu | {
|
| 1092 | 10357 | bantu | global $auth, $db; |
| 1093 | 10357 | bantu | |
| 1094 | 9575 | acydburn | $this->sql = array( |
| 1095 | 11003 | git-gate | '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, ' . |
| 1096 | 10304 | bantu | 'u.username, u.user_id',
|
| 1097 | 9575 | acydburn | 'FROM' => array( |
| 1098 | 9575 | acydburn | POSTS_TABLE => 'p', |
| 1099 | 9575 | acydburn | USERS_TABLE => 'u', |
| 1100 | 9575 | acydburn | ), |
| 1101 | 10357 | bantu | 'WHERE' => 'p.topic_id = ' . $this->topic_id . ' |
| 1102 | 10357 | bantu | ' . ($this->forum_id && !$auth->acl_get('m_approve', $this->forum_id) ? 'AND p.post_approved = 1' : '') . ' |
| 1103 | 10357 | bantu | AND p.poster_id = u.user_id',
|
| 1104 | 9575 | acydburn | 'ORDER_BY' => 'p.post_time DESC', |
| 1105 | 9575 | acydburn | ); |
| 1106 | 9575 | acydburn | |
| 1107 | 9575 | acydburn | return true; |
| 1108 | 9575 | acydburn | } |
| 1109 | 9575 | acydburn | |
| 1110 | 10357 | bantu | function get_item() |
| 1111 | 9575 | acydburn | {
|
| 1112 | 10357 | bantu | return ($row = parent::get_item()) ? array_merge($this->topic_data, $row) : $row; |
| 1113 | 9575 | acydburn | } |
| 1114 | 9575 | acydburn | } |
| 1115 | 9575 | acydburn | |
| 1116 | 10344 | bantu | /**
|
| 1117 | 10344 | bantu | * 'All Forums' feed |
| 1118 | 10344 | bantu | * |
| 1119 | 10344 | bantu | * This will give you a list of all postable forums where feeds are enabled |
| 1120 | 10344 | bantu | * including forum description, topic stats and post stats |
| 1121 | 10344 | bantu | * |
| 1122 | 10344 | bantu | * @package phpBB3 |
| 1123 | 10344 | bantu | */ |
| 1124 | 10315 | bantu | class phpbb_feed_forums extends phpbb_feed_base |
| 1125 | 9575 | acydburn | {
|
| 1126 | 10344 | bantu | var $num_items = 0; |
| 1127 | 10344 | bantu | |
| 1128 | 9575 | acydburn | function set_keys() |
| 1129 | 9575 | acydburn | {
|
| 1130 | 9575 | acydburn | $this->set('title', 'forum_name'); |
| 1131 | 9575 | acydburn | $this->set('text', 'forum_desc'); |
| 1132 | 9575 | acydburn | $this->set('bitfield', 'forum_desc_bitfield'); |
| 1133 | 9575 | acydburn | $this->set('bbcode_uid','forum_desc_uid'); |
| 1134 | 11003 | git-gate | $this->set('updated', 'forum_last_post_time'); |
| 1135 | 9575 | acydburn | $this->set('options', 'forum_desc_options'); |
| 1136 | 9575 | acydburn | } |
| 1137 | 9575 | acydburn | |
| 1138 | 9575 | acydburn | function get_sql() |
| 1139 | 9575 | acydburn | {
|
| 1140 | 10344 | bantu | global $auth, $db; |
| 1141 | 9575 | acydburn | |
| 1142 | 10356 | bantu | $in_fid_ary = array_diff($this->get_readable_forums(), $this->get_excluded_forums()); |
| 1143 | 10356 | bantu | if (empty($in_fid_ary)) |
| 1144 | 10344 | bantu | {
|
| 1145 | 10344 | bantu | return false; |
| 1146 | 10344 | bantu | } |
| 1147 | 9575 | acydburn | |
| 1148 | 9575 | acydburn | // Build SQL Query
|
| 1149 | 9575 | acydburn | $this->sql = array( |
| 1150 | 10344 | bantu | 'SELECT' => 'f.forum_id, f.left_id, f.forum_name, f.forum_last_post_time, |
| 1151 | 10344 | bantu | f.forum_desc, f.forum_desc_bitfield, f.forum_desc_uid, f.forum_desc_options, |
| 1152 | 10344 | bantu | f.forum_topics, f.forum_posts',
|
| 1153 | 9575 | acydburn | 'FROM' => array(FORUMS_TABLE => 'f'), |
| 1154 | 9575 | acydburn | 'WHERE' => 'f.forum_type = ' . FORUM_POST . ' |
| 1155 | 10356 | bantu | AND ' . $db->sql_in_set('f.forum_id', $in_fid_ary), |
| 1156 | 10344 | bantu | 'ORDER_BY' => 'f.left_id ASC', |
| 1157 | 9575 | acydburn | ); |
| 1158 | 9575 | acydburn | |
| 1159 | 9575 | acydburn | return true; |
| 1160 | 9575 | acydburn | } |
| 1161 | 9575 | acydburn | |
| 1162 | 9575 | acydburn | function adjust_item(&$item_row, &$row) |
| 1163 | 9575 | acydburn | {
|
| 1164 | 9575 | acydburn | global $phpEx, $config; |
| 1165 | 9575 | acydburn | |
| 1166 | 9575 | acydburn | $item_row['link'] = feed_append_sid('/viewforum.' . $phpEx, 'f=' . $row['forum_id']); |
| 1167 | 9575 | acydburn | |
| 1168 | 9575 | acydburn | if ($config['feed_item_statistics']) |
| 1169 | 9575 | acydburn | {
|
| 1170 | 9575 | acydburn | global $user; |
| 1171 | 9575 | acydburn | |
| 1172 | 10285 | bantu | $item_row['statistics'] = sprintf($user->lang['TOTAL_TOPICS_OTHER'], $row['forum_topics']) |
| 1173 | 10285 | bantu | . ' ' . $this->separator_stats . ' ' . sprintf($user->lang['TOTAL_POSTS_OTHER'], $row['forum_posts']); |
| 1174 | 9575 | acydburn | } |
| 1175 | 9575 | acydburn | } |
| 1176 | 9575 | acydburn | } |
| 1177 | 9575 | acydburn | |
| 1178 | 10345 | bantu | /**
|
| 1179 | 10345 | bantu | * News feed |
| 1180 | 10345 | bantu | * |
| 1181 | 10345 | bantu | * This will give you {$this->num_items} first posts
|
| 1182 | 10345 | bantu | * of all topics in the selected news forums. |
| 1183 | 10345 | bantu | * |
| 1184 | 10345 | bantu | * @package phpBB3 |
| 1185 | 10345 | bantu | */ |
| 1186 | 10355 | bantu | class phpbb_feed_news extends phpbb_feed_topic_base |
| 1187 | 9575 | acydburn | {
|
| 1188 | 10352 | bantu | function get_news_forums() |
| 1189 | 10352 | bantu | {
|
| 1190 | 10352 | bantu | global $db, $cache; |
| 1191 | 10352 | bantu | static $forum_ids; |
| 1192 | 10352 | bantu | |
| 1193 | 10354 | bantu | // Matches acp/acp_board.php
|
| 1194 | 10352 | bantu | $cache_name = 'feed_news_forum_ids'; |
| 1195 | 10352 | bantu | |
| 1196 | 10352 | bantu | if (!isset($forum_ids) && ($forum_ids = $cache->get('_' . $cache_name)) === false) |
| 1197 | 10352 | bantu | {
|
| 1198 | 10352 | bantu | $sql = 'SELECT forum_id |
| 1199 | 10352 | bantu | FROM ' . FORUMS_TABLE . ' |
| 1200 | 10352 | bantu | WHERE ' . $db->sql_bit_and('forum_options', FORUM_OPTION_FEED_NEWS, '<> 0'); |
| 1201 | 10352 | bantu | $result = $db->sql_query($sql); |
| 1202 | 10352 | bantu | |
| 1203 | 10352 | bantu | $forum_ids = array(); |
| 1204 | 10352 | bantu | while ($forum_id = (int) $db->sql_fetchfield('forum_id')) |
| 1205 | 10352 | bantu | {
|
| 1206 | 10352 | bantu | $forum_ids[$forum_id] = $forum_id; |
| 1207 | 10352 | bantu | } |
| 1208 | 10352 | bantu | $db->sql_freeresult($result); |
| 1209 | 10352 | bantu | |
| 1210 | 10354 | bantu | $cache->put('_' . $cache_name, $forum_ids); |
| 1211 | 10352 | bantu | } |
| 1212 | 10352 | bantu | |
| 1213 | 10352 | bantu | return $forum_ids; |
| 1214 | 10352 | bantu | } |
| 1215 | 10352 | bantu | |
| 1216 | 9575 | acydburn | function get_sql() |
| 1217 | 9575 | acydburn | {
|
| 1218 | 10317 | bantu | global $auth, $config, $db; |
| 1219 | 9575 | acydburn | |
| 1220 | 10352 | bantu | // Determine forum ids
|
| 1221 | 10358 | bantu | $in_fid_ary = array_intersect($this->get_news_forums(), $this->get_readable_forums()); |
| 1222 | 10358 | bantu | if (empty($in_fid_ary)) |
| 1223 | 10352 | bantu | {
|
| 1224 | 10352 | bantu | return false; |
| 1225 | 10352 | bantu | } |
| 1226 | 10352 | bantu | |
| 1227 | 10358 | bantu | $in_fid_ary = array_diff($in_fid_ary, $this->get_passworded_forums()); |
| 1228 | 10352 | bantu | if (empty($in_fid_ary)) |
| 1229 | 9575 | acydburn | {
|
| 1230 | 9575 | acydburn | return false; |
| 1231 | 9575 | acydburn | } |
| 1232 | 9575 | acydburn | |
| 1233 | 10397 | bantu | // Add global forum
|
| 1234 | 10397 | bantu | $in_fid_ary[] = 0; |
| 1235 | 10397 | bantu | |
| 1236 | 10397 | bantu | // We really have to get the post ids first!
|
| 1237 | 10397 | bantu | $sql = 'SELECT topic_first_post_id, topic_time |
| 1238 | 10397 | bantu | FROM ' . TOPICS_TABLE . ' |
| 1239 | 10397 | bantu | WHERE ' . $db->sql_in_set('forum_id', $in_fid_ary) . ' |
| 1240 | 10397 | bantu | AND topic_moved_id = 0 |
| 1241 | 10397 | bantu | AND topic_approved = 1 |
| 1242 | 10397 | bantu | ORDER BY topic_time DESC';
|
| 1243 | 10397 | bantu | $result = $db->sql_query_limit($sql, $this->num_items); |
| 1244 | 10397 | bantu | |
| 1245 | 10397 | bantu | $post_ids = array(); |
| 1246 | 10397 | bantu | while ($row = $db->sql_fetchrow($result)) |
| 1247 | 10397 | bantu | {
|
| 1248 | 10397 | bantu | $post_ids[] = (int) $row['topic_first_post_id']; |
| 1249 | 10397 | bantu | } |
| 1250 | 10397 | bantu | $db->sql_freeresult($result); |
| 1251 | 10397 | bantu | |
| 1252 | 10397 | bantu | if (empty($post_ids)) |
| 1253 | 10397 | bantu | {
|
| 1254 | 10397 | bantu | return false; |
| 1255 | 10397 | bantu | } |
| 1256 | 10397 | bantu | |
| 1257 | 9575 | acydburn | $this->sql = array( |
| 1258 | 10345 | bantu | 'SELECT' => 'f.forum_id, f.forum_name, |
| 1259 | 11003 | git-gate | 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, |
| 1260 | 11003 | git-gate | 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',
|
| 1261 | 9575 | acydburn | 'FROM' => array( |
| 1262 | 9575 | acydburn | TOPICS_TABLE => 't', |
| 1263 | 9575 | acydburn | POSTS_TABLE => 'p', |
| 1264 | 9575 | acydburn | ), |
| 1265 | 10345 | bantu | 'LEFT_JOIN' => array( |
| 1266 | 10345 | bantu | array(
|
| 1267 | 10345 | bantu | 'FROM' => array(FORUMS_TABLE => 'f'), |
| 1268 | 10397 | bantu | 'ON' => 'p.forum_id = f.forum_id', |
| 1269 | 10345 | bantu | ), |
| 1270 | 10345 | bantu | ), |
| 1271 | 10397 | bantu | 'WHERE' => 'p.topic_id = t.topic_id |
| 1272 | 10397 | bantu | AND ' . $db->sql_in_set('p.post_id', $post_ids), |
| 1273 | 10397 | bantu | 'ORDER_BY' => 'p.post_time DESC', |
| 1274 | 9575 | acydburn | ); |
| 1275 | 9575 | acydburn | |
| 1276 | 9575 | acydburn | return true; |
| 1277 | 9575 | acydburn | } |
| 1278 | 9575 | acydburn | } |
| 1279 | 9575 | acydburn | |
| 1280 | 10350 | bantu | /**
|
| 1281 | 10380 | bantu | * New Topics feed |
| 1282 | 10350 | bantu | * |
| 1283 | 10350 | bantu | * This will give you the last {$this->num_items} created topics
|
| 1284 | 10350 | bantu | * including the first post. |
| 1285 | 10350 | bantu | * |
| 1286 | 10350 | bantu | * @package phpBB3 |
| 1287 | 10350 | bantu | */ |
| 1288 | 10355 | bantu | class phpbb_feed_topics extends phpbb_feed_topic_base |
| 1289 | 9575 | acydburn | {
|
| 1290 | 9575 | acydburn | function get_sql() |
| 1291 | 9575 | acydburn | {
|
| 1292 | 9575 | acydburn | global $db, $config; |
| 1293 | 9575 | acydburn | |
| 1294 | 10353 | bantu | $forum_ids_read = $this->get_readable_forums(); |
| 1295 | 10353 | bantu | if (empty($forum_ids_read)) |
| 1296 | 9575 | acydburn | {
|
| 1297 | 10353 | bantu | return false; |
| 1298 | 9575 | acydburn | } |
| 1299 | 10353 | bantu | |
| 1300 | 10353 | bantu | $in_fid_ary = array_diff($forum_ids_read, $this->get_excluded_forums(), $this->get_passworded_forums()); |
| 1301 | 10353 | bantu | if (empty($in_fid_ary)) |
| 1302 | 9575 | acydburn | {
|
| 1303 | 10353 | bantu | return false; |
| 1304 | 9575 | acydburn | } |
| 1305 | 9575 | acydburn | |
| 1306 | 10397 | bantu | // Add global forum
|
| 1307 | 10397 | bantu | $in_fid_ary[] = 0; |
| 1308 | 10397 | bantu | |
| 1309 | 10397 | bantu | // We really have to get the post ids first!
|
| 1310 | 10397 | bantu | $sql = 'SELECT topic_first_post_id, topic_time |
| 1311 | 10397 | bantu | FROM ' . TOPICS_TABLE . ' |
| 1312 | 10397 | bantu | WHERE ' . $db->sql_in_set('forum_id', $in_fid_ary) . ' |
| 1313 | 10397 | bantu | AND topic_moved_id = 0 |
| 1314 | 10397 | bantu | AND topic_approved = 1 |
| 1315 | 10397 | bantu | ORDER BY topic_time DESC';
|
| 1316 | 10397 | bantu | $result = $db->sql_query_limit($sql, $this->num_items); |
| 1317 | 10397 | bantu | |
| 1318 | 10397 | bantu | $post_ids = array(); |
| 1319 | 10397 | bantu | while ($row = $db->sql_fetchrow($result)) |
| 1320 | 10397 | bantu | {
|
| 1321 | 10397 | bantu | $post_ids[] = (int) $row['topic_first_post_id']; |
| 1322 | 10397 | bantu | } |
| 1323 | 10397 | bantu | $db->sql_freeresult($result); |
| 1324 | 10397 | bantu | |
| 1325 | 10397 | bantu | if (empty($post_ids)) |
| 1326 | 10397 | bantu | {
|
| 1327 | 10397 | bantu | return false; |
| 1328 | 10397 | bantu | } |
| 1329 | 10397 | bantu | |
| 1330 | 9575 | acydburn | $this->sql = array( |
| 1331 | 10350 | bantu | 'SELECT' => 'f.forum_id, f.forum_name, |
| 1332 | 11003 | git-gate | 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, |
| 1333 | 11003 | git-gate | 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',
|
| 1334 | 9575 | acydburn | 'FROM' => array( |
| 1335 | 9575 | acydburn | TOPICS_TABLE => 't', |
| 1336 | 9575 | acydburn | POSTS_TABLE => 'p', |
| 1337 | 9575 | acydburn | ), |
| 1338 | 10350 | bantu | 'LEFT_JOIN' => array( |
| 1339 | 10350 | bantu | array(
|
| 1340 | 10350 | bantu | 'FROM' => array(FORUMS_TABLE => 'f'), |
| 1341 | 10397 | bantu | 'ON' => 'p.forum_id = f.forum_id', |
| 1342 | 10350 | bantu | ), |
| 1343 | 10350 | bantu | ), |
| 1344 | 10397 | bantu | 'WHERE' => 'p.topic_id = t.topic_id |
| 1345 | 10397 | bantu | AND ' . $db->sql_in_set('p.post_id', $post_ids), |
| 1346 | 10397 | bantu | 'ORDER_BY' => 'p.post_time DESC', |
| 1347 | 9575 | acydburn | ); |
| 1348 | 9575 | acydburn | |
| 1349 | 9575 | acydburn | return true; |
| 1350 | 9575 | acydburn | } |
| 1351 | 9575 | acydburn | |
| 1352 | 9575 | acydburn | function adjust_item(&$item_row, &$row) |
| 1353 | 9575 | acydburn | {
|
| 1354 | 10355 | bantu | parent::adjust_item($item_row, $row); |
| 1355 | 9575 | acydburn | |
| 1356 | 10350 | bantu | $item_row['title'] = (isset($row['forum_name']) && $row['forum_name'] !== '') ? $row['forum_name'] . ' ' . $this->separator . ' ' . $item_row['title'] : $item_row['title']; |
| 1357 | 9575 | acydburn | } |
| 1358 | 9575 | acydburn | } |
| 1359 | 9575 | acydburn | |
| 1360 | 10380 | bantu | /**
|
| 1361 | 10380 | bantu | * Active Topics feed |
| 1362 | 10380 | bantu | * |
| 1363 | 10380 | bantu | * This will give you the last {$this->num_items} topics
|
| 1364 | 10380 | bantu | * with replies made withing the last {$this->sort_days} days
|
| 1365 | 10380 | bantu | * including the last post. |
| 1366 | 10380 | bantu | * |
| 1367 | 10380 | bantu | * @package phpBB3 |
| 1368 | 10380 | bantu | */ |
| 1369 | 10380 | bantu | class phpbb_feed_topics_active extends phpbb_feed_topic_base |
| 1370 | 10380 | bantu | {
|
| 1371 | 10380 | bantu | var $sort_days = 7; |
| 1372 | 9575 | acydburn | |
| 1373 | 10380 | bantu | function set_keys() |
| 1374 | 10380 | bantu | {
|
| 1375 | 10380 | bantu | parent::set_keys();
|
| 1376 | 10380 | bantu | |
| 1377 | 10380 | bantu | $this->set('author_id', 'topic_last_poster_id'); |
| 1378 | 10380 | bantu | $this->set('creator', 'topic_last_poster_name'); |
| 1379 | 10380 | bantu | } |
| 1380 | 10380 | bantu | |
| 1381 | 10380 | bantu | function get_sql() |
| 1382 | 10380 | bantu | {
|
| 1383 | 10380 | bantu | global $db, $config; |
| 1384 | 10380 | bantu | |
| 1385 | 10380 | bantu | $forum_ids_read = $this->get_readable_forums(); |
| 1386 | 10380 | bantu | if (empty($forum_ids_read)) |
| 1387 | 10380 | bantu | {
|
| 1388 | 10380 | bantu | return false; |
| 1389 | 10380 | bantu | } |
| 1390 | 10380 | bantu | |
| 1391 | 10380 | bantu | $in_fid_ary = array_intersect($forum_ids_read, $this->get_forum_ids()); |
| 1392 | 10380 | bantu | $in_fid_ary = array_diff($in_fid_ary, $this->get_passworded_forums()); |
| 1393 | 10380 | bantu | if (empty($in_fid_ary)) |
| 1394 | 10380 | bantu | {
|
| 1395 | 10380 | bantu | return false; |
| 1396 | 10380 | bantu | } |
| 1397 | 10380 | bantu | |
| 1398 | 10397 | bantu | // Add global forum
|
| 1399 | 10397 | bantu | $in_fid_ary[] = 0; |
| 1400 | 10397 | bantu | |
| 1401 | 10380 | bantu | // Search for topics in last X days
|
| 1402 | 10397 | bantu | $last_post_time_sql = ($this->sort_days) ? ' AND topic_last_post_time > ' . (time() - ($this->sort_days * 24 * 3600)) : ''; |
| 1403 | 10380 | bantu | |
| 1404 | 10397 | bantu | // We really have to get the post ids first!
|
| 1405 | 10397 | bantu | $sql = 'SELECT topic_last_post_id, topic_last_post_time |
| 1406 | 10397 | bantu | FROM ' . TOPICS_TABLE . ' |
| 1407 | 10397 | bantu | WHERE ' . $db->sql_in_set('forum_id', $in_fid_ary) . ' |
| 1408 | 10397 | bantu | AND topic_moved_id = 0 |
| 1409 | 10397 | bantu | AND topic_approved = 1 |
| 1410 | 10397 | bantu | ' . $last_post_time_sql . ' |
| 1411 | 10397 | bantu | ORDER BY topic_last_post_time DESC';
|
| 1412 | 10397 | bantu | $result = $db->sql_query_limit($sql, $this->num_items); |
| 1413 | 10397 | bantu | |
| 1414 | 10397 | bantu | $post_ids = array(); |
| 1415 | 10397 | bantu | while ($row = $db->sql_fetchrow($result)) |
| 1416 | 10397 | bantu | {
|
| 1417 | 10397 | bantu | $post_ids[] = (int) $row['topic_last_post_id']; |
| 1418 | 10397 | bantu | } |
| 1419 | 10397 | bantu | $db->sql_freeresult($result); |
| 1420 | 10397 | bantu | |
| 1421 | 10397 | bantu | if (empty($post_ids)) |
| 1422 | 10397 | bantu | {
|
| 1423 | 10397 | bantu | return false; |
| 1424 | 10397 | bantu | } |
| 1425 | 10397 | bantu | |
| 1426 | 10380 | bantu | $this->sql = array( |
| 1427 | 10380 | bantu | 'SELECT' => 'f.forum_id, f.forum_name, |
| 1428 | 10595 | git-gate | t.topic_id, t.topic_title, t.topic_replies, t.topic_replies_real, t.topic_views, |
| 1429 | 10380 | bantu | t.topic_last_poster_id, t.topic_last_poster_name, t.topic_last_post_time, |
| 1430 | 11003 | git-gate | 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',
|
| 1431 | 10380 | bantu | 'FROM' => array( |
| 1432 | 10380 | bantu | TOPICS_TABLE => 't', |
| 1433 | 10380 | bantu | POSTS_TABLE => 'p', |
| 1434 | 10380 | bantu | ), |
| 1435 | 10380 | bantu | 'LEFT_JOIN' => array( |
| 1436 | 10380 | bantu | array(
|
| 1437 | 10380 | bantu | 'FROM' => array(FORUMS_TABLE => 'f'), |
| 1438 | 10397 | bantu | 'ON' => 'p.forum_id = f.forum_id', |
| 1439 | 10380 | bantu | ), |
| 1440 | 10380 | bantu | ), |
| 1441 | 10397 | bantu | 'WHERE' => 'p.topic_id = t.topic_id |
| 1442 | 10397 | bantu | AND ' . $db->sql_in_set('p.post_id', $post_ids), |
| 1443 | 10397 | bantu | 'ORDER_BY' => 'p.post_time DESC', |
| 1444 | 10380 | bantu | ); |
| 1445 | 10380 | bantu | |
| 1446 | 10380 | bantu | return true; |
| 1447 | 10380 | bantu | } |
| 1448 | 10380 | bantu | |
| 1449 | 10380 | bantu | function get_forum_ids() |
| 1450 | 10380 | bantu | {
|
| 1451 | 10380 | bantu | global $db, $cache; |
| 1452 | 10380 | bantu | static $forum_ids; |
| 1453 | 10380 | bantu | |
| 1454 | 10380 | bantu | $cache_name = 'feed_topic_active_forum_ids'; |
| 1455 | 10380 | bantu | |
| 1456 | 10380 | bantu | if (!isset($forum_ids) && ($forum_ids = $cache->get('_' . $cache_name)) === false) |
| 1457 | 10380 | bantu | {
|
| 1458 | 10380 | bantu | $sql = 'SELECT forum_id |
| 1459 | 10380 | bantu | FROM ' . FORUMS_TABLE . ' |
| 1460 | 10381 | bantu | WHERE forum_type = ' . FORUM_POST . ' |
| 1461 | 10381 | bantu | AND ' . $db->sql_bit_and('forum_options', FORUM_OPTION_FEED_EXCLUDE, '= 0') . ' |
| 1462 | 10380 | bantu | AND ' . $db->sql_bit_and('forum_flags', log(FORUM_FLAG_ACTIVE_TOPICS, 2), '<> 0'); |
| 1463 | 10380 | bantu | $result = $db->sql_query($sql); |
| 1464 | 10380 | bantu | |
| 1465 | 10380 | bantu | $forum_ids = array(); |
| 1466 | 10380 | bantu | while ($forum_id = (int) $db->sql_fetchfield('forum_id')) |
| 1467 | 10380 | bantu | {
|
| 1468 | 10380 | bantu | $forum_ids[$forum_id] = $forum_id; |
| 1469 | 10380 | bantu | } |
| 1470 | 10380 | bantu | $db->sql_freeresult($result); |
| 1471 | 10380 | bantu | |
| 1472 | 10380 | bantu | $cache->put('_' . $cache_name, $forum_ids, 180); |
| 1473 | 10380 | bantu | } |
| 1474 | 10380 | bantu | |
| 1475 | 10380 | bantu | return $forum_ids; |
| 1476 | 10380 | bantu | } |
| 1477 | 10380 | bantu | |
| 1478 | 10380 | bantu | function adjust_item(&$item_row, &$row) |
| 1479 | 10380 | bantu | {
|
| 1480 | 10380 | bantu | parent::adjust_item($item_row, $row); |
| 1481 | 10380 | bantu | |
| 1482 | 10380 | bantu | $item_row['title'] = (isset($row['forum_name']) && $row['forum_name'] !== '') ? $row['forum_name'] . ' ' . $this->separator . ' ' . $item_row['title'] : $item_row['title']; |
| 1483 | 10380 | bantu | } |
| 1484 | 10380 | bantu | } |
| 1485 | 10380 | bantu | |
| 1486 | 10380 | bantu | |
| 1487 | 9575 | acydburn | ?> |

