's)
fid: One or more forum ID's (comma-separated). If ignored,
topics from all readable forums will be pulled.
nfid: One or more forum ID's (comma-separated) that are to be
excluded. E.g. the ID of a a test forum.
tid: A topic ID from which to show posts. If a tid is supplied,
fid and nfid are ignored.
show: Any integer value between 1 and 50. The default is 15.
/***********************************************************************/
define('FORUM_QUIET_VISIT', 1);
if (!defined('FORUM_ROOT'))
define('FORUM_ROOT', './');
require FORUM_ROOT.'include/common.php';
($hook = get_hook('ex_start')) ? eval($hook) : null;
// The length at which topic subjects will be truncated (for HTML output)
if (!defined('FORUM_EXTERN_MAX_SUBJECT_LENGTH'))
define('FORUM_EXTERN_MAX_SUBJECT_LENGTH', 30);
// If we're a guest and we've sent a username/pass, we can try to authenticate using those details
if ($forum_user['is_guest'] && isset($_SERVER['PHP_AUTH_USER']))
authenticate_user($_SERVER['PHP_AUTH_USER'], $_SERVER['PHP_AUTH_PW']);
if ($forum_user['g_read_board'] == '0')
{
http_authenticate_user();
exit($lang_common['No view']);
}
$action = isset($_GET['action']) ? $_GET['action'] : 'feed';
//
// Sends the proper headers for Basic HTTP Authentication
//
function http_authenticate_user()
{
global $forum_config, $forum_user;
if (!$forum_user['is_guest'])
return;
header('WWW-Authenticate: Basic realm="'.$forum_config['o_board_title'].' External Syndication"');
header('HTTP/1.0 401 Unauthorized');
}
//
// Output $feed as RSS 2.0
//
function output_rss($feed)
{
global $lang_common, $forum_config;
// Send XML/no cache headers
header('Content-Type: text/xml; charset=utf-8');
header('Expires: '.gmdate('D, d M Y H:i:s').' GMT');
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Pragma: public');
echo ''."\n";
echo ''."\n";
echo "\t".''."\n";
echo "\t\t".''."\n";
echo "\t\t".''.$feed['link'].''."\n";
echo "\t\t".''."\n";
echo "\t\t".''.gmdate('r', count($feed['items']) ? $feed['items'][0]['pubdate'] : time()).''."\n";
if ($forum_config['o_show_version'] == '1')
echo "\t\t".'PunBB '.$forum_config['o_cur_version'].''."\n";
else
echo "\t\t".'PunBB'."\n";
($hook = get_hook('ex_add_new_rss_info')) ? eval($hook) : null;
foreach ($feed['items'] as $item)
{
echo "\t\t".''."\n";
echo "\t\t\t".''."\n";
echo "\t\t\t".''.$item['link'].''."\n";
echo "\t\t\t".''."\n";
echo "\t\t\t".''."\n";
echo "\t\t\t".''.gmdate('r', $item['pubdate']).''."\n";
echo "\t\t\t".''.$item['link'].''."\n";
($hook = get_hook('ex_add_new_rss_item_info')) ? eval($hook) : null;
echo "\t\t".''."\n";
}
echo "\t".''."\n";
echo ''."\n";
}
//
// Output $feed as Atom 1.0
//
function output_atom($feed)
{
global $lang_common, $forum_config;
// Send XML/no cache headers
header('Content-Type: text/xml; charset=utf-8');
header('Expires: '.gmdate('D, d M Y H:i:s').' GMT');
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Pragma: public');
echo ''."\n";
echo ''."\n";
echo "\t".''."\n";
echo "\t".''."\n";
echo "\t".''.gmdate('Y-m-d\TH:i:s\Z', count($feed['items']) ? $feed['items'][0]['pubdate'] : time()).''."\n";
if ($forum_config['o_show_version'] == '1')
echo "\t".'PunBB'."\n";
else
echo "\t".'PunBB'."\n";
($hook = get_hook('ex_add_new_atom_info')) ? eval($hook) : null;
echo "\t".''.$feed['link'].''."\n";
$content_tag = ($feed['type'] == 'posts') ? 'content' : 'summary';
foreach ($feed['items'] as $item)
{
echo "\t\t".''."\n";
echo "\t\t\t".''."\n";
echo "\t\t\t".''."\n";
echo "\t\t\t".'<'.$content_tag.' type="html">'.$content_tag.'>'."\n";
echo "\t\t\t".''."\n";
echo "\t\t\t\t".''."\n";
if (isset($item['author']['email']))
echo "\t\t\t\t".''."\n";
if (isset($item['author']['uri']))
echo "\t\t\t\t".''.$item['author']['uri'].''."\n";
echo "\t\t\t".''."\n";
echo "\t\t\t".''.gmdate('Y-m-d\TH:i:s\Z', $item['pubdate']).''."\n";
($hook = get_hook('ex_add_new_atom_item_info')) ? eval($hook) : null;
echo "\t\t\t".''.$item['link'].''."\n";
echo "\t\t".''."\n";
}
echo ''."\n";
}
//
// Output $feed as XML
//
function output_xml($feed)
{
global $lang_common, $forum_config;
// Send XML/no cache headers
header('Content-Type: application/xml; charset=utf-8');
header('Expires: '.gmdate('D, d M Y H:i:s').' GMT');
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Pragma: public');
echo ''."\n";
echo ''."\n";
echo "\t".''.$feed['link'].''."\n";
($hook = get_hook('ex_add_new_xml_info')) ? eval($hook) : null;
$forum_tag = ($feed['type'] == 'posts') ? 'post' : 'topic';
foreach ($feed['items'] as $item)
{
echo "\t".'<'.$forum_tag.' id="'.$item['id'].'">'."\n";
echo "\t\t".''."\n";
echo "\t\t".''.$item['link'].''."\n";
echo "\t\t".''."\n";
echo "\t\t".''."\n";
echo "\t\t\t".''."\n";
if (isset($item['author']['email']))
echo "\t\t\t".''."\n";
if (isset($item['author']['uri']))
echo "\t\t\t".''.$item['author']['uri'].''."\n";
echo "\t\t".''."\n";
echo "\t\t".''.gmdate('r', $item['pubdate']).''."\n";
($hook = get_hook('ex_add_new_xml_item_info')) ? eval($hook) : null;
echo "\t".''.$forum_tag.'>'."\n";
}
echo ''."\n";
}
//
// Output $feed as HTML (using
tags)
//
function output_html($feed)
{
// Send the Content-type header in case the web server is setup to send something else
header('Content-type: text/html; charset=utf-8');
header('Expires: '.gmdate('D, d M Y H:i:s').' GMT');
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Pragma: public');
foreach ($feed['items'] as $item)
{
if (utf8_strlen($item['title']) > FORUM_EXTERN_MAX_SUBJECT_LENGTH)
$subject_truncated = forum_htmlencode(forum_trim(utf8_substr($item['title'], 0, (FORUM_EXTERN_MAX_SUBJECT_LENGTH - 5)))).'…';
else
$subject_truncated = forum_htmlencode($item['title']);
echo '