<?
/*
if(mysql_result(mysql_querll("SELECT COUNT(*) FROM `kolhoz_collective_club` WHERE `id_collective` = '$ct[id]' AND `type` = 'razdel'"),0)==0)
{
mysql_querll("INSERT INTO `kolhoz_collective_club` SET `name` = 'Наш форум', `type` = 'razdel', `mother` = '0', `time` = '$time', `pos` = '1', `id_collective` = '$ct[id]', `guest` = '0'");
mysql_querll("INSERT INTO `kolhoz_collective_club` SET `name` = 'Гостевой', `type` = 'razdel', `mother` = '0', `time` = '$time', `pos` = '2', `id_collective` = '$ct[id]', `guest` = '1'");
}
*/
if(intval($_GET['club'])!=NULL && mysql_result(mysql_querll("SELECT COUNT(*) FROM `kolhoz_collective_club` WHERE `id` = '".intval($_GET['club'])."' AND `id_collective` = '$ct[id]'"),0)!=0)$forum=mysql_fetch_array(mysql_querll("SELECT * FROM `kolhoz_collective_club` WHERE `id` = '".intval($_GET['club'])."' AND `id_collective` = '$ct[id]'"));
if(isset($forum) && $forum['type']=='tema')
{
$fk=mysql_fetch_array(mysql_querll("SELECT * FROM `kolhoz_collective_club` WHERE `type` = 'komm' AND `mother` = '$forum[id]' ORDER BY `time` ASC LIMIT 1"));
$mother=mysql_fetch_array(mysql_querll("SELECT * FROM `kolhoz_collective_club` WHERE `id` = '$forum[mother]'"));
if($mc['id']!=$ct['id'] && $mother['guest']==0)
{
header("Location:?collective=$ct[id]&club");
exit;
}
if(isset($_GET['edit']) && $mc['id']==$ct['id'] && $mcu['status']<=3)
{
echo '<div class="event"><h1>Редактирование топика</h1></div>';
if($_GET['edit']=='ok')
{
$name=$_POST['name'];
$msg=$_POST['msg'];
$id_user=$_POST['id_user'];
if($name==NULL)
{
echo err_game("Слишком короткое название");
$err=1;
}
if($msg==NULL)
{
echo err_game("Слишком короткое сообщение");
$err=1;
}
if(!isset($err))
{
mysql_querll("UPDATE `kolhoz_collective_club` SET `name` = '".my_esc($name)."', `msg` = '".my_esc($msg)."', `id_user` = '".my_esc($id_user)."', `visit` = ',".$ku['id']."' WHERE `id` = '$forum[id]'");
mysql_querll("UPDATE `kolhoz_collective_club` SET `msg` = '".my_esc($msg)."' WHERE `id` = '$fk[id]'");
mysql_querll("UPDATE `kolhoz_collective_club` SET `id_user` = '".my_esc($id_user)."' WHERE `id` = '$fk[id]'");
header("Location:?collective=$ct[id]&club=$forum[id]");
exit;
}
}
echo '<div class="content"><div class="block">';
//echo "<form action='?collective=$ct[id]&club=$forum[id]&edit=ok' method='post'><ul><li><label><div>Заголовок:</div><div><input type='text' class='wide' value='".hsc($forum['name'])."' name='name'></div></label></li><li><label><div>Сообщение:</div><div><textarea class='wide' rows='5' name='msg'>".hsc($forum['msg'])."</textarea></div></label></li><li><input type='submit' value='Сохранить'></li></ul></form></div>";
echo '<div class="content"><div class="block">';
echo "<form action='?collective=$ct[id]&club=$forum[id]&edit=ok' method='post'><ul><li><label><div>
Заголовок:</div><div><input type='text' class='wide' value='".hsc($forum['name'])."' name='name'></div></label></li><li><label>
<div>Сообщение:</div><div><textarea class='wide' rows='5' name='msg'>".hsc($forum['msg'])."</textarea></div></label></li>
ID автора топа: <div><input type='text' class='wide' value='".hsc($fk['id_user'])."' name='id_user'></div></label></li>
<li><input type='submit' value='Сохранить'></li></ul></form></div>";


include_once 'inc/foot.php';
}
if(isset($_GET['lock']) && $mc['id']==$ct['id'] && $mcu['status']<=3)
{
mysql_querll("UPDATE `kolhoz_collective_club` SET `locked` = '".($forum['locked']==1?"0":"1")."' WHERE `id` = '$forum[id]'");
header("Location:?collective=$ct[id]&club=$forum[id]");
exit;
}
if(isset($_GET['pin']) && $mc['id']==$ct['id'] && $mcu['status']<=3)
{
mysql_querll("UPDATE `kolhoz_collective_club` SET `pined` = '".($forum['pined']==1?"0":"1")."' WHERE `id` = '$forum[id]'");
header("Location:?collective=$ct[id]&club=$forum[id]");
exit;
}
if(isset($_GET['del']) && $mc['id']==$ct['id'] && $mcu['status']<=3)
{
if($_GET['del']=='ok')
{
mysql_querll("delete from `kolhoz_collective_club` where `mother` = '$forum[id]' and `type` = 'komm'");
mysql_querll("delete from `kolhoz_collective_club` where `id` = '$forum[id]' and `type` = 'tema'");
header("Location:?collective=$ct[id]&club=$mother[id]");
exit;
}
echo '<div class="event"><h1>Подтверждение</h1></div><div class="content"><div class="block"><ul class="block"><li><span class="title">Вы уверены?</span></li><li class="pt"><img alt="" width="16" height="16" src="img/icons/tick.png"> <a href="?collective='.$ct['id'].'&club='.$forum['id'].'&del=ok"><span>
Да, подтверждаю</span></a></li><li><img alt="" width="16" height="16" src="img/icons/cross.png"> <a href="?collective='.$ct['id'].'&club='.$forum['id'].'"><span>
Нет, отказываюсь</span></a></li></ul></div>';
include_once 'inc/foot.php';
}
if(isset($_GET['del_komm']) && intval($_GET['del_komm'])!=NULL && mysql_result(mysql_querll("SELECT COUNT(*) FROM `kolhoz_collective_club` WHERE `id` = '".intval($_GET['del_komm'])."' AND `type` = 'komm' AND `id` != '$fk[id]'"),0)!=0 && $mc['id']==$ct['id'] && $mcu['status']<=3)
{
mysql_querll("delete from `kolhoz_collective_club` where `mother` = '$forum[id]' and `type` = 'komm' and `id` = '".intval($_GET['del_komm'])."'");
header("Location:?collective=$ct[id]&club=$forum[id]");
exit;
}




if(isset($_SESSION['avtor'])){echo "<div class='feedback'><font color='green'>Теперь автор топа:</font> <b>".nc($fk['id_user'])."</b></div>"; unset($_SESSION['avtor']);}

if ($mc['id']==$ct['id'] && $mcu['status']<=3){
if(isset($_GET['author'])){

echo '<div class="event"><h1>Подтверждение</h1></div><div class="content"><div class="block"><ul class="block"><li><span class="title">Вы уверены?</span></li><li class="pt"><img alt="" width="16" height="16" src="img/icons/tick.png"> <a href="?collective='.$ct['id'].'&club='.$forum['id'].'&author&ok"><span>
Да, подтверждаю</span></a></li><li><img alt="" width="16" height="16" src="img/icons/cross.png"> <a href="?collective='.$ct['id'].'&club='.$forum['id'].'"><span>
Нет, отказываюсь</span></a></li></ul></div>';

if(isset($_GET['ok'])){
mysql_query("UPDATE `kolhoz_collective_club` SET `id_user` = '".hsc($ku['id'])."' WHERE `id` = '$fk[id]'");
$_SESSION['avtor']=1;
header("Location:?collective=$ct[id]&club=$forum[id]");
}
include_once 'inc/foot.php';
}
}


//=====топик
echo "<div class='event'><h1><a href='?collective=$ct[id]'>".hsc($ct['name'])."</a> / <a href='?collective=$ct[id]&club'>Дом культуры</a> / <a href='?collective=$ct[id]&club=$mother[id]'>".hsc($mother['name'])."</a> / ".hsc($forum['name'])."</h1></div>";

echo "<div class='block'>Сейчас в топике <b>".hsc($forum['name']).":</b><br/>";


$k_post=mysql_result(mysql_query("SELECT COUNT(*) FROM `kolhoz_user` WHERE `date_last` > '".(time()-100)."' AND `url` like '?collective=$ct[id]%'"), 0);
$k_page=k_page($k_post,$set['p_str']);
$page=page($k_page);
$start=$set['p_str']*$page-$set['p_str'];
$q = mysql_query("SELECT * FROM `kolhoz_user` WHERE `date_last` > '".(time()-100)."' AND `url` like '?collective=$ct[id]%' ORDER BY `date_last` DESC LIMIT $start, $set[p_str]");
if ($k_post==0){echo "Нет никого";}
while ($post = mysql_fetch_array($q))
{
echo "<a class='' href='?user=$post[id]'><span>".nc($post['id'])."</span></a></span>, ";
}
echo "</div>";





{

$otv=mysql_fetch_array(mysql_querll("SELECT * FROM `kolhoz_user` WHERE `id` = '".intval($_GET['otv'])."'"));
$otvu=$otv;
}
if(isset($_GET['add']) && $_GET['add']=='ok' && $forum['locked']==0 && !isset($molchi))
{
$msg=$_POST['msg'];
if($msg==NULL)
{
echo err_game("Слишком короткое сообщение");
$err=1;
}
if($ku['level']<=15)
{
$err=1;
err_game("Писать в Доме культуры можно после того как достигните 15-го уровня!");
}
if($ku['time']<=3600*1)
{
$err=1;
err_game("Писать в Доме культуры можно после того как проведете в игре <b>1 часа</b>");
}




if(!isset($err))
{
mysql_querll("INSERT INTO `kolhoz_collective_club` SET `msg` = '".my_esc($msg)."', `id_user` = '$ku[id]', `type` = 'komm', `mother` = '$forum[id]', `time` = '$time'".(isset($otv)?", `otvet` = '$otv[id]'":null)."");
mysql_querll("UPDATE `kolhoz_collective_club` SET `time_obnov` = '$time', `visit` = ',".$ku['id']."' WHERE `id` = '$forum[id]'");
$for_raz=mysql_fetch_array(mysql_querll("SELECT * FROM kolhoz_collective_club WHERE id='".$forum['id']."'"));
mysql_querll("UPDATE `kolhoz_collective_club` SET `visit` = ',".$ku['id']."' WHERE `id` = '".$for_raz['mother']."'");
header("Location:?collective=$ct[id]&club=".$forum['id']."&page=end");
exit;
}
}
//======================================//
$visit=mysql_fetch_array(mysql_querll("SELECT * FROM kolhoz_collective_club WHERE id='".$forum['id']."'"));
$visit_array=explode(',',$visit['visit']);
$visit_num=count($visit_array)+$sum_num;
if(!in_array($ku['id'],$visit_array)){
$visit_array[$visit_num]=$ku['id'];
mysql_querll("UPDATE kolhoz_collective_club SET visit='".implode(',',$visit_array)."' WHERE id='".$forum['id']."'");
}
//======================================//
if($_GET['dav']==1){echo '1';}
echo "<div class='content'><div class='block'>";
$k_post = mysql_result(mysql_querll("SELECT COUNT(*) FROM `kolhoz_collective_club` WHERE `type` = 'komm' AND `mother` = '$forum[id]'"),0);
if ($k_post==0)
{
echo "Список пуст...";
}

$k_page=k_page($k_post,$set['p_str']);
$page=page($k_page);
$start=$set['p_str']*$page-$set['p_str'];

$q=mysql_querll("SELECT * FROM `kolhoz_collective_club` WHERE `type` = 'komm' AND `mother` = '$forum[id]' ORDER BY `time` ASC LIMIT $start, $set[p_str]");
while($post=mysql_fetch_array($q))
{

$ank=mysql_fetch_array(mysql_query("SELECT * FROM `kolhoz_user` WHERE `id` = '$post[id_user]'"));

echo "<div class='block'>";

echo on_k($ank['id']);
$ank=mysql_fetch_array(mysql_query("SELECT * FROM `kolhoz_user` WHERE `id` = '$post[id_user]'"));

if($post['otvet']!=0 && mysql_result(mysql_query("SELECT COUNT(*) FROM `kolhoz_user` WHERE `id` = '$post[otvet]'"),0)!=0)
{
$ot=mysql_fetch_array(mysql_query("SELECT * FROM `kolhoz_user` WHERE `id` = '$post[otvet]'"));
}


echo "<a class='' href='?user=$ank[id]'>".nc($ank['id'])."</a></span>";
echo " ".med($ank['id'])."";
if (mysql_result(mysql_query("SELECT COUNT(*) FROM `kolhoz_user` WHERE `id` = '$ank[id]' AND `date_last` > '".(time()-600)."' LIMIT 1"),0)==1)
echo " <img src='img/icons/online.gif' alt='' class='*'/>";
//===

$ban = mysql_fetch_array(mysql_querll("SELECT * FROM `kolhoz_ban` WHERE `id_user` = '$ank[id]' AND (`time` > '$time' OR `izg` = '1') ORDER BY `id` DESC LIMIT 1"));
$us_ban = mysql_fetch_array(mysql_querll("SELECT * FROM `kolhoz_user` WHERE `id` = '$ban[id_who]'"));

if($ban['id']){
echo "".($ban['izg']==1?'<br/><font color="tomato">Сообщение заблокировано</font>':"<br/><font color='tomato'>Сообщение заблокировано до:</font> <b>".vremja($ban['time']))."</b><br/>";
if($mcu['status']<=3){
echo "(<font color='#A52A2A'>".(!empty($post['otvet'])?"".($ku['id']==$ot['id']?"<span class='rare'>":null)."$ot[nick]".($ku['id']==$ot['id']?"</span>":null).", ":null)."".output_text($post['msg'], $ank['id'])."</font>)<br/><b><font color='#FFD700'>Видно только должностным лицам</font></b>";

}
}
else
if($ank['id']){

//echo " <span class='minor'><span>".vremja($post['time'])."</span></span></span><p>".(isset($otvet)?"".($ku['id']==$otvet['id']?"<span class='rare'>":null)."$otvetu[nick]".($ku['id']==$otvet['id']?"</span>":null).", ":null)."".output_text($post['msg'], $ank['id'])."</p><span class='small'>".($fk['id']!=$post['id']?"".($club['locked']==0?"".($ank['id']!=$ku['id']?"<a href='?club=$club[id]&otv=$ank[id]'>[ответить]</a>":null)."":null)."":null)."";
echo "<br/><span class='minor small'> ".vremja($post['time'])."</span><br/>".(!empty($post['otvet'])?"".($ku['id']==$ot['id']?"<span class='rare'>":null)."$ot[nick]".($ku['id']==$ot['id']?"</span>":null).", ":null)."".output_text($post['msg'], $ank['id'])."</br>".($ank['id']!=$ku['id']?"<a class='small minor' href='?collective=$ct[id]&club=$forum[id]&otv=$ank[id]'>[ответить]</a>":null)."";

}

//=====
if($mc['id']==$ct['id'] && $mcu['status']<=3 && $post['id']!=$fk['id'])echo " <a class='small minor' href='?collective=$ct[id]&club=$forum[id]&del_komm=$post[id]'>[удалить]</a>";
if($post['id']==$forum['id']+1){echo "<hr color='#114411' size='1'>";}else{echo "";}
echo "</div>";
}

{
if($ku['level']>=15)
{
$for_net=1;
if ($k_page>1){str("?collective=$ct[id]&club=$forum[id]&",$k_page,$page); echo"<br/>";} // Вывод страниц
if($forum['locked']==0)echo "<form action='?collective=$ct[id]&club=$forum[id]&add=ok".(isset($otv)?"&otv=$otv[id]":null)."' method='post'><ul><li><label><div>Сообщение".(isset($otv)?" для $otvu[nick]":null)."</div><div><textarea class='wide' rows='5' name='msg'></textarea></div></label></li><input type='submit' value='Написать'></form>";
else echo "<div class='pt minor'>Тема закрыта.</div>";
}
else
{
$for_net=1;
if ($k_page>1){str("?collective=$ct[id]&club=$forum[id]&",$k_page,$page);} // Вывод страниц
echo "<br><font color='yellow'>Писать в Доме культуры можно только с 15 уровня.</font>";
}
}
if($for_net!=1){
if ($k_page>1)str("?collective=$ct[id]&club=$forum[id]&",$k_page,$page); // Вывод страниц
}
echo "</div>";



if($mc['id']==$ct['id'] && $mcu['status']<=3)
{
echo "<div class='block'>";
echo "<li><img alt='o' width='16' height='16' src='img/icons/forum_pin.png'> <a href='?collective=$ct[id]&club=$forum[id]&pin'><span>".($forum['pined']==0?"При":"От")."крепить</span></a></li>";
echo "<li><img alt='o' width='16' height='16' src='img/icons/forum_close.png'> <a href='?collective=$ct[id]&club=$forum[id]&lock'><span>".($forum['locked']==0?"За":"От")."крыть</span></a></li>";
echo "<li><img alt='o' width='16' height='16' src='img/icons/forum_move.png'> <a href='?collective=$ct[id]&club=$forum[id]&moderate".(!isset($_GET['replace'])?"&replace":null)."'>Перенести</a><br></li>";
if(isset($_GET['replace']))
{
if($_GET['replace']=='ok' && mysql_result(mysql_querll("SELECT COUNT(*) FROM `kolhoz_collective_club` WHERE `id` = '".intval($_POST['forum'])."' AND `type` = 'razdel' AND `id_collective` = '$ct[id]'"),0)!=0)
{
mysql_querll("UPDATE `kolhoz_collective_club` SET `mother` = '".intval($_POST['forum'])."' WHERE `id` = '$forum[id]'");
header("Location:?collective=$ct[id]&club=$forum[id]");
}

echo "<form method='post' action='?collective=$ct[id]&club=$forum[id]&moderate&replace=ok'><div>Перенос топика \"<span>".hsc($forum['name'])."</span>\"</div><label>Новый раздел<br>";
echo "<select name='forum'>";
$q=mysql_querll("SELECT * FROM `kolhoz_collective_club` WHERE `id` != '$mother[id]' AND `type` = 'razdel' AND `id_collective` = '$ct[id]'");
while($post=mysql_fetch_array($q))
{
echo "<option value='$post[id]'>".hsc($post['name'])."</option>";
}
echo "</label><br><input type='submit' value='Перенести'></form></li>";
}

echo "<li><img alt='o' width='16' height='16' src='img/icons/delete.png'> <a href='?collective=$ct[id]&club=$forum[id]&del'>Удалить</a></li>";
echo "<li><img alt='o' width='16' height='16' src='img/icons/forum_edit.png'> <a href='?collective=$ct[id]&club=$forum[id]&edit'>Изменить</a></li>";
echo "<li><img alt='o' width='16' height='16' src='img/icons/forum_close.png'> <a href='?collective=$ct[id]&club=$forum[id]&author'><span>Забрать авторство топа</span></a></li>";

echo "</div>";
}
include_once 'inc/foot.php';
}


