<?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['tid'])) {
    $tid = abs(intval($_GET['tid']));
} else {
    $tid = 0;
} 

show_title('menu.png', 'Форум ' . $config['title']);

$querytopic = DB :: $dbh -> query("SELECT * FROM `topics` WHERE `topics_id`=? LIMIT 1;", array($tid));
$topic = $querytopic -> fetch();

if (!empty($topic)) {
    // -----------------------------------------------------------//
    ob_clean();
    ob_end_clean();

    header('Content-type:text/html; charset=utf-8');
    echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">';
    echo '<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="ru" lang="ru"><head>';
    echo '<title>' . $topic['topics_title'] . '</title>';
    echo '<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />';
    echo '</head><body>';

    $querypost = DB :: $dbh -> query("SELECT * FROM `posts` WHERE `posts_topics_id`=? ORDER BY `posts_time` ASC;", array($tid));

    echo '<big><b>' . $topic['topics_title'] . '</b></big><br /><br />';

    $i = 0;
    while ($data = $querypost -> fetch()) {
        echo ++$i . '. <b>' . nickname($data['posts_user']) . '</b> (' . date_fixed($data['posts_time']) . ')<br />';

        echo bb_code($data['posts_text']) . '<br /><br />';
    } 

    echo 'URL: <a href="' . $config['home'] . '/forum/topic.php?tid=' . $tid . '&amp;' . SID . '">' . $config['home'] . '/forum/topic.php?tid=' . $tid . '</a>';
    echo '</body></html>';
    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');

?>