Файл: CMS/comm/comm_forum_rss.php
Строк: 120
<?php
if (!defined('CMS')) { die('Access Denied!'); }
$data = '';
$data = $db->selectRow("SELECT ?_comm_comm.*, ?_comm_category.*
FROM ?_comm_comm LEFT JOIN ?_comm_category
ON ?_comm_comm.`comm_cats_id` = ?_comm_category.`cats_id`
WHERE `comm_url` = ? LIMIT 1;", $soo);
if (empty($data) || !is_array($data)) {
$inSes->addMessage('Ошибка! Сообщество не найдено или ссылка неверна!');
gen_red('index', '', RND);
}
if (empty($data['comm_forum'])) {
$inSes->addMessage('Ошибка! Форум не найден или ссылка неверна!');
gen_red('index', '', RND);
}
$arr_admins = @explode(',', $data['comm_admins']);
$users = array();
if ($is_logged) {
$users = $db->selectRow("SELECT * FROM ?_comm_users WHERE `cu_comm` = ? AND `cu_user` = ? LIMIT 1;", $data['comm_id'], $log);
if ($data['comm_user'] == $log) {
$is_admin_soo = true;
}
if (in_array($log, $arr_admins) && $users['cu_admin'] == 1) {
$is_moder_soo = true;
}
}
if ($data['comm_status'] == 1 && empty($users)) {
$inSes->addMessage('Форум только для участников сообщества!');
gen_red('index', '', RND);
}
error_reporting(0); // на всякий
$topic = $db->selectRow("SELECT * FROM ?_comm_topics
WHERE `topics_id` = ? AND `topics_comm` = ? LIMIT 1;", $id, $data['comm_id']);
if (empty($topic) || !is_array($topic)) {
$inSes->addMessage('Ошибка! Выбранная вами тема не существует, возможно она была удалена!');
gen_red('forum', '', RND);
}
$forum_href = gen_comm($data['comm_url'], 'forum', '', RND);
if ( $config['rss_format'] != 2 ) {
$rss_content = <<<XML
<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
<channel>
<title>RSS лента сообщений форума {$data['comm_name']}</title>
<link>{$forum_href}</link>
<language>ru</language>
<description>RSS лента сообщений форума {$data['comm_name']}</description>
<generator>{$config['site_name']}</generator>
XML;
} else {
$rss_content = <<<XML
<?xml version="1.0" encoding="{$config['charset']}"?>
<rss version="2.0" xmlns="http://backend.userland.com/rss2" xmlns:yandex="http://news.yandex.ru">
<channel>
<title>RSS лента сообщений форума {$data['comm_name']}</title>
<link>{$forum_href}</link>
<language>ru</language>
<description>RSS лента сообщений форума {$data['xomm_name']}</description>
<image>
<url></url>
<title>RSS лента сообщений форума {$data['comm_name']}</title>
<link>{$forum_href}</link>
</image>
<generator>{$config['site_name']}</generator>
XML;
}
$rows = $db->select( "SELECT * FROM ?_comm_posts WHERE `posts_topics_id` = ? AND `posts_comm` = ?
ORDER BY `posts_time` DESC LIMIT 0, ?d", $id, $data['comm_id'], $config['rss_num'] );
if (!empty($rows)) {
$rss_link = gen_comm($data['comm_url'], 'topic', $topic['topics_id'], RND);
foreach( $rows as $row ) {
$row['posts_text'] = nl2br(bb_code($row['posts_text']));
$row['posts_text'] = str_replace('../images/smiles', $config['site_url'] . '/images/smiles', $row['posts_text']);
$row['posts_text'] = htmlspecialchars($row['posts_text']);
$rss_date = date('r', $row['posts_time']);
if ( $config['rss_format'] == 1 ) {
$rss_content .= <<<XML
<item>
<title>{$topic['topics_title']}</title>
<guid isPermaLink="true">{$rss_link}</guid>
<link>{$rss_link}</link>
<description>{$row['posts_text']}</description>
<category>Комментарии</category>
<dc:creator>{$row['posts_user']}</dc:creator>
<pubDate>{$rss_date}</pubDate>
</item>
XML;
} else if ( $config['rss_format'] == 2 ) {
$rss_content .= <<<XML
<item>
<title>{$topic['topics_title']}</title>
<link>{$rss_link}</link>
<description>{$row['posts_text']}</description>
<category>Комментарии</category>
<author>{$row['posts_user']}</author>
<pubDate>{$rss_date}</pubDate>
<yandex:full-text>{$row['posts_text']}</yandex:full-text>
</item>
XML;
} else {
$rss_content .= <<<XML
<item>
<title>{$topic['topics_title']}</title>
<guid isPermaLink="true">{$rss_link}</guid>
<link>{$rss_link}</link>
<description>{$row['posts_text']}</description>
<category>Комментарии</category>
<dc:creator>{$row['posts_user']}</dc:creator>
<pubDate>{$rss_date}</pubDate>
</item>
XML;
}
}
}
$rss_content .= <<<XML
</channel></rss>
XML;
header( 'Content-type: application/xml' );
echo $rss_content;
exit;
?>