if(isset($forum) && $forum['type']=='razdel')
{
if($mc['id']!=$ct['id'] && $forum['guest']==0)
{
header("Location:?collective=$ct[id]&club");
exit;
}



if($forum['guest']==1){
if(isset($_GET['add']))
{
echo '<div class="event"><h1>Создание топика</h1></div>';
if($_GET['add']=='ok')
{
$name=$_POST['name'];
$msg=$_POST['msg'];
if($name==NULL)
{
echo err_game("Слишком короткое название");
$err=1;
}
if($msg==NULL)
{
echo err_game("Слишком короткое сообщение");
$err=1;
}
if(!isset($err))
{
mysql_querll("INSERT INTO `kolhoz_collective_club` SET `name` = '".my_esc($name)."', `msg` = '".my_esc($msg)."', `id_user` = '$ku[id]', `type` = 'tema', `mother` = '$forum[id]', `time` = '$time', `time_obnov` = '$time', `id_collective` = '$ct[id]'");
$id=mysql_insert_id();
mysql_querll("INSERT INTO `kolhoz_collective_club` SET `msg` = '".my_esc($msg)."', `id_user` = '$ku[id]', `type` = 'komm', `mother` = '$id', `time` = '$time', `id_collective` = '$ct[id]'");
header("Location:?collective=$ct[id]&club=$id");
exit;
}
}
echo '<div class="content"><div class="block">';
echo "<form action='?collective=$ct[id]&club=$forum[id]&add=ok' method='post'><ul><li><label><div>Заголовок:</div><div><input type='text' class='wide' value='' name='name'></div></label></li><li><label><div>Сообщение:</div><div><textarea class='wide' rows='5' name='msg'></textarea></div></label></li><li><input type='submit' value='Написать'></li></ul></form></div>";
include_once 'inc/foot.php';
}
}



if($forum['guest']==0){
if(isset($_GET['add']))
{
echo '<div class="event"><h1>Создание топика</h1></div>';
if($_GET['add']=='ok')
{
$name=$_POST['name'];
$msg=$_POST['msg'];
if($name==NULL)
{
echo err_game("Слишком короткое название");
$err=1;
}
if($msg==NULL)
{
echo err_game("Слишком короткое сообщение");
$err=1;
}
if(!isset($err))
{
mysql_querll("INSERT INTO `kolhoz_collective_club` SET `name` = '".my_esc($name)."', `msg` = '".my_esc($msg)."', `id_user` = '$ku[id]', `type` = 'tema', `mother` = '$forum[id]', `time` = '$time', `time_obnov` = '$time', `id_collective` = '$ct[id]'");
$id=mysql_insert_id();
mysql_querll("INSERT INTO `kolhoz_collective_club` SET `msg` = '".my_esc($msg)."', `id_user` = '$ku[id]', `type` = 'komm', `mother` = '$id', `time` = '$time', `id_collective` = '$ct[id]'");
header("Location:?collective=$ct[id]&club=$id");
exit;
}
}
echo '<div class="content"><div class="block">';
echo "<form action='?collective=$ct[id]&club=$forum[id]&add=ok' method='post'><ul><li><label><div>Заголовок:</div><div><input type='text' class='wide' value='' name='name'></div></label></li><li><label><div>Сообщение:</div><div><textarea class='wide' rows='5' name='msg'></textarea></div></label></li><li><input type='submit' value='Написать'></li></ul></form></div>";
include_once 'inc/foot.php';
}
}






if(isset($_GET['edit']) && $mc['id']==$ct['id'] && $mcu['status']<=2)
{
echo '<div class="event"><h1>Редактирование раздела</h1></div>';
if(isset($_POST['name']))
{
$name=$_POST['name'];
if($name==NULL)
{
echo err_game("Слишком короткое название");
$err=1;
}
if(!isset($err))
{
if($_POST['guest']==1)$guest=1;else $guest=0;
mysql_querll("UPDATE `kolhoz_collective_club` SET `name` = '".my_esc($name)."', `guest` = '$guest' WHERE `id` = '$forum[id]'");
header("Location:?collective=$ct[id]&club=$forum[id]");
exit;
}
}
echo '<div class="content"><div class="block">';
echo "<form method='post'><ul><li><label><div>Название:</div><div><input type='text' class='wide' value='".hsc($forum['name'])."' name='name'></div></label></li>";
echo "<input type='checkbox' name='guest' value='1'".($forum['guest']==1?" checked='checked'":null)."> <span>Открыть доступ гостям</span><br/>";
echo "<li><input type='submit' value='Сохранить'></li></ul></form></div>";
include_once 'inc/foot.php';
}







//========удаление раздела


elseif(isset($_GET['del']) && $mc['id']==$ct['id'] && $mcu['status']<=3)
{
if($_GET['del']=='ok')
{
$q=mysql_querll("SELECT * FROM `kolhoz_collective_club` WHERE `mother` = '$forum[id]' AND `type` = 'tema'");
while($post=mysql_fetch_array($q))
{
mysql_querll("delete from `kolhoz_collective_club` where `mother` = '$post[id]' and `type` = 'komm'");
mysql_querll("delete from `kolhoz_collective_club` where `id` = '$post[id]'");
}
$links = mysql_querll("SELECT * FROM `kolhoz_collective_club` WHERE `type` = 'razdel' AND `pos` > '$forum[pos]' ORDER BY `pos` ASC");
while ($p = mysql_fetch_array($links))
{
mysql_querll("UPDATE `kolhoz_collective_club` SET `pos` = '".($p['pos']-1)."' WHERE `id` = '$p[id]' LIMIT 1");
}
mysql_querll("delete from `kolhoz_collective_club` where `id` = '$forum[id]' and `type` = 'razdel'");
header("Location:?collective=$ct[id]&club");
}
else echo '<div class="event"><h1>Подтверждение</h1></div><div class="content"><div class="block"><li><span class="title">Вы уверены?</span></li><li class="pt"><img alt="" width="16" height="16" src="img/icons/tick.png"> <a href="?collective='.$ct['id'].'&club='.$forum['id'].'&del=ok"><span>
Да, подтверждаю</span></a></li><li><img alt="" width="16" height="16" src="img/icons/cross.png"> <a href="?collective='.$ct['id'].'&club='.$forum['id'].'"><span>
Нет, отказываюсь</span></a></li></div></div>';
include_once 'inc/foot.php';
}
//========создание раздела



echo "<div class='event'><h1><a href='?collective=$ct[id]'>".hsc($ct['name'])."</a> / <a href='?collective=$ct[id]&club'>Дом культуры</a> / ".hsc($forum['name'])."</h1></div>";
echo '<div class="content"><div class="block"><ul>';
$k_post = mysql_result(mysql_querll("SELECT COUNT(*) FROM `kolhoz_collective_club` WHERE `type` = 'tema' AND `mother` = '$forum[id]'"),0);
if ($k_post==0)
{
echo "Список пуст...";
}
$k_page=k_page($k_post,$set['p_str']);
$page=page($k_page);
$start=$set['p_str']*$page-$set['p_str'];
$q=mysql_querll("SELECT * FROM `kolhoz_collective_club` WHERE `type` = 'tema' AND `mother` = '$forum[id]' ORDER BY `pined` DESC, `time_obnov` DESC LIMIT $start, $set[p_str]");

//======================================//
$visit=mysql_fetch_array(mysql_querll("SELECT * FROM kolhoz_collective_club WHERE id='".$forum['id']."'"));
$visit_array=explode(',',$visit['visit']);
$visit_num=count($visit_array)+$sum_num;
if(!in_array($ku['id'],$visit_array)){
$visit_array[$visit_num]=$ku['id'];
mysql_querll("UPDATE kolhoz_collective_club SET visit='".implode(',',$visit_array)."' WHERE id='".$forum['id']."'");
}
//======================================//

if(isset($_GET['proshit'])){
while($post=mysql_fetch_array($q))
{
$visit_array=explode(',',$post['visit']);
$visit_num=count($visit_array)+$sum_num;
if(!in_array($ku['id'],$visit_array)){
$visit_array[$visit_num]=$ku['id'];
mysql_querll("UPDATE kolhoz_collective_club SET visit='".implode(',',$visit_array)."' WHERE id='".$post['id']."'");
}
}
header("Location:?collective=$ct[id]&club=".$forum['id'].""); exit;
}

/////===========================================================================================//
while($post=mysql_fetch_array($q))
{
echo "<div class='block'>"; 
$visit_array=explode(',',$post['visit']);
$visit_num=count($visit_array)+$sum_num;
if(!in_array($ku['id'],$visit_array)){echo"<img width='16' height='16' src='img/icons/forum_topic_new.png' alt='x' title='x'>";
} else {
if($post['locked']==1){echo"<img width='16' height='16' src='img/icons/forum_topic_closed.png' alt='x' title='x'>";
} else {
echo"<img width='16' height='16' src='img/icons/forum_topic.png' alt='*' title='*'>";
}
}
echo" <a href='?collective=$ct[id]&club=$post[id]'><span style='font-weight:bold'>".hsc($post['name'])."</span></a>";
echo ' <font color="orange">('.mysql_result(mysql_query("SELECT COUNT(*) FROM `kolhoz_collective_club` WHERE `id` >= $post[id] AND `mother` = $post[id]"),0).')</font>';

echo'</div>';
}

if ($k_page>1)str("?collective=$ct[id]&club=$forum[id]&",$k_page,$page); // Вывод страниц
echo "</ul>";
echo "<ul class='pt'>";
echo "<li></li>";




/*
//============
echo "<div class='event'><h1>1<a href='?collective=$ct[id]&club'>Дом культуры</a> / ".hsc($forum['name'])."</h1></div>";
echo '<div class="content"><div class="block"><ul>';
$k_post = mysql_result(mysql_querll("SELECT COUNT(*) FROM `kolhoz_collective_club` WHERE `type` = 'tema' AND `mother` = '$forum[id]'"),0);
if ($k_post==0)
{
echo "Список пуст...";
}
$k_page=k_page($k_post,$set['p_str']);
$page=page($k_page);
$start=$set['p_str']*$page-$set['p_str'];
$q=mysql_querll("SELECT * FROM `kolhoz_collective_club` WHERE `type` = 'tema' AND `mother` = '$forum[id]' ORDER BY `pined` DESC, `time_obnov` DESC LIMIT $start, $set[p_str]");
while($post=mysql_fetch_array($q))
{
echo "<li><div>".($post['locked']==1?"<img width='16' height='16' src='img/icons/forum_topic_closed.png' alt='x' title='x'>":"<img width='16' height='16' src='img/icons/forum_topic.png' alt='*' title='*'>")." <a href='?collective=$ct[id]&club=$post[id]'><span style='font-weight:bold'>".hsc($post['name'])."</span></a>";
echo ' <font color="orange">('.mysql_result(mysql_query("SELECT COUNT(*) FROM `kolhoz_collective_club` WHERE `id` >= $post[id] AND `mother` = $post[id]"),0).')</font></div><div class="small"></div></li>';

}
if ($k_page>1)str("?collective=$ct[id]&club=$forum[id]&",$k_page,$page); // Вывод страниц
echo "</ul>";
echo "<ul class='pt'>";
echo "<li></li>";
*/




echo "<li><img width='16' height='16' src='img/icons/tick.png' alt='*' title='*'> <a href='?collective=$ct[id]&club=$forum[id]&proshit'>Отметить все как прочитанное</a></li>";
if($mc['id']!=$ct['id'])echo "<li><img width='16' height='16' src='img/icons/forum_topic_new.png' alt='*' title='*'> <a href='?collective=$ct[id]&club=$forum[id]&add'>Создать топик</a></li>";
if($mc['id']==$ct['id'])echo "<li><img width='16' height='16' src='img/icons/forum_topic_new.png' alt='*' title='*'> <a href='?collective=$ct[id]&club=$forum[id]&add'>Создать топик</a></li>";
if($mc['id']==$ct['id'] && $mcu['status']<=2)echo "<li><img alt='o' width='16' height='16' src='img/icons/forum_edit.png'> <a href='?collective=$ct[id]&club=$forum[id]&edit'>Изменить название</a></li>";
if($mc['id']==$ct['id'] && $mcu['status']<=3)echo "<li><img alt='o' width='16' height='16' src='img/icons/delete.png'> <a href='?collective=$ct[id]&club=$forum[id]&del'>Удалить</a></li>";

echo "</ul></div>";
include_once 'inc/foot.php';
}


