Skip to content
Newer
Older
100644 593 lines (456 sloc) 20.3 KB
9d65336 Initial import based on revision 1613 of PunBB.
Connor Dunn authored Apr 27, 2008
1 <?php
56ab252 Updated copyright texts.
Frank Smit authored Oct 17, 2009
2
e5f7b2a @reines Updating copyright notices in all files
reines authored Feb 20, 2010
3 /**
7c5edc2 @reines Updating copyright notices for 2012
reines authored Jan 4, 2012
4 * Copyright (C) 2008-2012 FluxBB
e5f7b2a @reines Updating copyright notices in all files
reines authored Feb 20, 2010
5 * based on code by Rickard Andersson copyright (C) 2002-2008 PunBB
6 * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher
7 */
56ab252 Updated copyright texts.
Frank Smit authored Oct 17, 2009
8
9 /*-----------------------------------------------------------------------------
9d65336 Initial import based on revision 1613 of PunBB.
Connor Dunn authored Apr 27, 2008
10
5737059 @reines Converting the queries in extern.php
reines authored Apr 7, 2011
11 INSTRUCTIONS
12
13 This script is used to include information about your board from
14 pages outside the forums and to syndicate news about recent
15 discussions via RSS/Atom/XML. The script can display a list of
16 recent discussions, a list of active users or a collection of
17 general board statistics. The script can be called directly via
18 an URL, from a PHP include command or through the use of Server
19 Side Includes (SSI).
20
21 The scripts behaviour is controlled via variables supplied in the
22 URL to the script. The different variables are: action (what to
23 do), show (how many items to display), fid (the ID or IDs of
24 the forum(s) to poll for topics), nfid (the ID or IDs of forums
25 that should be excluded), tid (the ID of the topic from which to
26 display posts) and type (output as HTML or RSS). The only
27 mandatory variable is action. Possible/default values are:
9d65336 Initial import based on revision 1613 of PunBB.
Connor Dunn authored Apr 27, 2008
28
7118aa5 @sprt Automatically right trimmed lines and converted sequences of 4 spaces…
sprt authored Jan 4, 2011
29 action: feed - show most recent topics/posts (HTML or RSS)
30 online - show users online (HTML)
31 online_full - as above, but includes a full list (HTML)
32 stats - show board statistics (HTML)
9d65336 Initial import based on revision 1613 of PunBB.
Connor Dunn authored Apr 27, 2008
33
7118aa5 @sprt Automatically right trimmed lines and converted sequences of 4 spaces…
sprt authored Jan 3, 2011
34 type: rss - output as RSS 2.0
35 atom - output as Atom 1.0
36 xml - output as XML
37 html - output as HTML (<li>'s)
9d65336 Initial import based on revision 1613 of PunBB.
Connor Dunn authored Apr 27, 2008
38
7118aa5 @sprt Automatically right trimmed lines and converted sequences of 4 spaces…
sprt authored Jan 3, 2011
39 fid: One or more forum IDs (comma-separated). If ignored,
40 topics from all readable forums will be pulled.
9d65336 Initial import based on revision 1613 of PunBB.
Connor Dunn authored Apr 27, 2008
41
7118aa5 @sprt Automatically right trimmed lines and converted sequences of 4 spaces…
sprt authored Jan 3, 2011
42 nfid: One or more forum IDs (comma-separated) that are to be
43 excluded. E.g. the ID of a a test forum.
9d65336 Initial import based on revision 1613 of PunBB.
Connor Dunn authored Apr 27, 2008
44
7118aa5 @sprt Automatically right trimmed lines and converted sequences of 4 spaces…
sprt authored Jan 3, 2011
45 tid: A topic ID from which to show posts. If a tid is supplied,
46 fid and nfid are ignored.
9d65336 Initial import based on revision 1613 of PunBB.
Connor Dunn authored Apr 27, 2008
47
7118aa5 @sprt Automatically right trimmed lines and converted sequences of 4 spaces…
sprt authored Jan 3, 2011
48 show: Any integer value between 1 and 50. The default is 15.
9d65336 Initial import based on revision 1613 of PunBB.
Connor Dunn authored Apr 27, 2008
49
7118aa5 @sprt Automatically right trimmed lines and converted sequences of 4 spaces…
sprt authored Jan 3, 2011
50 order: last_post - show topics ordered by when they were last
51 posted in, giving information about the reply.
52 posted - show topics ordered by when they were first
5737059 @reines Converting the queries in extern.php
reines authored Apr 7, 2011
53 posted, giving information about the original post.
9d65336 Initial import based on revision 1613 of PunBB.
Connor Dunn authored Apr 27, 2008
54
56ab252 Updated copyright texts.
Frank Smit authored Oct 17, 2009
55 -----------------------------------------------------------------------------*/
9d65336 Initial import based on revision 1613 of PunBB.
Connor Dunn authored Apr 27, 2008
56
03b76fe @Quy Ported extern.php from 1.3 to 1.4.
Quy authored Jul 8, 2009
57 define('PUN_QUIET_VISIT', 1);
9d65336 Initial import based on revision 1613 of PunBB.
Connor Dunn authored Apr 27, 2008
58
03b76fe @Quy Ported extern.php from 1.3 to 1.4.
Quy authored Jul 8, 2009
59 if (!defined('PUN_ROOT'))
f5ee836 @reines Changing PUN_ROOT to use absolute paths, this solves some issues with…
reines authored Dec 7, 2010
60 define('PUN_ROOT', dirname(__FILE__).'/');
03b76fe @Quy Ported extern.php from 1.3 to 1.4.
Quy authored Jul 8, 2009
61 require PUN_ROOT.'include/common.php';
9d65336 Initial import based on revision 1613 of PunBB.
Connor Dunn authored Apr 27, 2008
62
03b76fe @Quy Ported extern.php from 1.3 to 1.4.
Quy authored Jul 8, 2009
63 // The length at which topic subjects will be truncated (for HTML output)
64 if (!defined('FORUM_EXTERN_MAX_SUBJECT_LENGTH'))
9f33616 @reines Converted a bunch of spaces into tabs to tidy up. Patch kindly submit…
reines authored Oct 20, 2009
65 define('FORUM_EXTERN_MAX_SUBJECT_LENGTH', 30);
9d65336 Initial import based on revision 1613 of PunBB.
Connor Dunn authored Apr 27, 2008
66
03b76fe @Quy Ported extern.php from 1.3 to 1.4.
Quy authored Jul 8, 2009
67 // If we're a guest and we've sent a username/pass, we can try to authenticate using those details
68 if ($pun_user['is_guest'] && isset($_SERVER['PHP_AUTH_USER']))
69 authenticate_user($_SERVER['PHP_AUTH_USER'], $_SERVER['PHP_AUTH_PW']);
9d65336 Initial import based on revision 1613 of PunBB.
Connor Dunn authored Apr 27, 2008
70
03b76fe @Quy Ported extern.php from 1.3 to 1.4.
Quy authored Jul 8, 2009
71 if ($pun_user['g_read_board'] == '0')
72 {
73 http_authenticate_user();
664cb8b @franzliedke #367: Add Gettext file common.po (and .mo, too) and use that in all t…
franzliedke authored Sep 19, 2011
74 exit($lang->t('No view'));
03b76fe @Quy Ported extern.php from 1.3 to 1.4.
Quy authored Jul 8, 2009
75 }
9d65336 Initial import based on revision 1613 of PunBB.
Connor Dunn authored Apr 27, 2008
76
b9774ac @reines Updating extern.php to not be case-sensitive
reines authored Jul 31, 2010
77 $action = isset($_GET['action']) ? strtolower($_GET['action']) : 'feed';
9d65336 Initial import based on revision 1613 of PunBB.
Connor Dunn authored Apr 27, 2008
78
07f8021 @reines Adding redirects for old 1.2 style syndication links. #84
reines authored Jul 31, 2010
79 // Handle a couple old formats, from FluxBB 1.2
80 switch ($action)
81 {
82 case 'active':
83 $action = 'feed';
84 $_GET['order'] = 'last_post';
85 break;
86
87 case 'new':
88 $action = 'feed';
89 $_GET['order'] = 'posted';
90 break;
91 }
9d65336 Initial import based on revision 1613 of PunBB.
Connor Dunn authored Apr 27, 2008
92
03b76fe @Quy Ported extern.php from 1.3 to 1.4.
Quy authored Jul 8, 2009
93 //
94 // Sends the proper headers for Basic HTTP Authentication
95 //
96 function http_authenticate_user()
97 {
98 global $pun_config, $pun_user;
9d65336 Initial import based on revision 1613 of PunBB.
Connor Dunn authored Apr 27, 2008
99
03b76fe @Quy Ported extern.php from 1.3 to 1.4.
Quy authored Jul 8, 2009
100 if (!$pun_user['is_guest'])
101 return;
9d65336 Initial import based on revision 1613 of PunBB.
Connor Dunn authored Apr 27, 2008
102
03b76fe @Quy Ported extern.php from 1.3 to 1.4.
Quy authored Jul 8, 2009
103 header('WWW-Authenticate: Basic realm="'.$pun_config['o_board_title'].' External Syndication"');
104 header('HTTP/1.0 401 Unauthorized');
105 }
9d65336 Initial import based on revision 1613 of PunBB.
Connor Dunn authored Apr 27, 2008
106
107
03b76fe @Quy Ported extern.php from 1.3 to 1.4.
Quy authored Jul 8, 2009
108 //
109 // Output $feed as RSS 2.0
110 //
111 function output_rss($feed)
112 {
664cb8b @franzliedke #367: Add Gettext file common.po (and .mo, too) and use that in all t…
franzliedke authored Sep 19, 2011
113 global $lang, $pun_config;
03b76fe @Quy Ported extern.php from 1.3 to 1.4.
Quy authored Jul 8, 2009
114
115 // Send XML/no cache headers
1d3d762 @FSX RSS/XML content-type headers are correct now.
FSX authored May 11, 2010
116 header('Content-Type: application/xml; charset=utf-8');
03b76fe @Quy Ported extern.php from 1.3 to 1.4.
Quy authored Jul 8, 2009
117 header('Expires: '.gmdate('D, d M Y H:i:s').' GMT');
118 header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
119 header('Pragma: public');
120
121 echo '<?xml version="1.0" encoding="utf-8"?>'."\n";
d9824a9 @franzliedke #330: Fix my feed fix. XML-namespace-related.
franzliedke authored Mar 9, 2011
122 echo '<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">'."\n";
03b76fe @Quy Ported extern.php from 1.3 to 1.4.
Quy authored Jul 8, 2009
123 echo "\t".'<channel>'."\n";
e0fa124 @franzliedke Enhance RSS feeds by adding atom:link with rel="self".
franzliedke authored Mar 9, 2011
124 echo "\t\t".'<atom:link href="'.pun_htmlspecialchars(get_current_url()).'" rel="self" type="application/rss+xml" />'."\n";
03b76fe @Quy Ported extern.php from 1.3 to 1.4.
Quy authored Jul 8, 2009
125 echo "\t\t".'<title><![CDATA['.escape_cdata($feed['title']).']]></title>'."\n";
69c74f9 @reines Escaping the URL output in extern.php. This isnt critical as the base…
reines authored Oct 23, 2010
126 echo "\t\t".'<link>'.pun_htmlspecialchars($feed['link']).'</link>'."\n";
1bc3b18 @reines Changing extern descriptions to use CDATA rather than html encoding
reines authored Oct 12, 2009
127 echo "\t\t".'<description><![CDATA['.escape_cdata($feed['description']).']]></description>'."\n";
03b76fe @Quy Ported extern.php from 1.3 to 1.4.
Quy authored Jul 8, 2009
128 echo "\t\t".'<lastBuildDate>'.gmdate('r', count($feed['items']) ? $feed['items'][0]['pubdate'] : time()).'</lastBuildDate>'."\n";
129
130 if ($pun_config['o_show_version'] == '1')
131 echo "\t\t".'<generator>FluxBB '.$pun_config['o_cur_version'].'</generator>'."\n";
132 else
133 echo "\t\t".'<generator>FluxBB</generator>'."\n";
9d65336 Initial import based on revision 1613 of PunBB.
Connor Dunn authored Apr 27, 2008
134
03b76fe @Quy Ported extern.php from 1.3 to 1.4.
Quy authored Jul 8, 2009
135 foreach ($feed['items'] as $item)
136 {
137 echo "\t\t".'<item>'."\n";
138 echo "\t\t\t".'<title><![CDATA['.escape_cdata($item['title']).']]></title>'."\n";
69c74f9 @reines Escaping the URL output in extern.php. This isnt critical as the base…
reines authored Oct 23, 2010
139 echo "\t\t\t".'<link>'.pun_htmlspecialchars($item['link']).'</link>'."\n";
1bc3b18 @reines Changing extern descriptions to use CDATA rather than html encoding
reines authored Oct 12, 2009
140 echo "\t\t\t".'<description><![CDATA['.escape_cdata($item['description']).']]></description>'."\n";
03b76fe @Quy Ported extern.php from 1.3 to 1.4.
Quy authored Jul 8, 2009
141 echo "\t\t\t".'<author><![CDATA['.(isset($item['author']['email']) ? escape_cdata($item['author']['email']) : 'dummy@example.com').' ('.escape_cdata($item['author']['name']).')]]></author>'."\n";
142 echo "\t\t\t".'<pubDate>'.gmdate('r', $item['pubdate']).'</pubDate>'."\n";
59af677 @reines Properly escaping the GUID in RSS feeds. Spotted by Kurkov.ORG. #265
reines authored Jan 30, 2011
143 echo "\t\t\t".'<guid>'.pun_htmlspecialchars($item['link']).'</guid>'."\n";
03b76fe @Quy Ported extern.php from 1.3 to 1.4.
Quy authored Jul 8, 2009
144
145 echo "\t\t".'</item>'."\n";
146 }
147
148 echo "\t".'</channel>'."\n";
149 echo '</rss>'."\n";
150 }
9d65336 Initial import based on revision 1613 of PunBB.
Connor Dunn authored Apr 27, 2008
151
152
03b76fe @Quy Ported extern.php from 1.3 to 1.4.
Quy authored Jul 8, 2009
153 //
154 // Output $feed as Atom 1.0
155 //
156 function output_atom($feed)
157 {
664cb8b @franzliedke #367: Add Gettext file common.po (and .mo, too) and use that in all t…
franzliedke authored Sep 19, 2011
158 global $lang, $pun_config;
9d65336 Initial import based on revision 1613 of PunBB.
Connor Dunn authored Apr 27, 2008
159
03b76fe @Quy Ported extern.php from 1.3 to 1.4.
Quy authored Jul 8, 2009
160 // Send XML/no cache headers
4b97c3f @FSX Atom/RSS/XML feeds are now served with the right content-type header.…
FSX authored May 11, 2010
161 header('Content-Type: application/atom+xml; charset=utf-8');
03b76fe @Quy Ported extern.php from 1.3 to 1.4.
Quy authored Jul 8, 2009
162 header('Expires: '.gmdate('D, d M Y H:i:s').' GMT');
163 header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
164 header('Pragma: public');
9d65336 Initial import based on revision 1613 of PunBB.
Connor Dunn authored Apr 27, 2008
165
03b76fe @Quy Ported extern.php from 1.3 to 1.4.
Quy authored Jul 8, 2009
166 echo '<?xml version="1.0" encoding="utf-8"?>'."\n";
167 echo '<feed xmlns="http://www.w3.org/2005/Atom">'."\n";
9d65336 Initial import based on revision 1613 of PunBB.
Connor Dunn authored Apr 27, 2008
168
03b76fe @Quy Ported extern.php from 1.3 to 1.4.
Quy authored Jul 8, 2009
169 echo "\t".'<title type="html"><![CDATA['.escape_cdata($feed['title']).']]></title>'."\n";
170 echo "\t".'<link rel="self" href="'.pun_htmlspecialchars(get_current_url()).'"/>'."\n";
69c74f9 @reines Escaping the URL output in extern.php. This isnt critical as the base…
reines authored Oct 23, 2010
171 echo "\t".'<link href="'.pun_htmlspecialchars($feed['link']).'"/>'."\n";
03b76fe @Quy Ported extern.php from 1.3 to 1.4.
Quy authored Jul 8, 2009
172 echo "\t".'<updated>'.gmdate('Y-m-d\TH:i:s\Z', count($feed['items']) ? $feed['items'][0]['pubdate'] : time()).'</updated>'."\n";
9d65336 Initial import based on revision 1613 of PunBB.
Connor Dunn authored Apr 27, 2008
173
03b76fe @Quy Ported extern.php from 1.3 to 1.4.
Quy authored Jul 8, 2009
174 if ($pun_config['o_show_version'] == '1')
175 echo "\t".'<generator version="'.$pun_config['o_cur_version'].'">FluxBB</generator>'."\n";
176 else
177 echo "\t".'<generator>FluxBB</generator>'."\n";
9d65336 Initial import based on revision 1613 of PunBB.
Connor Dunn authored Apr 27, 2008
178
69c74f9 @reines Escaping the URL output in extern.php. This isnt critical as the base…
reines authored Oct 23, 2010
179 echo "\t".'<id>'.pun_htmlspecialchars($feed['link']).'</id>'."\n";
9d65336 Initial import based on revision 1613 of PunBB.
Connor Dunn authored Apr 27, 2008
180
03b76fe @Quy Ported extern.php from 1.3 to 1.4.
Quy authored Jul 8, 2009
181 $content_tag = ($feed['type'] == 'posts') ? 'content' : 'summary';
9d65336 Initial import based on revision 1613 of PunBB.
Connor Dunn authored Apr 27, 2008
182
03b76fe @Quy Ported extern.php from 1.3 to 1.4.
Quy authored Jul 8, 2009
183 foreach ($feed['items'] as $item)
184 {
3eda01b @reines Updated atom feeds to include feed link as suggested by Meow (http://…
reines authored Jan 16, 2010
185 echo "\t".'<entry>'."\n";
186 echo "\t\t".'<title type="html"><![CDATA['.escape_cdata($item['title']).']]></title>'."\n";
69c74f9 @reines Escaping the URL output in extern.php. This isnt critical as the base…
reines authored Oct 23, 2010
187 echo "\t\t".'<link rel="alternate" href="'.pun_htmlspecialchars($item['link']).'"/>'."\n";
3eda01b @reines Updated atom feeds to include feed link as suggested by Meow (http://…
reines authored Jan 16, 2010
188 echo "\t\t".'<'.$content_tag.' type="html"><![CDATA['.escape_cdata($item['description']).']]></'.$content_tag.'>'."\n";
189 echo "\t\t".'<author>'."\n";
190 echo "\t\t\t".'<name><![CDATA['.escape_cdata($item['author']['name']).']]></name>'."\n";
9d65336 Initial import based on revision 1613 of PunBB.
Connor Dunn authored Apr 27, 2008
191
03b76fe @Quy Ported extern.php from 1.3 to 1.4.
Quy authored Jul 8, 2009
192 if (isset($item['author']['email']))
3eda01b @reines Updated atom feeds to include feed link as suggested by Meow (http://…
reines authored Jan 16, 2010
193 echo "\t\t\t".'<email><![CDATA['.escape_cdata($item['author']['email']).']]></email>'."\n";
9d65336 Initial import based on revision 1613 of PunBB.
Connor Dunn authored Apr 27, 2008
194
03b76fe @Quy Ported extern.php from 1.3 to 1.4.
Quy authored Jul 8, 2009
195 if (isset($item['author']['uri']))
69c74f9 @reines Escaping the URL output in extern.php. This isnt critical as the base…
reines authored Oct 23, 2010
196 echo "\t\t\t".'<uri>'.pun_htmlspecialchars($item['author']['uri']).'</uri>'."\n";
9d65336 Initial import based on revision 1613 of PunBB.
Connor Dunn authored Apr 27, 2008
197
3eda01b @reines Updated atom feeds to include feed link as suggested by Meow (http://…
reines authored Jan 16, 2010
198 echo "\t\t".'</author>'."\n";
199 echo "\t\t".'<updated>'.gmdate('Y-m-d\TH:i:s\Z', $item['pubdate']).'</updated>'."\n";
5ca8498 @reines Updating trunk to version 1.4. These changes have all kindly been don…
reines authored Jan 30, 2009
200
7f4dbd3 @reines Escaping missed entry for atom feeds in extern.php
reines authored Oct 26, 2010
201 echo "\t\t".'<id>'.pun_htmlspecialchars($item['link']).'</id>'."\n";
3eda01b @reines Updated atom feeds to include feed link as suggested by Meow (http://…
reines authored Jan 16, 2010
202 echo "\t".'</entry>'."\n";
03b76fe @Quy Ported extern.php from 1.3 to 1.4.
Quy authored Jul 8, 2009
203 }
5ca8498 @reines Updating trunk to version 1.4. These changes have all kindly been don…
reines authored Jan 30, 2009
204
03b76fe @Quy Ported extern.php from 1.3 to 1.4.
Quy authored Jul 8, 2009
205 echo '</feed>'."\n";
9d65336 Initial import based on revision 1613 of PunBB.
Connor Dunn authored Apr 27, 2008
206 }
207
208
03b76fe @Quy Ported extern.php from 1.3 to 1.4.
Quy authored Jul 8, 2009
209 //
210 // Output $feed as XML
211 //
212 function output_xml($feed)
213 {
664cb8b @franzliedke #367: Add Gettext file common.po (and .mo, too) and use that in all t…
franzliedke authored Sep 19, 2011
214 global $lang, $pun_config;
9d65336 Initial import based on revision 1613 of PunBB.
Connor Dunn authored Apr 27, 2008
215
03b76fe @Quy Ported extern.php from 1.3 to 1.4.
Quy authored Jul 8, 2009
216 // Send XML/no cache headers
1d3d762 @FSX RSS/XML content-type headers are correct now.
FSX authored May 11, 2010
217 header('Content-Type: application/xml; charset=utf-8');
03b76fe @Quy Ported extern.php from 1.3 to 1.4.
Quy authored Jul 8, 2009
218 header('Expires: '.gmdate('D, d M Y H:i:s').' GMT');
219 header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
220 header('Pragma: public');
9d65336 Initial import based on revision 1613 of PunBB.
Connor Dunn authored Apr 27, 2008
221
03b76fe @Quy Ported extern.php from 1.3 to 1.4.
Quy authored Jul 8, 2009
222 echo '<?xml version="1.0" encoding="utf-8"?>'."\n";
223 echo '<source>'."\n";
69c74f9 @reines Escaping the URL output in extern.php. This isnt critical as the base…
reines authored Oct 23, 2010
224 echo "\t".'<url>'.pun_htmlspecialchars($feed['link']).'</url>'."\n";
9d65336 Initial import based on revision 1613 of PunBB.
Connor Dunn authored Apr 27, 2008
225
03b76fe @Quy Ported extern.php from 1.3 to 1.4.
Quy authored Jul 8, 2009
226 $forum_tag = ($feed['type'] == 'posts') ? 'post' : 'topic';
9d65336 Initial import based on revision 1613 of PunBB.
Connor Dunn authored Apr 27, 2008
227
03b76fe @Quy Ported extern.php from 1.3 to 1.4.
Quy authored Jul 8, 2009
228 foreach ($feed['items'] as $item)
229 {
230 echo "\t".'<'.$forum_tag.' id="'.$item['id'].'">'."\n";
9d65336 Initial import based on revision 1613 of PunBB.
Connor Dunn authored Apr 27, 2008
231
03b76fe @Quy Ported extern.php from 1.3 to 1.4.
Quy authored Jul 8, 2009
232 echo "\t\t".'<title><![CDATA['.escape_cdata($item['title']).']]></title>'."\n";
69c74f9 @reines Escaping the URL output in extern.php. This isnt critical as the base…
reines authored Oct 23, 2010
233 echo "\t\t".'<link>'.pun_htmlspecialchars($item['link']).'</link>'."\n";
1bc3b18 @reines Changing extern descriptions to use CDATA rather than html encoding
reines authored Oct 12, 2009
234 echo "\t\t".'<content><![CDATA['.escape_cdata($item['description']).']]></content>'."\n";
03b76fe @Quy Ported extern.php from 1.3 to 1.4.
Quy authored Jul 8, 2009
235 echo "\t\t".'<author>'."\n";
236 echo "\t\t\t".'<name><![CDATA['.escape_cdata($item['author']['name']).']]></name>'."\n";
237
238 if (isset($item['author']['email']))
239 echo "\t\t\t".'<email><![CDATA['.escape_cdata($item['author']['email']).']]></email>'."\n";
240
241 if (isset($item['author']['uri']))
69c74f9 @reines Escaping the URL output in extern.php. This isnt critical as the base…
reines authored Oct 23, 2010
242 echo "\t\t\t".'<uri>'.pun_htmlspecialchars($item['author']['uri']).'</uri>'."\n";
03b76fe @Quy Ported extern.php from 1.3 to 1.4.
Quy authored Jul 8, 2009
243
244 echo "\t\t".'</author>'."\n";
245 echo "\t\t".'<posted>'.gmdate('r', $item['pubdate']).'</posted>'."\n";
246
247 echo "\t".'</'.$forum_tag.'>'."\n";
248 }
249
250 echo '</source>'."\n";
9d65336 Initial import based on revision 1613 of PunBB.
Connor Dunn authored Apr 27, 2008
251 }
252
253
254 //
03b76fe @Quy Ported extern.php from 1.3 to 1.4.
Quy authored Jul 8, 2009
255 // Output $feed as HTML (using <li> tags)
9d65336 Initial import based on revision 1613 of PunBB.
Connor Dunn authored Apr 27, 2008
256 //
03b76fe @Quy Ported extern.php from 1.3 to 1.4.
Quy authored Jul 8, 2009
257 function output_html($feed)
9d65336 Initial import based on revision 1613 of PunBB.
Connor Dunn authored Apr 27, 2008
258 {
259
03b76fe @Quy Ported extern.php from 1.3 to 1.4.
Quy authored Jul 8, 2009
260 // Send the Content-type header in case the web server is setup to send something else
261 header('Content-type: text/html; charset=utf-8');
262 header('Expires: '.gmdate('D, d M Y H:i:s').' GMT');
263 header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
264 header('Pragma: public');
265
266 foreach ($feed['items'] as $item)
9d65336 Initial import based on revision 1613 of PunBB.
Connor Dunn authored Apr 27, 2008
267 {
03b76fe @Quy Ported extern.php from 1.3 to 1.4.
Quy authored Jul 8, 2009
268 if (utf8_strlen($item['title']) > FORUM_EXTERN_MAX_SUBJECT_LENGTH)
8d5b6c0 @reines Replacing some entities with their UTF-8 character equivalent.
reines authored May 15, 2010
269 $subject_truncated = pun_htmlspecialchars(pun_trim(utf8_substr($item['title'], 0, (FORUM_EXTERN_MAX_SUBJECT_LENGTH - 5)))).'';
03b76fe @Quy Ported extern.php from 1.3 to 1.4.
Quy authored Jul 8, 2009
270 else
271 $subject_truncated = pun_htmlspecialchars($item['title']);
9d65336 Initial import based on revision 1613 of PunBB.
Connor Dunn authored Apr 27, 2008
272
69c74f9 @reines Escaping the URL output in extern.php. This isnt critical as the base…
reines authored Oct 23, 2010
273 echo '<li><a href="'.pun_htmlspecialchars($item['link']).'" title="'.pun_htmlspecialchars($item['title']).'">'.$subject_truncated.'</a></li>'."\n";
9d65336 Initial import based on revision 1613 of PunBB.
Connor Dunn authored Apr 27, 2008
274 }
03b76fe @Quy Ported extern.php from 1.3 to 1.4.
Quy authored Jul 8, 2009
275 }
9d65336 Initial import based on revision 1613 of PunBB.
Connor Dunn authored Apr 27, 2008
276
03b76fe @Quy Ported extern.php from 1.3 to 1.4.
Quy authored Jul 8, 2009
277 // Show recent discussions
278 if ($action == 'feed')
279 {
c979351 @reines Changing the parser to output html rather than bbcode, since pretty m…
reines authored Oct 11, 2009
280 require PUN_ROOT.'include/parser.php';
281
03b76fe @Quy Ported extern.php from 1.3 to 1.4.
Quy authored Jul 8, 2009
282 // Determine what type of feed to output
b9774ac @reines Updating extern.php to not be case-sensitive
reines authored Jul 31, 2010
283 $type = isset($_GET['type']) ? strtolower($_GET['type']) : 'html';
cfa272f @reines Fixing a missed variable in the last commit, oops...
reines authored Jul 31, 2010
284 if (!in_array($type, array('html', 'rss', 'atom', 'xml')))
b9774ac @reines Updating extern.php to not be case-sensitive
reines authored Jul 31, 2010
285 $type = 'html';
9d65336 Initial import based on revision 1613 of PunBB.
Connor Dunn authored Apr 27, 2008
286
03b76fe @Quy Ported extern.php from 1.3 to 1.4.
Quy authored Jul 8, 2009
287 $show = isset($_GET['show']) ? intval($_GET['show']) : 15;
288 if ($show < 1 || $show > 50)
289 $show = 15;
9d65336 Initial import based on revision 1613 of PunBB.
Connor Dunn authored Apr 27, 2008
290
03b76fe @Quy Ported extern.php from 1.3 to 1.4.
Quy authored Jul 8, 2009
291 // Was a topic ID supplied?
292 if (isset($_GET['tid']))
9d65336 Initial import based on revision 1613 of PunBB.
Connor Dunn authored Apr 27, 2008
293 {
03b76fe @Quy Ported extern.php from 1.3 to 1.4.
Quy authored Jul 8, 2009
294 $tid = intval($_GET['tid']);
9d65336 Initial import based on revision 1613 of PunBB.
Connor Dunn authored Apr 27, 2008
295
4f725e6 @reines Only perform caching for forum feeds with no forums explicitly includ…
reines authored Feb 6, 2011
296 // Fetch topic subject
7c97871 @daris Updating to use new db layer
daris authored Oct 27, 2011
297 $query = $db->select(array('subject' => 't.subject', 'first_post_id' => 't.first_post_id'), 'topics AS t');
5737059 @reines Converting the queries in extern.php
reines authored Apr 7, 2011
298
861460d @daris PHP methods are not case sensitive, but replace InnerJoin and LeftJoi…
daris authored Nov 6, 2011
299 $query->leftJoin('fp', 'forum_perms AS fp', 'fp.forum_id = t.forum_id AND fp.group_id = :group_id');
5737059 @reines Converting the queries in extern.php
reines authored Apr 7, 2011
300
301 $query->where = '(fp.read_forum IS NULL OR fp.read_forum = 1) AND t.moved_to IS NULL AND t.id = :topic_id';
302
303 $params = array(':group_id' => $pun_user['g_id'], ':topic_id' => $tid);
304
7c97871 @daris Updating to use new db layer
daris authored Oct 27, 2011
305 $result = $query->run($params);
5737059 @reines Converting the queries in extern.php
reines authored Apr 7, 2011
306 if (empty($result))
d95bfba @reines Adding caching for syndication.
reines authored Feb 3, 2011
307 {
4f725e6 @reines Only perform caching for forum feeds with no forums explicitly includ…
reines authored Feb 6, 2011
308 http_authenticate_user();
664cb8b @franzliedke #367: Add Gettext file common.po (and .mo, too) and use that in all t…
franzliedke authored Sep 19, 2011
309 exit($lang->t('Bad request'));
4f725e6 @reines Only perform caching for forum feeds with no forums explicitly includ…
reines authored Feb 6, 2011
310 }
03b76fe @Quy Ported extern.php from 1.3 to 1.4.
Quy authored Jul 8, 2009
311
5737059 @reines Converting the queries in extern.php
reines authored Apr 7, 2011
312 $cur_topic = $result[0];
313 unset ($result, $query, $params);
9d65336 Initial import based on revision 1613 of PunBB.
Connor Dunn authored Apr 27, 2008
314
4f725e6 @reines Only perform caching for forum feeds with no forums explicitly includ…
reines authored Feb 6, 2011
315 if ($pun_config['o_censoring'] == '1')
316 $cur_topic['subject'] = censor_words($cur_topic['subject']);
d95bfba @reines Adding caching for syndication.
reines authored Feb 3, 2011
317
4f725e6 @reines Only perform caching for forum feeds with no forums explicitly includ…
reines authored Feb 6, 2011
318 // Setup the feed
319 $feed = array(
664cb8b @franzliedke #367: Add Gettext file common.po (and .mo, too) and use that in all t…
franzliedke authored Sep 19, 2011
320 'title' => $pun_config['o_board_title'].$lang->t('Title separator').$cur_topic['subject'],
4f725e6 @reines Only perform caching for forum feeds with no forums explicitly includ…
reines authored Feb 6, 2011
321 'link' => get_base_url(true).'/viewtopic.php?id='.$tid,
a5a577f @daris Use $lang->t() instead of sprintf/printf
daris authored Oct 28, 2011
322 'description' => $lang->t('RSS description topic', $cur_topic['subject']),
4f725e6 @reines Only perform caching for forum feeds with no forums explicitly includ…
reines authored Feb 6, 2011
323 'items' => array(),
324 'type' => 'posts'
325 );
326
327 // Fetch $show posts
7c97871 @daris Updating to use new db layer
daris authored Oct 27, 2011
328 $query = $db->select(array('pid' => 'p.id', 'poster' => 'p.poster', 'message' => 'p.message', 'hide_smilies' => 'p.hide_smilies', 'posted' => 'p.posted', 'posted_id' => 'p.poster_id', 'email_setting' => 'u.email_setting', 'email' => 'u.email', 'poster_email' => 'p.poster_email'), 'posts AS p');
5737059 @reines Converting the queries in extern.php
reines authored Apr 7, 2011
329
861460d @daris PHP methods are not case sensitive, but replace InnerJoin and LeftJoi…
daris authored Nov 6, 2011
330 $query->innerJoin('u', 'users AS u', 'u.id = p.poster_id');
5737059 @reines Converting the queries in extern.php
reines authored Apr 7, 2011
331
332 $query->where = 'p.topic_id = :topic_id';
333 $query->order = array('posted' => 'p.posted DESC');
334 $query->limit = $show;
335
336 $params = array(':topic_id' => $tid);
337
7c97871 @daris Updating to use new db layer
daris authored Oct 27, 2011
338 $result = $query->run($params);
5737059 @reines Converting the queries in extern.php
reines authored Apr 7, 2011
339 foreach ($result as $cur_post)
4f725e6 @reines Only perform caching for forum feeds with no forums explicitly includ…
reines authored Feb 6, 2011
340 {
341 $cur_post['message'] = parse_message($cur_post['message'], $cur_post['hide_smilies']);
342
343 $item = array(
344 'id' => $cur_post['id'],
13a3c6a @franzliedke Make some language file improvements and move comments in there to th…
franzliedke authored Nov 30, 2011
345 'title' => $cur_topic['first_post_id'] == $cur_post['id'] ? $cur_topic['subject'] : $lang->t('RSS reply', $cur_topic['subject']),
4f725e6 @reines Only perform caching for forum feeds with no forums explicitly includ…
reines authored Feb 6, 2011
346 'link' => get_base_url(true).'/viewtopic.php?pid='.$cur_post['id'].'#p'.$cur_post['id'],
347 'description' => $cur_post['message'],
348 'author' => array(
349 'name' => $cur_post['poster'],
350 ),
351 'pubdate' => $cur_post['posted']
03b76fe @Quy Ported extern.php from 1.3 to 1.4.
Quy authored Jul 8, 2009
352 );
353
4f725e6 @reines Only perform caching for forum feeds with no forums explicitly includ…
reines authored Feb 6, 2011
354 if ($cur_post['poster_id'] > 1)
03b76fe @Quy Ported extern.php from 1.3 to 1.4.
Quy authored Jul 8, 2009
355 {
4f725e6 @reines Only perform caching for forum feeds with no forums explicitly includ…
reines authored Feb 6, 2011
356 if ($cur_post['email_setting'] == '0' && !$pun_user['is_guest'])
357 $item['author']['email'] = $cur_post['email'];
d95bfba @reines Adding caching for syndication.
reines authored Feb 3, 2011
358
4f725e6 @reines Only perform caching for forum feeds with no forums explicitly includ…
reines authored Feb 6, 2011
359 $item['author']['uri'] = get_base_url(true).'/profile.php?id='.$cur_post['poster_id'];
03b76fe @Quy Ported extern.php from 1.3 to 1.4.
Quy authored Jul 8, 2009
360 }
4f725e6 @reines Only perform caching for forum feeds with no forums explicitly includ…
reines authored Feb 6, 2011
361 else if ($cur_post['poster_email'] != '' && !$pun_user['is_guest'])
362 $item['author']['email'] = $cur_post['poster_email'];
03b76fe @Quy Ported extern.php from 1.3 to 1.4.
Quy authored Jul 8, 2009
363
4f725e6 @reines Only perform caching for forum feeds with no forums explicitly includ…
reines authored Feb 6, 2011
364 $feed['items'][] = $item;
03b76fe @Quy Ported extern.php from 1.3 to 1.4.
Quy authored Jul 8, 2009
365 }
9d65336 Initial import based on revision 1613 of PunBB.
Connor Dunn authored Apr 27, 2008
366
5737059 @reines Converting the queries in extern.php
reines authored Apr 7, 2011
367 unset ($result, $query, $params);
368
03b76fe @Quy Ported extern.php from 1.3 to 1.4.
Quy authored Jul 8, 2009
369 $output_func = 'output_'.$type;
370 $output_func($feed);
371 }
9d65336 Initial import based on revision 1613 of PunBB.
Connor Dunn authored Apr 27, 2008
372 else
373 {
b9774ac @reines Updating extern.php to not be case-sensitive
reines authored Jul 31, 2010
374 $order_posted = isset($_GET['order']) && strtolower($_GET['order']) == 'posted';
03b76fe @Quy Ported extern.php from 1.3 to 1.4.
Quy authored Jul 8, 2009
375 $forum_name = '';
5737059 @reines Converting the queries in extern.php
reines authored Apr 7, 2011
376
7c97871 @daris Updating to use new db layer
daris authored Oct 27, 2011
377 $post_query = $db->select(array('t.id, t.poster, t.subject, t.posted, t.last_post, t.last_poster, p.message, p.hide_smilies, u.email_setting, u.email, p.poster_id, p.poster_email'), 'topics AS t');
5737059 @reines Converting the queries in extern.php
reines authored Apr 7, 2011
378
9e5fe49 @daris Fix syntax error in extern.php
daris authored Nov 25, 2011
379 $post_query->innerJoin('p', 'posts AS p', 'p.id = '.($order_posted ? 't.first_post_id' : 't.last_post_id'));
5737059 @reines Converting the queries in extern.php
reines authored Apr 7, 2011
380
72a3beb @daris Fix query in extern.php
daris authored Nov 25, 2011
381 $post_query->innerJoin('u', 'users AS u', 'u.id = p.poster_id');
5737059 @reines Converting the queries in extern.php
reines authored Apr 7, 2011
382
861460d @daris PHP methods are not case sensitive, but replace InnerJoin and LeftJoi…
daris authored Nov 6, 2011
383 $post_query->leftJoin('fp', 'forum_perms AS fp', 'fp.forum_id = t.forum_id AND fp.group_id = :group_id');
5737059 @reines Converting the queries in extern.php
reines authored Apr 7, 2011
384
385 $post_query->where = '(fp.read_forum IS NULL OR fp.read_forum = 1) AND t.moved_to IS NULL';
386 $post_query->order = array('sort' => ($order_posted ? 't.posted' : 't.last_post').' DESC');
387 $post_query->limit = 50;
388
389 $post_params = array(':group_id' => $pun_user['g_id']);
56ab252 Updated copyright texts.
Frank Smit authored Oct 17, 2009
390
5cd7d63 @reines A bunch of consistency changes (mainly in comments). Submitted by Dar…
reines authored Nov 26, 2009
391 // Were any forum IDs supplied?
03b76fe @Quy Ported extern.php from 1.3 to 1.4.
Quy authored Jul 8, 2009
392 if (isset($_GET['fid']) && is_scalar($_GET['fid']) && $_GET['fid'] != '')
393 {
394 $fids = explode(',', pun_trim($_GET['fid']));
395 $fids = array_map('intval', $fids);
396
397 if (!empty($fids))
5737059 @reines Converting the queries in extern.php
reines authored Apr 7, 2011
398 {
399 $post_query->where .= ' AND t.forum_id IN :fids';
400 $post_params[':fids'] = $fids;
401 }
03b76fe @Quy Ported extern.php from 1.3 to 1.4.
Quy authored Jul 8, 2009
402
403 if (count($fids) == 1)
404 {
b310de9 @Quy Added censoring checking to extern.php.
Quy authored Feb 3, 2010
405 // Fetch forum name
7c97871 @daris Updating to use new db layer
daris authored Oct 27, 2011
406 $query = $db->select(array('forum_name' => 'f.forum_name'), 'forums AS f');
5737059 @reines Converting the queries in extern.php
reines authored Apr 7, 2011
407
861460d @daris PHP methods are not case sensitive, but replace InnerJoin and LeftJoi…
daris authored Nov 6, 2011
408 $query->leftJoin('fp', 'forum_perms AS fp', 'fp.forum_id = f.id AND fp.group_id = :group_id');
5737059 @reines Converting the queries in extern.php
reines authored Apr 7, 2011
409
410 $query->where = '(fp.read_forum IS NULL OR fp.read_forum = 1) AND f.id = :forum_id';
411
412 $params = array(':group_id' => $pun_user['g_id'], ':forum_id' => $fids[0]);
413
7c97871 @daris Updating to use new db layer
daris authored Oct 27, 2011
414 $result = $query->run($params);
5737059 @reines Converting the queries in extern.php
reines authored Apr 7, 2011
415 if (!empty($result))
586bc04 @franzliedke Merge branch 'fluxbb-2.0-db' into fluxbb-2.0
franzliedke authored Oct 28, 2011
416 $forum_name = $lang->t('Title separator').$result[0]['forum_name'];
5737059 @reines Converting the queries in extern.php
reines authored Apr 7, 2011
417
418 unset ($result, $query, $params);
03b76fe @Quy Ported extern.php from 1.3 to 1.4.
Quy authored Jul 8, 2009
419 }
420 }
9d65336 Initial import based on revision 1613 of PunBB.
Connor Dunn authored Apr 27, 2008
421
5cd7d63 @reines A bunch of consistency changes (mainly in comments). Submitted by Dar…
reines authored Nov 26, 2009
422 // Any forum IDs to exclude?
03b76fe @Quy Ported extern.php from 1.3 to 1.4.
Quy authored Jul 8, 2009
423 if (isset($_GET['nfid']) && is_scalar($_GET['nfid']) && $_GET['nfid'] != '')
424 {
425 $nfids = explode(',', pun_trim($_GET['nfid']));
426 $nfids = array_map('intval', $nfids);
9d65336 Initial import based on revision 1613 of PunBB.
Connor Dunn authored Apr 27, 2008
427
03b76fe @Quy Ported extern.php from 1.3 to 1.4.
Quy authored Jul 8, 2009
428 if (!empty($nfids))
5737059 @reines Converting the queries in extern.php
reines authored Apr 7, 2011
429 {
430 $post_query->where .= ' AND t.forum_id NOT IN :nfids';
431 $post_params[':nfids'] = $nfids;
432 }
03b76fe @Quy Ported extern.php from 1.3 to 1.4.
Quy authored Jul 8, 2009
433 }
434
903c708 @reines Also cache single forum feeds.
reines authored Feb 6, 2011
435 // Only attempt to cache if caching is enabled and we have all or a single forum
436 if ($pun_config['o_feed_ttl'] > 0 && ($forum_sql == '' || ($forum_name != '' && !isset($_GET['nfid']))))
c6a1eb4 @reines Temporarily adding the cache loading into db_update and install scripts
reines authored Feb 28, 2011
437 {
664cb8b @franzliedke #367: Add Gettext file common.po (and .mo, too) and use that in all t…
franzliedke authored Sep 19, 2011
438 $cache_id = 'feed.'.$pun_user['g_id'].'.'.$lang->t('lang_identifier').'.'.($order_posted ? '1' : '0').($forum_name == '' ? '' : '.'.$fids[0]);
c6a1eb4 @reines Temporarily adding the cache loading into db_update and install scripts
reines authored Feb 28, 2011
439 $feed = $cache->get($cache_id);
440 }
91c2c6c @ridgerunner Cleaned all lines having trailing whitespace
ridgerunner authored Feb 5, 2010
441
51f7ddb @reines Moving assignment down since it isnt required when accessing topics.
reines authored Feb 7, 2011
442 $now = time();
f90f415 @reines Updating cache module, now uses namespaces.
reines authored Jan 14, 2012
443 if (!isset($feed) || $feed === \fluxbb\cache\Cache::NOT_FOUND)
d95bfba @reines Adding caching for syndication.
reines authored Feb 3, 2011
444 {
445 // Setup the feed
446 $feed = array(
447 'title' => $pun_config['o_board_title'].$forum_name,
c012486 @reines Fixing handling of http/https when caching syndication feeds. Spotted…
reines authored Feb 9, 2011
448 'link' => '/index.php',
a5a577f @daris Use $lang->t() instead of sprintf/printf
daris authored Oct 28, 2011
449 'description' => $lang->t('RSS description', $pun_config['o_board_title']),
d95bfba @reines Adding caching for syndication.
reines authored Feb 3, 2011
450 'items' => array(),
451 'type' => 'topics'
03b76fe @Quy Ported extern.php from 1.3 to 1.4.
Quy authored Jul 8, 2009
452 );
453
5737059 @reines Converting the queries in extern.php
reines authored Apr 7, 2011
454 // Fetch topics
7c97871 @daris Updating to use new db layer
daris authored Oct 27, 2011
455 $result = $post_query->run($post_params);
5737059 @reines Converting the queries in extern.php
reines authored Apr 7, 2011
456 foreach ($result as $cur_topic)
03b76fe @Quy Ported extern.php from 1.3 to 1.4.
Quy authored Jul 8, 2009
457 {
d95bfba @reines Adding caching for syndication.
reines authored Feb 3, 2011
458 if ($pun_config['o_censoring'] == '1')
459 $cur_topic['subject'] = censor_words($cur_topic['subject']);
460
461 $cur_topic['message'] = parse_message($cur_topic['message'], $cur_topic['hide_smilies']);
462
463 $item = array(
464 'id' => $cur_topic['id'],
465 'title' => $cur_topic['subject'],
c012486 @reines Fixing handling of http/https when caching syndication feeds. Spotted…
reines authored Feb 9, 2011
466 'link' => '/viewtopic.php?id='.$cur_topic['id'].($order_posted ? '' : '&action=new'),
d95bfba @reines Adding caching for syndication.
reines authored Feb 3, 2011
467 'description' => $cur_topic['message'],
468 'author' => array(
469 'name' => $order_posted ? $cur_topic['poster'] : $cur_topic['last_poster']
470 ),
471 'pubdate' => $order_posted ? $cur_topic['posted'] : $cur_topic['last_post']
472 );
473
474 if ($cur_topic['poster_id'] > 1)
475 {
476 if ($cur_topic['email_setting'] == '0' && !$pun_user['is_guest'])
477 $item['author']['email'] = $cur_topic['email'];
478
c012486 @reines Fixing handling of http/https when caching syndication feeds. Spotted…
reines authored Feb 9, 2011
479 $item['author']['uri'] = '/profile.php?id='.$cur_topic['poster_id'];
d95bfba @reines Adding caching for syndication.
reines authored Feb 3, 2011
480 }
481 else if ($cur_topic['poster_email'] != '' && !$pun_user['is_guest'])
482 $item['author']['email'] = $cur_topic['poster_email'];
483
484 $feed['items'][] = $item;
03b76fe @Quy Ported extern.php from 1.3 to 1.4.
Quy authored Jul 8, 2009
485 }
486
5737059 @reines Converting the queries in extern.php
reines authored Apr 7, 2011
487 unset ($result, $post_query, $post_params);
488
d95bfba @reines Adding caching for syndication.
reines authored Feb 3, 2011
489 // Output feed as PHP code
4f725e6 @reines Only perform caching for forum feeds with no forums explicitly includ…
reines authored Feb 6, 2011
490 if (isset($cache_id))
c6a1eb4 @reines Temporarily adding the cache loading into db_update and install scripts
reines authored Feb 28, 2011
491 $cache->set($cache_id, $feed, $pun_config['o_feed_ttl'] * 60);
9d65336 Initial import based on revision 1613 of PunBB.
Connor Dunn authored Apr 27, 2008
492 }
03b76fe @Quy Ported extern.php from 1.3 to 1.4.
Quy authored Jul 8, 2009
493
4f725e6 @reines Only perform caching for forum feeds with no forums explicitly includ…
reines authored Feb 6, 2011
494 // If we only want to show a few items but due to caching we have too many
495 if (count($feed['items']) > $show)
496 $feed['items'] = array_slice($feed['items'], 0, $show);
497
c012486 @reines Fixing handling of http/https when caching syndication feeds. Spotted…
reines authored Feb 9, 2011
498 // Prepend the current base URL onto some links. Done after caching to handle http/https correctly
499 $feed['link'] = get_base_url(true).$feed['link'];
500
15db2b9 @reines Fixing previous commit.
reines authored Feb 9, 2011
501 foreach ($feed['items'] as $key => $item)
c012486 @reines Fixing handling of http/https when caching syndication feeds. Spotted…
reines authored Feb 9, 2011
502 {
15db2b9 @reines Fixing previous commit.
reines authored Feb 9, 2011
503 $feed['items'][$key]['link'] = get_base_url(true).$item['link'];
c012486 @reines Fixing handling of http/https when caching syndication feeds. Spotted…
reines authored Feb 9, 2011
504
505 if (isset($item['author']['uri']))
15db2b9 @reines Fixing previous commit.
reines authored Feb 9, 2011
506 $feed['items'][$key]['author']['uri'] = get_base_url(true).$item['author']['uri'];
c012486 @reines Fixing handling of http/https when caching syndication feeds. Spotted…
reines authored Feb 9, 2011
507 }
508
03b76fe @Quy Ported extern.php from 1.3 to 1.4.
Quy authored Jul 8, 2009
509 $output_func = 'output_'.$type;
510 $output_func($feed);
9d65336 Initial import based on revision 1613 of PunBB.
Connor Dunn authored Apr 27, 2008
511 }
512
03b76fe @Quy Ported extern.php from 1.3 to 1.4.
Quy authored Jul 8, 2009
513 exit;
9d65336 Initial import based on revision 1613 of PunBB.
Connor Dunn authored Apr 27, 2008
514 }
515
516 // Show users online
03b76fe @Quy Ported extern.php from 1.3 to 1.4.
Quy authored Jul 8, 2009
517 else if ($action == 'online' || $action == 'online_full')
9d65336 Initial import based on revision 1613 of PunBB.
Connor Dunn authored Apr 27, 2008
518 {
519 // Load the index.php language file
6373198 @franzliedke #498: Convert index.php language file.
franzliedke authored Sep 25, 2011
520 $lang->load('index');
03b76fe @Quy Ported extern.php from 1.3 to 1.4.
Quy authored Jul 8, 2009
521
9d65336 Initial import based on revision 1613 of PunBB.
Connor Dunn authored Apr 27, 2008
522 // Fetch users online info and generate strings for output
523 $num_guests = $num_users = 0;
524 $users = array();
525
7c97871 @daris Updating to use new db layer
daris authored Oct 27, 2011
526 $query = $db->select(array('user_id' => 'o.user_id', 'ident' => 'o.ident'), 'online AS o');
5737059 @reines Converting the queries in extern.php
reines authored Apr 7, 2011
527 $query->where = 'o.idle = 0';
528 $query->order = array('ident' => 'o.ident ASC');
56ab252 Updated copyright texts.
Frank Smit authored Oct 17, 2009
529
5737059 @reines Converting the queries in extern.php
reines authored Apr 7, 2011
530 $params = array();
531
7c97871 @daris Updating to use new db layer
daris authored Oct 27, 2011
532 $result = $query->run($params);
5737059 @reines Converting the queries in extern.php
reines authored Apr 7, 2011
533 foreach ($result as $pun_user_online)
9d65336 Initial import based on revision 1613 of PunBB.
Connor Dunn authored Apr 27, 2008
534 {
535 if ($pun_user_online['user_id'] > 1)
536 {
69c74f9 @reines Escaping the URL output in extern.php. This isnt critical as the base…
reines authored Oct 23, 2010
537 $users[] = ($pun_user['g_view_users'] == '1') ? '<a href="'.pun_htmlspecialchars(get_base_url(true)).'/profile.php?id='.$pun_user_online['user_id'].'">'.pun_htmlspecialchars($pun_user_online['ident']).'</a>' : pun_htmlspecialchars($pun_user_online['ident']);
9d65336 Initial import based on revision 1613 of PunBB.
Connor Dunn authored Apr 27, 2008
538 ++$num_users;
539 }
540 else
541 ++$num_guests;
542 }
543
5737059 @reines Converting the queries in extern.php
reines authored Apr 7, 2011
544 unset ($result, $query, $params);
545
03b76fe @Quy Ported extern.php from 1.3 to 1.4.
Quy authored Jul 8, 2009
546 // Send the Content-type header in case the web server is setup to send something else
547 header('Content-type: text/html; charset=utf-8');
548 header('Expires: '.gmdate('D, d M Y H:i:s').' GMT');
549 header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
550 header('Pragma: public');
56ab252 Updated copyright texts.
Frank Smit authored Oct 17, 2009
551
a5a577f @daris Use $lang->t() instead of sprintf/printf
daris authored Oct 28, 2011
552 echo $lang->t('Guests online', forum_number_format($num_guests)).'<br />'."\n";
9d65336 Initial import based on revision 1613 of PunBB.
Connor Dunn authored Apr 27, 2008
553
03b76fe @Quy Ported extern.php from 1.3 to 1.4.
Quy authored Jul 8, 2009
554 if ($action == 'online_full' && !empty($users))
a5a577f @daris Use $lang->t() instead of sprintf/printf
daris authored Oct 28, 2011
555 echo $lang->t('Users online', implode(', ', $users)).'<br />'."\n";
9d65336 Initial import based on revision 1613 of PunBB.
Connor Dunn authored Apr 27, 2008
556 else
a5a577f @daris Use $lang->t() instead of sprintf/printf
daris authored Oct 28, 2011
557 echo $lang->t('Users online', forum_number_format($num_users)).'<br />'."\n";
9d65336 Initial import based on revision 1613 of PunBB.
Connor Dunn authored Apr 27, 2008
558
03b76fe @Quy Ported extern.php from 1.3 to 1.4.
Quy authored Jul 8, 2009
559 exit;
9d65336 Initial import based on revision 1613 of PunBB.
Connor Dunn authored Apr 27, 2008
560 }
561
562 // Show board statistics
03b76fe @Quy Ported extern.php from 1.3 to 1.4.
Quy authored Jul 8, 2009
563 else if ($action == 'stats')
9d65336 Initial import based on revision 1613 of PunBB.
Connor Dunn authored Apr 27, 2008
564 {
565 // Load the index.php language file
6373198 @franzliedke #498: Convert index.php language file.
franzliedke authored Sep 25, 2011
566 $lang->load('index');
9d65336 Initial import based on revision 1613 of PunBB.
Connor Dunn authored Apr 27, 2008
567
c0d9338 @reines Removing final parts of old cache system.
reines authored Feb 28, 2011
568 // Collect some board statistics
569 $stats = fetch_board_stats();
9d65336 Initial import based on revision 1613 of PunBB.
Connor Dunn authored Apr 27, 2008
570
7c97871 @daris Updating to use new db layer
daris authored Oct 27, 2011
571 $query = $db->select(array('total_topics' => 'SUM(f.num_topics) AS total_topics', 'total_posts' => 'SUM(num_posts) AS total_posts'), 'forums AS f');
5737059 @reines Converting the queries in extern.php
reines authored Apr 7, 2011
572 $params = array();
573
7c97871 @daris Updating to use new db layer
daris authored Oct 27, 2011
574 $stats = array_merge($stats, current($query->run($params)));
5737059 @reines Converting the queries in extern.php
reines authored Apr 7, 2011
575 unset ($query, $params);
56ab252 Updated copyright texts.
Frank Smit authored Oct 17, 2009
576
03b76fe @Quy Ported extern.php from 1.3 to 1.4.
Quy authored Jul 8, 2009
577 // Send the Content-type header in case the web server is setup to send something else
578 header('Content-type: text/html; charset=utf-8');
579 header('Expires: '.gmdate('D, d M Y H:i:s').' GMT');
580 header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
581 header('Pragma: public');
582
a5a577f @daris Use $lang->t() instead of sprintf/printf
daris authored Oct 28, 2011
583 echo $lang->t('No of users', forum_number_format($stats['total_users'])).'<br />'."\n";
584 echo $lang->t('Newest user', (($pun_user['g_view_users'] == '1') ? '<a href="'.pun_htmlspecialchars(get_base_url(true)).'/profile.php?id='.$stats['last_user']['id'].'">'.pun_htmlspecialchars($stats['last_user']['username']).'</a>' : pun_htmlspecialchars($stats['last_user']['username']))).'<br />'."\n";
585 echo $lang->t('No of topics', forum_number_format($stats['total_topics'])).'<br />'."\n";
586 echo $lang->t('No of posts', forum_number_format($stats['total_posts'])).'<br />'."\n";
56ab252 Updated copyright texts.
Frank Smit authored Oct 17, 2009
587
03b76fe @Quy Ported extern.php from 1.3 to 1.4.
Quy authored Jul 8, 2009
588 exit;
9d65336 Initial import based on revision 1613 of PunBB.
Connor Dunn authored Apr 27, 2008
589 }
590
03b76fe @Quy Ported extern.php from 1.3 to 1.4.
Quy authored Jul 8, 2009
591 // If we end up here, the script was called with some wacky parameters
664cb8b @franzliedke #367: Add Gettext file common.po (and .mo, too) and use that in all t…
franzliedke authored Sep 19, 2011
592 exit($lang->t('Bad request'));
Something went wrong with that request. Please try again.