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