Файл: inc/collective/club.php
Строк: 262
<?
$title='Дом культуры';
include_once '../system/config.php';
if(isset($_GET['KolhozForum']) && ($_GET['KolhozForum'])!=NULL && mysql_result(mysql_query("SELECT COUNT(*) FROM `kolhoz_collective` WHERE `id` = '".($_GET['KolhozForum'])."' LIMIT 1"),0)!=0){
$mcu =mysql_fetch_array(mysql_query("SELECT * FROM `kolhoz_collective_user` WHERE `id_user` = '$ku[id]'"));
$ct =mysql_fetch_array(mysql_query("SELECT * FROM `kolhoz_collective` WHERE `id` = '".intval($_GET['KolhozForum'])."'"));
if(mysql_result(mysql_query("SELECT COUNT(*) FROM `kolhoz_collective_club` WHERE `id_collective` = '$ct[id]' AND `type` = 'razdel'"),0)==0)
{
mysql_query("INSERT INTO `kolhoz_collective_club` SET `name` = 'Наш форум', `type` = 'razdel', `mother` = '0', `time` = '$time', `pos` = '1', `id_collective` = '$ct[id]', `guest` = '0'");
mysql_query("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_query("SELECT COUNT(*) FROM `kolhoz_collective_club` WHERE `id` = '".intval($_GET['club'])."' AND `id_collective` = '$ct[id]'"),0)!=0)$forum=mysql_fetch_array(mysql_query("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_query("SELECT * FROM `kolhoz_collective_club` WHERE `type` = 'komm' AND `mother` = '$forum[id]' ORDER BY `time` ASC LIMIT 1"));
$mother=mysql_fetch_array(mysql_query("SELECT * FROM `kolhoz_collective_club` WHERE `id` = '$forum[mother]'"));
if($mc['id']!=$ct['id'] && $mother['guest']==0)
{
header("Location:/kolhoz/KolhozForum/$ct[id]/");
exit;
}
if(isset($_GET['edit']) && $mc['id']==$ct['id'] && $mcu['status']<=3)
{
echo"<div class='rzd2'></div><div class='menuin2'>";
echo '<div class="title">Редактирование топика</h2></div>';
if($_GET['edit']=='ok')
{
$name=trim($_POST['name']);
$msg=trim($_POST['msg']);
if($name==NULL)
{
echo err_game("Слишком короткое название");
$err=1;
}
if($msg==NULL)
{
echo err_game("Слишком короткое сообщение");
$err=1;
}
if(!isset($err))
{
mysql_query("UPDATE `kolhoz_collective_club` SET `name` = '".my_esc($name)."', `msg` = '".my_esc($msg)."' WHERE `id` = '$forum[id]'");
mysql_query("UPDATE `kolhoz_collective_club` SET `msg` = '".my_esc($msg)."' WHERE `id` = '$fk[id]'");
header("Location:/kolhoz/KolhozForum/$ct[id]/$forum[id]");
exit;
}
}
echo '<div class="content"><div class="div">';
echo "<form action='/kolhoz/KolhozForum/$ct[id]/$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></div><div class='rzd2'></div>";
include_once '../system/foot.php';}
if(isset($_GET['lock']) && $mc['id']==$ct['id'] && $mcu['status']<=3)
{
mysql_query("UPDATE `kolhoz_collective_club` SET `locked` = '".($forum['locked']==1?"0":"1")."' WHERE `id` = '$forum[id]'");
header("Location:/kolhoz/KolhozForum/$ct[id]/$forum[id]");
exit;
}
if(isset($_GET['pin']) && $mc['id']==$ct['id'] && $mcu['status']<=3)
{
mysql_query("UPDATE `kolhoz_collective_club` SET `pined` = '".($forum['pined']==1?"0":"1")."' WHERE `id` = '$forum[id]'");
header("Location:/kolhoz/KolhozForum/$ct[id]/$forum[id]");
exit;
}
if(isset($_GET['del']) && $mc['id']==$ct['id'] && $mcu['status']<=3)
{
if($_GET['del']=='ok')
{
mysql_query("delete from `kolhoz_collective_club` where `mother` = '$forum[id]' and `type` = 'komm'");
mysql_query("delete from `kolhoz_collective_club` where `id` = '$forum[id]' and `type` = 'tema'");
header("Location:/kolhoz/KolhozForum/$ct[id]/$mother[id]");
exit;
}
echo '<div class="title">Подтверждение</h2></div><div class="content"><div class="title"><ul class="block"><li><span >Вы уверены?</span></li><li class="pt"><img alt="" src="/img/icons/tick.png"> <a href="/kolhoz/KolhozForum/'.$ct['id'].'/'.$forum['id'].'/Delete/ok"><span>
Да, подтверждаю</span></a></li><li><img alt="" src="/img/icons/cross.png"> <a href="/kolhoz/KolhozForum/'.$ct['id'].'/'.$forum['id'].'"><span>
Нет, отказываюсь</span></a></li></ul></div>';
echo"</div></div><div class='rzd2'></div>";
include_once '../system/foot.php';}
if(isset($_GET['del_komm']) && intval($_GET['del_komm'])!=NULL && mysql_result(mysql_query("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_query("delete from `kolhoz_collective_club` where `mother` = '$forum[id]' and `type` = 'komm' and `id` = '".intval($_GET['del_komm'])."'");
header("Location:/kolhoz/KolhozForum/$ct[id]/$forum[id]");
exit;
}
echo"<div class='rzd2'></div><div class='menuin2'>";
echo "<div class='title'><a href='/kolhoz/KolhozForum/$ct[id]/$mother[id]'>".hsc($mother['name'])."</a> / ".hsc($forum['name'])."</h2></div>";
if(isset($_GET['otv']) && intval($_GET['otv'])!=NULL && mysql_result(mysql_query("SELECT COUNT(*) FROM `kolhoz_user` WHERE `id` = '".intval($_GET['otv'])."'"),0)!=0 && intval($_GET['otv'])!=$ku['id'])
{
$otv=mysql_fetch_array(mysql_query("SELECT * FROM `kolhoz_user` WHERE `id` = '".intval($_GET['otv'])."'"));
$otvu=$otv;
}
if(isset($_GET['add']) && $_GET['add']=='ok' && $forum['locked']==0)
{
$msg=trim($_POST['msg']);
if($msg==NULL)
{
echo err_game("Слишком короткое сообщение");
$err=1;
}
if(!isset($err))
{
mysql_query("INSERT INTO `kolhoz_collective_club` SET `msg` = '".my_esc($msg)."', `id_user` = '$ku[id]', `type` = 'komm', `mother` = '$forum[id]', `time` = '$time', `id_collective` = '$ct[id]'".(isset($otv)?", `otvet` = '$otv[id]'":null)."");
mysql_query("UPDATE `kolhoz_collective_club` SET `time_obnov` = '$time' WHERE `id` = '$forum[id]'");
header("Location:/kolhoz/KolhozForum/$ct[id]/$forum[id]");
exit;
}
}
echo "<div class='content'><div class='div'>";echo "<ul>";
$k_post = mysql_result(mysql_query("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_query("SELECT * FROM `kolhoz_collective_club` WHERE `type` = 'komm' AND `mother` = '$forum[id]' ORDER BY `time` ASC LIMIT $start, $set[p_str]");
$visit=mysql_fetch_array(mysql_query("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_query("UPDATE kolhoz_collective_club SET visit='".implode(',',$visit_array)."' WHERE id='".$forum['id']."'");
}
while($post=mysql_fetch_array($q))
{
$ank=mysql_fetch_array(mysql_query("SELECT * FROM `kolhoz_user` WHERE `id` = '$post[id_user]'"));
$anku=$ank;
echo "<li><div><span class='small'><span>";
echo on_k($ank['id']);
if($post['otvet']!=0 && mysql_result(mysql_query("SELECT COUNT(*) FROM `kolhoz_user` WHERE `id` = '$post[otvet]'"),0)!=0)
{
$otvet=mysql_fetch_array(mysql_query("SELECT * FROM `kolhoz_user` WHERE `id` = '$post[otvet]'"));
$otvetu=$otvet;
}
echo "<a class='' href='/user/$ank[id]'>".nc($ank['id'])."</a></span> <span class='minor'><span>".vremja($post['time'])."</span></span></span>
<span class='n'><br>".(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'])."</span></div><div class='small'>".($fk['id']!=$post['id']?"".($forum['locked']==0?"".($ank['id']!=$ku['id']?"<a class='minor' href='/kolhoz/KolhozForum/$ct[id]/$forum[id]/otv/$ank[id]'>[ответить]</a>":null)."":null)."":null)."";
if($mc['id']==$ct['id'] && $mcu['status']<=3 && $post['id']!=$fk['id'])echo " <a class='small minor' href='/kolhoz/KolhozForum/$ct[id]/$forum[id]/Delete/$post[id]'>[удалить]</a>";
echo "</div></li>";
}
if($forum['locked']==0)echo "<form action='/kolhoz/KolhozForum/$ct[id]/$forum[id]/add/ok".(isset($otv)?"/otv/$otv[id]":null)."' method='post'><ul><li><label><div><br>Сообщение".(isset($otv)?" для $otvu[nick]":null)."</div><div><textarea class='wide' rows='5' name='msg'></textarea></div></label></li><li><input type='submit' value='Написать'></li></ul></form>";
else echo "<div class='pt minor'>Топик закрыт.</div>";
if ($k_page>1)str("/kolhoz/KolhozForum/$ct[id]/$forum[id]/",$k_page,$page); // Вывод страниц
echo "</ul>";
echo "<ul class='pt'>";
if($mc['id']==$ct['id'] && $mcu['status']<=3)echo "<li><img alt='o' width='' height='16' src='/img/icons/moderate.png'> <a href='/kolhoz/KolhozForum/$ct[id]/$forum[id]".(!isset($_GET['moderate'])?"/moderate":null)."'>Управление</a></li>";
if(isset($_GET['moderate']) && $mc['id']==$ct['id'] && $mcu['status']<=3)
{
echo "<li><img alt='o' src='/img/icons/forum_pin.png'> <a href='/kolhoz/KolhozForum/$ct[id]/$forum[id]/pin'><span>".($forum['pined']==0?"При":"От")."крепить</span></a></li>";
echo "<li><img alt='o' src='/img/icons/forum_close.png'> <a href='/kolhoz/KolhozForum/$ct[id]/$forum[id]/lock'><span>".($forum['locked']==0?"За":"От")."крыть</span></a></li>";
echo "<li><img alt='o' src='/img/icons/forum_move.png'> <a href='/kolhoz/KolhozForum/$ct[id]/$forum[id]/moderate".(!isset($_GET['replace'])?"/replace":null)."'>Перенести</a><br></li>";
if(isset($_GET['replace']))
{
if($_GET['replace']=='ok' && mysql_result(mysql_query("SELECT COUNT(*) FROM `kolhoz_collective_club` WHERE `id` = '".intval($_POST['forum'])."' AND `type` = 'razdel' AND `id_collective` = '$ct[id]'"),0)!=0)
{
mysql_query("UPDATE `kolhoz_collective_club` SET `mother` = '".intval($_POST['forum'])."' WHERE `id` = '$forum[id]'");
header("Location:/kolhoz/KolhozForum/$ct[id]/$forum[id]");
}
echo "<li>";
echo "<form method='post' action='/kolhoz/KolhozForum/$ct[id]/$forum[id]/moderate/replace/ok'><div>Перенос топика "<span>".hsc($forum['name'])."</span>"</div><label>Новый раздел<br>";
echo "<select name='forum'>";
$q=mysql_query("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>";
}
}
if($mc['id']==$ct['id'] && $mcu['status']<=3)echo "<li><img alt='o' src='/img/icons/delete.png'> <a href='/kolhoz/KolhozForum/$ct[id]/$forum[id]/Delete'>Удалить</a></li>";
if($mc['id']==$ct['id'] && $mcu['status']<=3)echo "<li><img alt='o' src='/img/icons/forum_edit.png'> <a href='/kolhoz/KolhozForum/$ct[id]/$forum[id]/edit'>Изменить</a></li>";
echo "</ul></div>";
echo"</div></div><div class='rzd2'></div>";
include_once '../system/foot.php';}
if(isset($forum) && $forum['type']=='razdel')
{
if($mc['id']!=$ct['id'] && $forum['guest']==0)
{
header("Location:/kolhoz/KolhozForum/$ct[id]/");
exit;
}
if(isset($_GET['add']) && $mc['id']==$ct['id'])
{
echo"<div class='rzd2'></div><div class='menuin2'>";
echo '<div class="title">Создание топика</h2></div>';
if($_GET['add']=='ok')
{
$name=trim($_POST['name']);
$msg=trim($_POST['msg']);
if($name==NULL)
{
echo err_game("Слишком короткое название");
$err=1;
}
if($msg==NULL)
{
echo err_game("Слишком короткое сообщение");
$err=1;
}
if(!isset($err))
{
mysql_query("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_query("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:/kolhoz/KolhozForum/$ct[id]/$id");
exit;
}
}
echo '<div class="content"><div class="div">';
echo "<form action='/kolhoz/KolhozForum/$ct[id]/$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>";
echo"</div></div><div class='rzd2'></div>";
include_once '../system/foot.php';}
if(isset($_GET['edit']) && $mc['id']==$ct['id'] && $mcu['status']<=2)
{
echo"<div class='rzd2'></div><div class='menuin2'>";
echo '<div class="title">Редактирование раздела</h2></div>';
if(isset($_POST['name']))
{
$name=$_POST['name'];
if($name==NULL)
{
echo err_game("Слишком короткое название");
$err=1;
}
if(!isset($err))
{
mysql_query("UPDATE `kolhoz_collective_club` SET `name` = '".my_esc($name)."' WHERE `id` = '$forum[id]'");
header("Location:/kolhoz/KolhozForum/$ct[id]/$forum[id]");
exit;
}
}
echo '<div class="content"><div class="div">';
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 "<li><input type='submit' value='Сохранить'></li></ul></form></div>";
include_once '../system/foot.php';}
echo"<div class='rzd2'></div><div class='menuin2'>";
echo "<div class='title'><a href='/kolhoz/KolhozForum/$ct[id]/'>Дом культуры</a> / ".hsc($forum['name'])."</h2></div>";
echo '<div class="content"><div class="div"><ul>';
$k_post = mysql_result(mysql_query("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'];
$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_query("UPDATE `kolhoz_collective_club` SET visit='".implode(',',$visit_array)."' WHERE id='".$post['id']."'");
}
$q=mysql_query("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>";
$visit_array=explode(',',$post['visit']);
$visit_num=count($visit_array)+$sum_num;
if(!in_array($ku['id'],$visit_array))
{
echo"<img src='/img/icons/forum_topic_new.png' alt='x' n='x'> ";
}
else
{
if($post['locked']==1){echo"<img src='/img/icons/forum_topic_closed.png' alt='x' n='x'> ";
}
else
{
echo"<img src='/img/icons/forum_topic.png' alt='*' n='*'> ";
}
}
echo '<a href="/kolhoz/KolhozForum/'.$ct['id'].'/'.$post['id'].'">'.hsc($post['name']).'</a></div><div class="small"></div></li>';
}
if ($k_page>1)str("/kolhoz/KolhozForum/$ct[id]/$forum[id]/",$k_page,$page); // Вывод страниц
echo "</ul>";
echo "<ul class='pt'>";
echo "<li></li>";
if($mc['id']==$ct['id'])echo "<li><img src='/img/icons/forum_topic_new.png' alt='*' n='*'> <a href='/kolhoz/KolhozForum/$ct[id]/$forum[id]/add'>Создать топик</a></li>";
if($mc['id']==$ct['id'] && $mcu['status']<=2)echo "<li><img alt='o' src='/img/icons/forum_edit.png'> <a href='/kolhoz/KolhozForum/$ct[id]/$forum[id]/edit'>Изменить название</a></li>";
echo "</ul></div>";
echo"</div></div><div class='rzd2'></div>";
include_once '../system/foot.php';}
if (isset($_GET['up']) && $mc['id']==$ct['id'] && $mcu['status']<=2)
{
$up=mysql_fetch_assoc(mysql_query("SELECT * FROM `kolhoz_collective_club` WHERE `id` = '".intval($_GET['up'])."' AND `type` = 'razdel' AND `id_collective` = '$ct[id]' LIMIT 1"));
if(mysql_result(mysql_query("SELECT COUNT(*) FROM `kolhoz_collective_club` WHERE `pos` < '$up[pos]' AND `type` = 'razdel' AND `id_collective` = '$ct[id]' LIMIT 1"),0)!=0)
{
mysql_query("UPDATE `kolhoz_collective_club` SET `pos` = '".($up['pos'])."' WHERE `pos` = '".($up['pos']-1)."' AND `type` = 'razdel' AND `id_collective` = '$ct[id]' LIMIT 1");
mysql_query("UPDATE `kolhoz_collective_club` SET `pos` = '".($up['pos']-1)."' WHERE `id` = '".intval($_GET['up'])."' AND `type` = 'razdel' AND `id_collective` = '$ct[id]' LIMIT 1");
}
}
elseif (isset($_GET['down']) && $mc['id']==$ct['id'] && $mcu['status']<=2)
{
$down=mysql_fetch_assoc(mysql_query("SELECT * FROM `kolhoz_collective_club` WHERE `id` = '".intval($_GET['down'])."' AND `type` = 'razdel' AND `id_collective` = '$ct[id]' LIMIT 1"));
if(mysql_result(mysql_query("SELECT COUNT(*) FROM `kolhoz_collective_club` WHERE `pos` > '$down[pos]' AND `type` = 'razdel' AND `id_collective` = '$ct[id]' LIMIT 1"),0)!=0)
{
mysql_query("UPDATE `kolhoz_collective_club` SET `pos` = '".($down['pos'])."' WHERE `pos` = '".($down['pos']+1)."' AND `type` = 'razdel' AND `id_collective` = '$ct[id]' LIMIT 1");
mysql_query("UPDATE `kolhoz_collective_club` SET `pos` = '".($down['pos']+1)."' WHERE `id` = '".intval($_GET['down'])."' AND `type` = 'razdel' AND `id_collective` = '$ct[id]' LIMIT 1");
}
}
echo"<div class='rzd2'></div><div class='menuin2'>";
echo "<div class='title'><a href='/kolhoz/$ct[id]'>".hsc($ct['name'])."</a> / Дом культуры</h2></div>";
echo '<div class="content"><div class="div"><ul>';
$q=mysql_query("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))
{
$visit_array=explode(',',$post['visit']);
$visit_num=count($visit_array)+$sum_num;
if(!in_array($ku['id'],$visit_array) && $post['open']!=no)
{
echo"<li><img src='/img/icons/forum_new.png' alt='*' n='*'> ";
}
else
{
echo "<li><img src='/img/icons/forum.png' alt='*' n='*'> ";
}
echo "<a href='/kolhoz/KolhozForum/$ct[id]/$post[id]'><span>".hsc($post['name'])."</span></a></li>";
}
echo "</ul>";
if($mc['id']==$ct['id'] && $mcu['status']<=2)
{
echo "<ul class='pt'>";
echo "</ul>";
}
echo "</div>";
echo"</div></div><div class='rzd2'></div>";
include_once '../system/foot.php';
}
?>