if(isset($_GET['add']) && $mc['id']==$ct['id'] && $mcu['status']<=3)
{
echo '<div class="event"><h1>Создание раздела</h1></div>';
if($_GET['add']=='ok')
{
$name=$_POST['name'];
if($name==NULL)
{
echo err_game("Слишком короткое название");
$err=1;
}
if(!isset($err))
{
if($_POST['guest']==1)$guest=1;else $guest=0;

$pos=mysql_result(mysql_querll("SELECT MAX(`pos`) FROM `kolhoz_collective_club` WHERE `type` = 'razdel'"), 0)+1;
mysql_querll("INSERT INTO `kolhoz_collective_club` SET `name` = '".my_esc($name)."', `id_user` = '$ku[id]', `type` = 'razdel', `mother` = '0', `time` = '$time', `guest` = '$guest',`id_collective` = '$ct[id]'");
header("Location:?collective=$ct[id]&club");
exit;
}
}
echo '<div class="content"><div class="block">';
echo "<form action='?collective=".$ct['id']."&club&add=ok' method='post'><ul><li><label><div>Название:</div><div><input type='text' class='wide' value='' name='name'></div></label></li>";
echo "<input type='checkbox' name='guest' value='1'> <span>Открыть доступ гостям</span><br/>";

echo "<li><input type='submit' value='Создать'></li></ul></form></div></div>";
include_once 'inc/foot.php';
}



