Code: Select all
$chars = 500; //Maximum
Code: Select all
<?php
/*
*
* @package phpBB3
* @version $Id: syndication.php,v 1.0 2006/11/27 22:29:16 angelside Exp $
* Modified by CK for holographyforum.org
* @copyright (c) Canver Software
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
* Updated by several people: 2008-01-17 - Version 1.1.1f
*
*/
/**
*/
define('IN_PHPBB', true);
$phpbb_root_path = './';
$phpEx = substr(strrchr(__FILE__, '.'), 1);
include($phpbb_root_path . 'common.' . $phpEx);
// Start session management
$user->session_begin();
$auth->acl($user->data);
$user->setup();
// Begin configuration
$CFG['exclude_forums'] = '';
$CFG['max_topics'] = '20';
// End configuration
// Requests
$fid = request_var('fid', '');
$count = request_var('count', 0);
$chars = request_var('chars', 200);
$type = request_var('type', '');
$topics_only = request_var('t', '');
// If not set, set the output count to max_topics
$count = ($count == 0) ? $CFG['max_topics'] : $count;
// maximum text char limit
if ($chars <0 || $chars > 500)
$chars = 500; //Maximum
// Generate url
$board_url = generate_board_url();
$index_url = $board_url . '/index.' . $phpEx;
$viewtopic_url = $board_url . '/viewtopic.' . $phpEx;
// ==========================================================================================================================
function codebox($preg)
{
return $preg[2];
}
// ==========================================================================================================================
function parse_message($row, $bbcode_options, $bbcode_uid, $bbcode_bitfield)
{
global $board_url, $type;
$row = generate_text_for_display($row, $bbcode_uid, $bbcode_bitfield, $bbcode_options);
$row = preg_replace_callback("/\<dt\>(.*?)\<\/dt\>\<dd\>\<code\>(.*?)\<\/code\>\<\/dd\>/si", "codebox", $row);
if ($type == 'atom')
{
$row = str_replace(" ", " ", $row);
}
else
{
$row = str_replace("\n", "\n<br />\n", $row); // Do NOT user nl2br
$row = htmlspecialchars($row);
}
return $row;
}
// ==========================================================================================================================
// Create a date according to correct RFC standard
function format_date($timestamp)
{
global $type;
if ($type == 'atom')
return date('Y-m-d\TH:i:s\Z', $timestamp); // RFC 3339 for ATOM
else
return date('D, d M Y H:i:s O', $timestamp); // RFC 822 for RSS2
}
// ==========================================================================================================================
$sql_where = '';
// only topic first post
if ($topics_only == 1)
{
$sql_where = 'AND p.post_id = t.topic_first_post_id';
$sql_from = 'FROM ' . POSTS_TABLE . ' as p, ' . FORUMS_TABLE . ' as f, ' . USERS_TABLE . ' as u, ' . TOPICS_TABLE . ' as t';
}
else
{
$sql_from = 'FROM ' . POSTS_TABLE . ' as p, ' . FORUMS_TABLE . ' as f, ' . USERS_TABLE . ' as u';
}
// Exclude forums
if ($CFG['exclude_forums'])
{
$exclude_forums = explode(',', $CFG['exclude_forums']);
foreach ($exclude_forums as $i => $id)
{
if ($id > 0)
{
$sql_where .= ' AND p.forum_id != ' . trim($id);
}
}
}
if ($fid != '')
{
$select_forums = explode(',', $fid);
$sql_where .= ( sizeof($select_forums)>0 ) ? ' AND f.forum_id IN (' . $fid . ')' : '';
}
// SQL posts table
$sql = 'SELECT p.post_id, p.poster_id, p.post_subject, p.post_text, p.bbcode_uid, p.bbcode_bitfield, p.topic_id, p.forum_id, p.post_time, f.forum_name, f.forum_desc_options, u.username
' . $sql_from . '
WHERE (u.user_id = p.poster_id)
AND p.post_approved = 1
AND (f.forum_id = p.forum_id)
' . $sql_where . '
ORDER BY post_time DESC';
$result = $db->sql_query_limit($sql, $count);
while( ($row = $db->sql_fetchrow($result)) )
{
if (!$auth->acl_get('f_list', $row['forum_id']))
{
// if the user does not have permissions to list this forum, skip everything until next branch
continue;
}
if (empty($row['post_subject']))
{
$subj_sql = 'SELECT p.post_subject
FROM ' . POSTS_TABLE . ' as p, ' . TOPICS_TABLE . ' as t
WHERE (p.topic_id = '.$row['topic_id'] .')
AND p.post_id = t.topic_first_post_id';
$subj_result = $db->sql_query($subj_sql);
$subj_row = $db->sql_fetchrow($subj_result);
$row['post_subject'] = $subj_row['post_subject'];
}
$template->assign_block_vars('item', array(
'AUTHOR' => $row['username'],
'TIME' => format_date($row['post_time']),
'LINK' => "$board_url/viewtopic.$phpEx" ."?". 'f=' . $row['forum_id'] . '&t=' . $row['topic_id']."&p=".$row['post_id']."#p".$row['post_id'],
'IDENTIFIER' => "$board_url/viewtopic.$phpEx" ."?". 'f=' . $row['forum_id'] . '&t=' . $row['topic_id']."&p=".$row['post_id']."#p".$row['post_id'],
'TITLE' => $row['post_subject'],
'TEXT' => parse_message($row['post_text'], $row['forum_desc_options'], $row['bbcode_uid'], $row['bbcode_bitfield']),
)
);
}
$template->assign_var('FEED_LINK', generate_board_url(TRUE) . $_SERVER['SCRIPT_NAME'] . "?" . htmlspecialchars($_SERVER['QUERY_STRING']));
if ($type == 'atom')
{
$content_type = 'application/atom+xml';
$tpl = 'atom';
}
else
{
$content_type = 'application/rss+xml';
$tpl = 'rss2';
}
$template->set_filenames(array(
'body' => 'syndication_' . $tpl . '.xml')
);
// get time, use current time
$last_build_date = mktime();
$template->assign_vars(array(
'HEADER' => '<?xml version="1.0" encoding="UTF-8"?>' . "\n", // workaround for remove_php_tags() removing this line from the template
'TITLE' => strip_tags($config['sitename']),
'DESCRIPTION' => strip_tags($config['site_desc']),
'LINK' => $board_url,
'LAST_BUILD' => format_date($last_build_date)
)
);
// gzip compression
if ($config['gzip_compress'])
{
if (@extension_loaded('zlib') && !headers_sent())
{
ob_start('ob_gzhandler');
}
}
// Start output
header ('Content-Type: ' . $content_type . '; charset=UTF-8');
//header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
//header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
//header("Cache-Control: no-store, no-cache, must-revalidate"); // HTTP/1.1
//header("Cache-Control: post-check=0, pre-check=0", false); // HTTP/1.1
//header("Pragma: no-cache"); // HTTP/1.0
$template->display('body');
exit;
?>