<?php
#-----------------------------------------------------#
#          ********* ROTORCMS *********               #
#              Made by  :  VANTUZ                     #
#               E-mail  :  visavi.net@mail.ru         #
#                 Site  :  http://pizdec.ru           #
#             WAP-Site  :  http://visavi.net          #
#                  ICQ  :  36-44-66                   #
#  Вы не имеете право вносить изменения в код скрипта #
#        для его дальнейшего распространения          #
#-----------------------------------------------------#	
require_once ('../includes/start.php');
require_once ('../includes/functions.php');
require_once ('../includes/header.php');
include_once ('../themes/' . $config['themes'] . '/index.php');

if (isset($_GET['id'])) {
    $id = abs(intval($_GET['id']));
} else {
    $id = 0;
} 

show_title('site.png', 'Комментарии');

$queryblog = DB :: $dbh -> query("SELECT * FROM `blogs` WHERE `blogs_id`=? LIMIT 1;", array($id));
$blog = $queryblog -> fetch();

if (!empty($blog)) {
    ob_implicit_flush();
    ob_end_clean();
    ob_clean();
    header("Content-type:application/rss+xml; charset=utf-8");
    echo '<?xml version="1.0" encoding="utf-8"?>';
    echo '<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel>';
    echo '<title>Комментарии - ' . $blog['blogs_title'] . '</title>';
    echo '<link>' . $config['home'] . '</link>';
    echo '<description>Комментарии RSS - ' . $config['title'] . '</description>';
    echo '<image><url>' . $config['logotip'] . '</url>';
    echo '<title>Комментарии - ' . $blog['blogs_title'] . '</title>';
    echo '<link>' . $config['home'] . '</link></image>';
    echo '<language>ru</language>';
    echo '<copyright>' . $config['copy'] . '</copyright>';
    echo '<managingEditor>' . $config['emails'] . ' (' . $config['nickname'] . ')</managingEditor>';
    echo '<webMaster>' . $config['emails'] . ' (' . $config['nickname'] . ')</webMaster>';
    echo '<lastBuildDate>' . date("r", SITETIME) . '</lastBuildDate>';

    $querycomm = DB :: $dbh -> query("SELECT * FROM `commblog` WHERE `commblog_blog`=? ORDER BY `commblog_time` DESC LIMIT 15;", array($id));

    while ($data = $querycomm -> fetch()) {
        $data['commblog_text'] = bb_code($data['commblog_text']);
        $data['commblog_text'] = str_replace('../images/smiles', $config['home'] . '/images/smiles', $data['commblog_text']);
        $data['commblog_text'] = htmlspecialchars($data['commblog_text']);

        echo '<item><title>' . $blog['blogs_title'] . '</title><link>' . $config['home'] . '/blog/blog.php?act=comments&amp;id=' . $blog['blogs_id'] . '</link>';
        echo '<description>' . $data['commblog_text'] . ' </description><author>' . nickname($data['commblog_author']) . '</author>';
        echo '<pubDate>' . date("r", $data['commblog_time']) . '</pubDate><category>Комментарии</category><guid>' . $config['home'] . '/blog/blog.php?act=comments&amp;id=' . $blog['blogs_id'] . '&amp;pid=' . $data['commblog_id'] . '</guid></item>';
    } 

    echo '</channel></rss>';
    ob_end_flush();
    exit;
} else {
    show_error('Ошибка! Выбранная вами статья не существует, возможно она была удалена!');
} 

echo '<img src="../images/img/reload.gif" alt="image" /> <a href="index.php?' . SID . '">К блогам</a>';

include_once ('../themes/' . $config['themes'] . '/foot.php');

?>