<?PHP

define( 'DATALIFEENGINE', true );
define( 'ROOT_DIR', '../../../..' );
define( 'SYSTEM_DIR', '../../..' );
@error_reporting( E_ALL ^ E_NOTICE );
@ini_set( 'display_errors', true );
@ini_set( 'html_errors', false );
@ini_set( 'error_reporting', E_ALL ^ E_NOTICE );

if (! defined ( 'DATALIFEENGINE' ))
	die ( "Hacking attempt!" );

$forum_id = intval ( $_REQUEST ['fid']);

if ($forum_id != "" AND $forum_id != 0) {

	include SYSTEM_DIR . '/data/config.php';
	require_once SYSTEM_DIR . '/classes/mysql.php';
	include_once SYSTEM_DIR . '/data/dbconfig.php';
	include_once SYSTEM_DIR . '/modules/functions.php';
	//require_once ENGINE_DIR . '/classes/templates.class.php';
	include_once ROOT_DIR . '/language/' . $config['langs'] . '/website.lng';

	require_once SYSTEM_DIR . '/modules/sitelogin.php';
	if( ! $is_logged )
	{
		$member_id['user_group'] = 5;
	}

	$opisanie = "Форум Files-Sib.NET"; // короткое описание сайта
	$adres_1 = "Files-Sib.NET"; // имя домена
	$adres_2 = "http://files-sib.net/"; // адрес вашего сайта
	$nazvanir_f = "Форум Files-Sib.NET"; // название вашего форума
	$url_logo = "http://files-sib.net/templates/default/images/logo.png"; // ссылка на лого вашего сайта
	$f_info = $db->super_query("SELECT * FROM " . PREFIX . "_forum_forums where id = '$forum_id'");
	if ($f_info['id'] == $forum_id AND $f_info['id'] != "")  // проверка на ID найденного форума
	{
		check_xss();
		$title = htmlspecialchars ( strip_tags ( stripslashes ( $f_info['name'] ) ) );
		$site = $config['http_home_url'];//3
		$rss_content = <<<XML
<?xml version="1.0" encoding="{$config['charset']}"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
<channel>
<title>{$nazvanir_f} » {$title}</title>
<link>{$site}</link>
<language>ru</language>
<description>{$config['description']}</description>
<copyright>{$opisanie}</copyright>
<generator>{$adres_1}</generator>
    <image>
        <title>{$opisanie}</title>
        <url>{$url_logo}</url>
        <link>{$adres_2}</link>
     </image>

XML;

		$access_forum = "(ff.access_read LIKE '%:".$member_id['user_group']."' OR ff.access_read LIKE '%:".$member_id['user_group'].":%' OR ff.access_read LIKE '".$member_id['user_group'].":%' OR ff.access_read LIKE '".$member_id['user_group']."')";
		$sql_result = $db->query("SELECT * FROM `".PREFIX."_forum_posts` AS `forum_posts`, `".PREFIX."_forum_forums` AS `ff`, `".PREFIX."_forum_topics` WHERE tid = forum_posts.topic_id AND ff.id = '$f_info[id]' AND forum_posts.hidden = '0' AND (".$access_forum." AND ff.id = ".PREFIX."_forum_topics.forum_id) AND ".PREFIX."_forum_topics.hidden = '0' ORDER BY forum_posts.post_date DESC LIMIT 0,30");
		while($row = $db->get_row($sql_result))
		{
			$t_title = htmlspecialchars ( strip_tags ( stripslashes ( $row['title'] ) ) );

			$rss_content .= <<<XML
<item>
<title>{$t_title}</title>

XML;
			$url = $config['http_home_url']."forum/topic_".$row['tid'];
			$rss_content .= "<link>{$url}</link>\n";
			$row['post_text'] = preg_replace ( "'\\[hide\\](.*?)\\[/hide\\]'ies", "", $row['post_text'] );
			$author = "<a {$go_page} href=\"".$config['http_home_url']."user/".urlencode($row['post_author'])."/\">".$row['post_author']."</a>";

			$rss_content2 = <<<HTML
{$row['post_text']}<br>
<b>Опубликовал:</b> {$author}<hr>
HTML;

			$rss_content3 = stripslashes(str_replace("<br />", "<br>", $rss_content2));

			$rss_content .=  <<<XML
<description>
<![CDATA[ {$rss_content3} ]]>
</description>
<category>undefined</category>
<dc:creator>{$row['post_author']}</dc:creator>
<pubDate>{$row['post_date']}</pubDate>
</item>

XML;

		}

		$rss_content .= <<<XML

</channel>
</rss>
XML;
	header ( 'Content-type: application/xml' );
	echo $rss_content;

	}
	else
		header( "Location: {$config['http_home_url']}" );
}
else
	header( "Location: {$config['http_home_url']}" );

exit ();
?>