echo "<div class='event'><h1><a href='?collective=$ct[id]'>".hsc($ct['name'])."</a> / Дом культуры</h1></div>";
echo '<div class="content"><div class="block"><ul>';
$q=mysql_querll("SELECT * FROM `kolhoz_collective_club` WHERE `type` = 'razdel' AND `id_collective` = '$ct[id]'".($mc['id']!=$ct['id']?" AND `guest` = '1'":null)." ORDER BY `pos` ASC");

while($post=mysql_fetch_array($q))
{
echo "<div class='block'>"; 

$visit_array=explode(',',$post['visit']);
$visit_num=count($visit_array)+$sum_num;
if(!in_array($ku['id'],$visit_array)){echo"<img width='16' height='16' src='img/icons/forum_new.png' alt='*' title='*'>";} else {echo"<img width='16' height='16' src='img/icons/forum.png' alt='*' title='*'>";}

echo " <a href='?collective=$ct[id]&club=$post[id]'><span>".hsc($post['name'])."</span></a>";

echo ' <font color="tomato">('.mysql_result(mysql_query("SELECT COUNT(*) FROM `kolhoz_collective_club` WHERE `id` >= $post[id] AND `mother` = $post[id]"),0).')</font>';

echo "</div>";
}
/*
echo "<b>*</b> <font color='green'>Кол. игроков в разделе</font><br/>";
echo "<b>*</b> <font color='tomato'>Кол. топиков в разделе</font><br/>";
echo "<b>*</b> <font color='orange'>Кол. сообщений в разделе</font>";
*/
if($mc['id']==$ct['id'] && $mcu['status']<=3)echo "<br/><li><img width='16' height='16' src='img/icons/forum.png' alt='*' title='*'> <a href='?collective=$ct[id]&club&add'>Создать раздел</a></li>";

echo "</div>";
include_once 'inc/foot.php';
?>