<?
require_once'home.php';

$q1 = @mysql_query( @"select  *  from  `forum_topic` where `id`='".$id."' ;" );
$topic = @mysql_fetch_array(@$q1);
if (mysql_affected_rows() == 0){
echo $fs1;
echo '<b>Такой темы не существует!</b>';
echo $fs2;
foot();
exit;
}
$f = $topic ['section'];
$sf = $topic ['subfor'];

$que = @mysql_query( "select * from  `forum_subfor` where id='$sf';" );
$dtm = @mysql_fetch_array( @$que );
$s_name = $dtm['name'];

$que = @mysql_query( "select * from  `forum_sections` where id='$f';" );
$dtm = @mysql_fetch_array( @$que );
$f_name = $dtm['name'];

echo '<dl><dt></dt></dl><a href="'.F.'">Форумы</a>|<a href="'.F.'subfs/'.$f.'">'.$f_name.'</a>';
echo '|<a href="'.F.'temes/'.$sf.'\">'.$s_name.'</a>|<a href="'.F.'tema/'.$id.'/'.$page.'">'.$topic ['name'].'</a><br /><dl><dt></dt></dl>';

if (($topic['login']!=$row['id'])&&($row['level']<5)){
echo '<b>У вас нет прав доступа сюда!</b><br /> ';
echo '<a href="'.htmlspecialchars(getenv("HTTP_REFERER")).'">Вернуться</a>';
foot();
exit;
}

$topic_vote = mysql_result(mysql_query("SELECT COUNT(*) FROM `forum_vote` WHERE `type`='1' AND `topic`='$id'"), 0);
if ($topic_vote != 1) {
echo '<b>В этой теме нет опроса!</b><br /> ';
echo '<a href="'.htmlspecialchars(getenv("HTTP_REFERER")).'">Вернуться</a>';
foot();
exit;
}
$topic_vote = mysql_fetch_array(mysql_query("SELECT `name`, `time`, `count` FROM `forum_vote` WHERE `type` = '1' AND `topic` = '$id' LIMIT 1"));
echo 'Пользователи, принявшие участие в опросе &laquo;<b>' . htmlentities($topic_vote['name'], ENT_QUOTES, 'UTF-8') . '</b>&raquo;:<br />';
$total = mysql_result(mysql_query("SELECT COUNT(*) FROM `forum_vote_us` WHERE `topic`='$id'"), 0);

$max = $row['max'];
$k_page=k_page($total,$max);
$page=page($k_page);
$start=$max*$page-$max;


$whos = mysql_query("SELECT * FROM `forum_vote_us` WHERE `topic` = '$id' ORDER BY `time` DESC LIMIT $start,$max");

if(mysql_num_rows($whos)>1) $zp = ', '; else $zp = '';
while($who = mysql_fetch_array($whos)){
echo '<a href="'.H2.$who['user'].'">'.nik($who['user']).'</a>'.$zp;
}

if ($k_page>1){
echo '<br/><dl><dt></dt></dl>';
str("?",$k_page,$page); // Вывод страниц
echo '<br/><dl><dt></dt></dl>';
}

echo '<br /><a href="'.htmlspecialchars(getenv("HTTP_REFERER")).'">Вернуться в тему</a>';
?>