Файл: zfarm.mobi/inc/communication/forum.php
Строк: 385
<?
$title='Форум';
include_once '../system/config.php';
include_once '../user/Chest.php';
$sum_num=1;
if(intval($_GET['forum'])!=NULL && mysql_result(mysql_query("SELECT COUNT(*) FROM `kolhoz_forum` WHERE `id` = '".intval($_GET['forum'])."'"),0)!=0)$forum=mysql_fetch_array(mysql_query("SELECT * FROM `kolhoz_forum` WHERE `id` = '".intval($_GET['forum'])."'"));
if(isset($forum) && $forum['type']=='tema')
{
$fk=mysql_fetch_array(mysql_query("SELECT * FROM `kolhoz_forum` WHERE `type` = 'komm' AND `mother` = '$forum[id]' ORDER BY `time` ASC LIMIT 1"));
$mother=mysql_fetch_array(mysql_query("SELECT * FROM `kolhoz_forum` WHERE `id` = '$forum[mother]'"));
if($mother['locked']==1 && $ku['status']<=0)header("Location:/forum");
if(isset($_GET['edit']) && $ku['status']>0)
{
echo '<div class="title">Редактирование топика</h2></div>';
if($_GET['edit']=='ok')
{
$name=$_POST['name'];
$msg=$_POST['msg'];
if($name==NULL)
{
echo err_game("Слишком короткое название");
$err=1;
}
if($msg==NULL)
{
echo err_game("Слишком короткое сообщение");
$err=1;
}
if($ku['antispam']>$time)
{
$err=1;
err_game("Вы сможете написать сообщение через ".time_left($ku['antispam']-$time)."");
}
if(!isset($err))
{
mysql_query("UPDATE `kolhoz_forum` SET `name` = '".my_esc($name)."', `msg` = '".my_esc($msg)."', `visit` = ',".$ku['id']."' WHERE `id` = '$forum[id]'");
mysql_query("UPDATE `kolhoz_forum` SET `msg` = '".my_esc($msg)."' WHERE `id` = '$fk[id]'");
mysql_query("UPDATE `kolhoz_forum` SET `visit` = ',".$ku['id']."' WHERE `id` = '".$forum['mother']."'");
$time1=(60-$ku['level']);
$timeAntispam=$time1+time();
mysql_query("UPDATE `kolhoz_user` SET `antispam` = '$timeAntispam' WHERE `id` = '$ku[id]'");
header("Location:/forum/$forum[id]");
exit;
}
}
echo '<div class="content"><div class="div">';
echo "<form action='/forum/$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';
}
elseif(isset($_GET['lock']) && $ku['status']>0)
{
mysql_query("UPDATE `kolhoz_forum` SET `locked` = '".($forum['locked']==1?"0":"1")."' WHERE `id` = '$forum[id]'");
mysql_query("INSERT INTO `kolhoz_forum` SET `msg` = 'Тема ".($forum['locked']==1?"открыта":"закрыта")." ".($ku['admin']==2?"модератором":"администратором")." $ku[nick]', `id_user` = '3', `type` = 'komm', `mother` = '$forum[id]', `time` = '$time'".(isset($otv)?", `otvet` = '$otv[id]'":null)."");
header("Location:/forum/$forum[id]");
}
elseif(isset($_GET['pin']) && $ku['status']>0)
{
mysql_query("UPDATE `kolhoz_forum` SET `pined` = '".($forum['pined']==1?"0":"1")."' WHERE `id` = '$forum[id]'");
header("Location:/forum/$forum[id]");
}
elseif(isset($_GET['del']) && $ku['status']>0)
{
if($_GET['del']=='ok')
{
mysql_query("delete from `kolhoz_forum` where `mother` = '$forum[id]' and `type` = 'komm'");
mysql_query("delete from `kolhoz_forum` where `id` = '$forum[id]' and `type` = 'tema'");
header("Location:/forum/$mother[id]");
}
else
echo"<div class='rzd2'></div><div class='menuin2'>";
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="/forum/'.$forum['id'].'/del/ok"><span>
Да, подтверждаю</span></a></li><li><img alt="" src="/img/icons/cross.png"> <a href="/forum/'.$forum['id'].'"><span>
Нет, отказываюсь</span></a></li></ul></div>';
echo"</div></div><div class='rzd2'></div>";
include_once '../system/foot.php';
}
elseif(isset($_GET['del_komm']) && intval($_GET['del_komm'])!=NULL && mysql_result(mysql_query("SELECT COUNT(*) FROM `kolhoz_forum` WHERE `id` = '".intval($_GET['del_komm'])."' AND `type` = 'komm' AND `id` != '$fk[id]'"),0)!=0 && $ku['status']>0)
{
mysql_query("delete from `kolhoz_forum` where `mother` = '$forum[id]' and `type` = 'komm' and `id` = '".intval($_GET['del_komm'])."'");
header("Location:/forum/$forum[id]");
}
else
{
echo"<div class='rzd2'></div><div class='menuin2'>";
echo "<div class='title'><a href='/forum/$mother[id]'>".hsc($forum['name'])."</h2></a></div>";
{
$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 && !isset($molchi))
{
$msg=$_POST['msg'];
if($msg==NULL)
{
echo err_game("Слишком короткое сообщение");
$err=1;
}
if($ku['antispam']>$time)
{
$err=1;
err_game("Вы сможете написать сообщение через ".time_left($ku['antispam']-$time)."");
}
////=======================================================================================================///
if(!isset($err))
{
mysql_query("INSERT INTO `kolhoz_forum` SET `msg` = '".my_esc($msg)."', `id_user` = '$ku[id]', `type` = 'komm', `mother` = '$forum[id]', `time` = '$time'".(isset($otv)?", `otvet` = '$otv[id]'":null)."");
mysql_query("UPDATE `kolhoz_user` SET `forum` = '".($ku['forum']+1)."' WHERE `id` = '".$ku['id']."'");
$time1=(120-$ku['level']);
$timeAntispam=$time1+time();
mysql_query("UPDATE `kolhoz_user` SET `antispam` = '$timeAntispam' WHERE `id` = '$ku[id]'");
mysql_query("UPDATE `kolhoz_forum` SET `time_obnov` = '$time', `visit` = ',".$ku['id']."' WHERE `id` = '$forum[id]'");
$for_raz=mysql_fetch_array(mysql_query("SELECT * FROM kolhoz_forum WHERE id='".$forum['id']."'"));
mysql_query("UPDATE `kolhoz_forum` SET `visit` = ',".$ku['id']."' WHERE `id` = '".$for_raz['mother']."'");
mysql_query("UPDATE `kolhoz_user` SET `forumpost` = '".($ku['forumpost']+1)."' WHERE `id` = '$ku[id]' LIMIT 1");
header("Location:/forum/".$forum['id']."/page/end");
exit;
}
}
//======================================//
$visit=mysql_fetch_array(mysql_query("SELECT * FROM kolhoz_forum 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_forum SET visit='".implode(',',$visit_array)."' WHERE id='".$forum['id']."'");
}
//======================================//
echo "<div class='content'><div class='div'>";
echo "<ul>";
$k_post = mysql_result(mysql_query("SELECT COUNT(*) FROM `kolhoz_forum` 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_forum` 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]'"));
$anku=$ank;
echo "<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;
}
if($ank['id']==$ank['id'])
if($mcu['status']<=3)echo "";
echo "<a class='' href='/user/$ank[id]'>".nc($ank['id'])."</a></span>";
if (mysql_result(mysql_query("SELECT COUNT(*) FROM `kolhoz_user` WHERE `id` = '$ank[id]' AND `date_last` > '".(time()-700)."' LIMIT 1"),0)==1)
echo " ";
echo " <span class='minor'>".vremja($post['time'])."</span><br></span></span>".(($post['otvet']!=0)?"".($ku['id']==$otvet['id']?"<span class='rare'>":null)."$otvetu[nick]".($ku['id']==$otvet['id']?"</span>":null).", ":null)."<span class='n'>".output_text($post['msg'], $ank['id'])."</span><div class='small minor'>".($fk['id']!=$post['id']?"".($forum['locked']==0?"".($ank['id']!=$ku['id']?"<a class='small minor' href='/forum/$forum[id]/otv/$ank[id]'>ответить</a>":null)."":null)."":null)."";
if($ku['status']>0 && $post['id']!=$fk['id'])echo " <a class='small minor' href='/forum/$forum[id]/Delete/$post[id]'>[удалить]</a>";
echo'<div style="margin-top:1px"></div>';
if($post['id']==$forum['id']+1){echo "<br>";}else{echo "<br>";}
echo "</div>";
}
if($ban['id'])
{
echo "<br>
<div>
<li class='major'><span>".($ban['izg']==1?'Изгнание':"Обет Молчания до ".vremja($ban['time']))."</span>, выдал".($us_ban['pol']==0?'a':null)." <span>";
echo on_k($us_ban['id']);
echo "<a href='/user/$us_ban[id]'>".nc($us_ban['id'])."</a></span><span>, (".output_text($ban['msg']).")</span></li></div></ul>";
}
else
{
$for_net=1;
if ($k_page>1){str("/forum/$forum[id]/",$k_page,$page); echo"<br>";} // Вывод страниц
if($forum['locked']==0)echo "<form action='/forum/$forum[id]/add/ok".(isset($otv)?"/otv/$otv[id]":null)."' method='post'><ul><li><label><div>Сообщение ".(isset($_GET['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($for_net!=1){
if ($k_page>1)str("/forum/$forum[id]/",$k_page,$page); // Вывод страниц
}
echo "</ul>";
echo "<br>";
{
if($ku['status']>0)echo "<li><img alt='o' src='/img/icons/forum_close.png'> <a href='/forum/$forum[id]/lock'><span>".($forum['locked']==0?"За":"От")."крыть</span></a></li>";
if($ku['status']>0)echo "<li><img alt='o' src='/img/icons/forum_pin.png'> <a href='/forum/$forum[id]/pin'><span>".($forum['pined']==0?"При":"От")."крепить</span></a></li>";
if($ku['status']>0)echo "<li><img alt='o' src='/img/icons/forum_move.png'> <a href='/forum/$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_forum` WHERE `id` = '".intval($_POST['forum'])."' AND `type` = 'razdel'"),0)!=0)
{
mysql_query("UPDATE `kolhoz_forum` SET `mother` = '".intval($_POST['forum'])."' WHERE `id` = '$forum[id]'");
header("Location:/forum/$forum[id]");
}
echo "<li>";
echo "<form method='post' action='/forum/$forum[id]/moderate/replace/ok'><div>Перенос топика "<span>".hsc($forum['name'])."</span>"</div><label>Новый раздел<br>";
echo "<select name='forum'>";
$q=mysql_query("SELECT * FROM `kolhoz_forum` WHERE `id` != '$mother[id]' AND `type` = 'razdel'");
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($ku['status']>0)echo "<li><img alt='o' src='/img/icons/delete.png'> <a href='/forum/$forum[id]/del'>Удалить</a></li>";
if($ku['status']>0)echo "<li><img alt='o' src='/img/icons/forum_edit.png'> <a href='/forum/$forum[id]/edit'>Изменить</a></li>";
echo "</ul></div>";
echo"</div></div><div class='rzd2'></div>";
include_once '../system/foot.php';
}
}
elseif(isset($forum) && $forum['type']=='razdel' && ($forum['locked']==1 && $ku['status']>0 || $forum['locked']==0))
{
if(isset($_GET['add']) && !isset($molchi) && $ku['level']>=10 && ($forum['admod']==1 && $ku['status']>0 || $forum['admod']==0))
{
echo"<div class='rzd2'></div><div class='menuin2'>";
echo '<div class="title">Создание топика</h2></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_query("INSERT INTO `kolhoz_forum` SET `name` = '".my_esc($name)."', `msg` = '".my_esc($msg)."', `id_user` = '$ku[id]', `type` = 'tema', `mother` = '$forum[id]', `time` = '$time', `time_obnov` = '$time'");
$id=mysql_insert_id();
mysql_query("INSERT INTO `kolhoz_forum` SET `msg` = '".my_esc($msg)."', `id_user` = '$ku[id]', `type` = 'komm', `mother` = '$id', `time` = '$time'");
mysql_query("UPDATE `kolhoz_forum` SET `visit` = ',".$ku['id']."' WHERE `id` = '".$forum['id']."'");
header("Location:/forum/$id");
exit;
}
}
echo '<div class="content"><div class="div">';
echo "<form action='/forum/$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';
}
elseif(isset($_GET['edit']) && $ku['status']>0)
{
echo"<div class='rzd2'></div><div class='menuin2'>";
echo '<div class="title">Редактирование раздела</h2></div>';
if($_GET['edit']=='ok')
{
$name=$_POST['name'];
if($name==NULL)
{
echo err_game("Слишком короткое название");
$err=1;
}
if(!isset($err))
{
if($_POST['admod']==1)$admod=1;else $admod=0;
if($_POST['locked']==1)$locked=1;else $locked=0;
mysql_query("UPDATE `kolhoz_forum` SET `name` = '".my_esc($name)."', `admod` = '$admod', `locked` = '$locked' WHERE `id` = '$forum[id]'");
header("Location:/forum/$forum[id]");
exit;
}
}
echo"<div class='rzd2'></div><div class='menuin2'>";
echo '<div class="content"><div class="title">';
echo "<form action='/forum/$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>";
echo "<input type='checkbox' name='admod' value='1'".($forum['admod']==1?" checked='checked'":null)."> <span>Создает топики только администрацыя</span><br/>";
echo "<input type='checkbox' name='locked' value='1'".($forum['locked']==1?" checked='checked'":null)."> <span>Давать доступ только администрации</span><br/>";
echo "<li><input type='submit' value='Сохранить'></li></ul></form></div>";
echo"</div></div><div class='rzd2'></div>";
include_once '../system/foot.php';
}
elseif(isset($_GET['del']) && $ku['status']>0)
{
if($_GET['del']=='ok')
{
$q=mysql_query("SELECT * FROM `kolhoz_forum` WHERE `mother` = '$forum[id]' AND `type` = 'tema'");
while($post=mysql_fetch_array($q))
{
mysql_query("delete from `kolhoz_forum` where `mother` = '$post[id]' and `type` = 'komm'");
mysql_query("delete from `kolhoz_forum` where `id` = '$post[id]'");
}
$links = mysql_query("SELECT * FROM `kolhoz_forum` WHERE `type` = 'razdel' AND `pos` > '$forum[pos]' ORDER BY `pos` ASC");
while ($p = mysql_fetch_array($links))
{
mysql_query("UPDATE `kolhoz_forum` SET `pos` = '".($p['pos']-1)."' WHERE `id` = '$p[id]' LIMIT 1");
}
mysql_query("delete from `kolhoz_forum` where `id` = '$forum[id]' and `type` = 'razdel'");
header("Location:/forum");
}
else echo"<div class='rzd2'></div><div class='menuin2'>";
echo '<div class="title">Подтверждение</h2></div><div class="content"><div class="title"><li><span >Вы уверены?</span></li><li class="pt"><img alt="" src="/img/icons/tick.png"> <a href="/forum/'.$forum['id'].'/del/ok"><span>
Да, подтверждаю</span></a></li><li><img alt="" src="/img/icons/cross.png"> <a href="/forum/'.$forum['id'].'"><span>
Нет, отказываюсь</span></a></li></div></div>';
echo"</div></div><div class='rzd2'></div>";
include_once '../system/foot.php';
}
else
{
echo"<div class='rzd2'></div><div class='menuin2'>";
echo "<div class='title'><a href='/forum'>".hsc($forum['name'])."</a></h2></div>";
echo '<div class="content"><div class="div"><ul>';
$k_post = mysql_result(mysql_query("SELECT COUNT(*) FROM `kolhoz_forum` 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_query("SELECT * FROM `kolhoz_forum` WHERE `type` = 'tema' AND `mother` = '$forum[id]' ORDER BY `pined` DESC, `time_obnov` DESC LIMIT $start, $set[p_str]");
//======================================//
$visit=mysql_fetch_array(mysql_query("SELECT * FROM kolhoz_forum 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_forum 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_query("UPDATE kolhoz_forum SET visit='".implode(',',$visit_array)."' WHERE id='".$post['id']."'");
}
}
header("Location:/forum/".$forum['id'].""); exit;
}
/////===========================================================================================//
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='/forum/$post[id]'>".hsc($post['name'])."</span></a>";
echo'<div style="margin-top:5px"></div>';
echo'</div></li>';
}
echo'<div style="margin-top:10px"></div>';
if ($k_page>1)str("/forum/$forum[id]/",$k_page,$page); // Вывод страниц
echo "</ul>";
if($ban['id'])
{
echo "<ul class='pt'>
<div>
<li class='major'><span>".($ban['izg']==1?'Изгнание':"Обет Молчания до ".vremja($ban['time']))."</span>, выдал".($us_ban['pol']==0?'a':null)." <span>";
echo on_k($us_ban['id']);
echo "<a href='/user/$us_ban[id]'>".nc($us_ban['id'])."</a></span><span>, (".output_text($ban['msg']).")</span></li></div></ul>";
}
elseif($ku['level']>=10 && ($forum['admod']==1 && $ku['status']>0 || $forum['admod']==0))echo "<li><br><img src='/img/icons/forum_topic.png' alt='*' n='*'> <a href='/forum/$forum[id]/add'>Создать топик</a></li>";
echo "<li><img src='/img/icons/tick.png' alt='*' n='*'> <a href='/forum/".$forum['id']."/proshit'>Отметить все как прочитанное</a></li>";
if($ku['status']>0)echo "<li><img alt='o' src='/img/icons/delete.png'> <a href='/forum/$forum[id]/del'>Удалить</a></li>";
if($ku['status']>0)echo "<li><img alt='o' src='/img/icons/forum_edit.png'> <a href='/forum/$forum[id]/edit'>Изменить название</a></li>";
echo "</ul></div>";
echo"</div></div><div class='rzd2'></div>";
include_once '../system/foot.php';
}
}
else
{
if(isset($_GET['add']) && $ku['status']>0)
{
echo"<div class='rzd2'></div><div class='menuin2'>";
echo '<div class="title">Создание раздела</h2></div>';
if($_GET['add']=='ok')
{
$name=$_POST['name'];
if($name==NULL)
{
echo err_game("Слишком короткое название");
$err=1;
}
if(!isset($err))
{
if($_POST['admod']==1)$admod=1;else $admod=0;
$pos=mysql_result(mysql_query("SELECT MAX(`pos`) FROM `kolhoz_forum` WHERE `type` = 'razdel'"), 0)+1;
mysql_query("INSERT INTO `kolhoz_forum` SET `name` = '".my_esc($name)."', `id_user` = '$ku[id]', `type` = 'razdel', `mother` = '0', `time` = '$time', `admod` = '$admod', `pos` = '$pos', `locked` = '".($_POST['locked']==1?"1":"0")."'");
header("Location:/forum");
exit;
}
}
echo"<div class='rzd2'></div><div class='menuin2'>";
echo '<div class="content"><div class="title">';
echo "<form action='/forum/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='admod' value='1'> <span>Создает топики только администрация</span><br/>";
echo "<input type='checkbox' name='locked' value='1'> <span>Давать доступ только администрации</span><br/>";
echo "<li><input type='submit' value='Создать'></li></ul></form></div></div>";
echo"</div></div><div class='rzd2'></div>";
include_once '../system/foot.php';
}
else
{
if (isset($_GET['up']) && $ku['status']>0)
{
$up=mysql_fetch_assoc(mysql_query("SELECT * FROM `kolhoz_forum` WHERE `id` = '".intval($_GET['up'])."' AND `type` = 'razdel' LIMIT 1"));
if(mysql_result(mysql_query("SELECT COUNT(*) FROM `kolhoz_forum` WHERE `pos` < '$up[pos]' AND `type` = 'razdel' LIMIT 1"),0)!=0)
{
mysql_query("UPDATE `kolhoz_forum` SET `pos` = '".($up['pos'])."' WHERE `pos` = '".($up['pos']-1)."' AND `type` = 'razdel' LIMIT 1");
mysql_query("UPDATE `kolhoz_forum` SET `pos` = '".($up['pos']-1)."' WHERE `id` = '".intval($_GET['up'])."' AND `type` = 'razdel' LIMIT 1");
}
}
elseif (isset($_GET['down']) && $ku['status']>0)
{
$down=mysql_fetch_assoc(mysql_query("SELECT * FROM `kolhoz_forum` WHERE `id` = '".intval($_GET['down'])."' AND `type` = 'razdel' LIMIT 1"));
if(mysql_result(mysql_query("SELECT COUNT(*) FROM `kolhoz_forum` WHERE `pos` > '$down[pos]' AND `type` = 'razdel' LIMIT 1"),0)!=0)
{
mysql_query("UPDATE `kolhoz_forum` SET `pos` = '".($down['pos'])."' WHERE `pos` = '".($down['pos']+1)."' AND `type` = 'razdel' LIMIT 1");
mysql_query("UPDATE `kolhoz_forum` SET `pos` = '".($down['pos']+1)."' WHERE `id` = '".intval($_GET['down'])."' AND `type` = 'razdel' LIMIT 1");
}
}
echo"<div class='rzd2'></div><div class='menuin2'>";
echo "<div class='title'>Форум</h2></div>";
echo '<div class="content"><div class="div"><ul>';
$q=mysql_query("SELECT * FROM `kolhoz_forum` WHERE `type` = 'razdel' ORDER BY `pos` ASC");
while($post=mysql_fetch_array($q))
{
echo "<li>";
$visit_array=explode(',',$post['visit']);
$visit_num=count($visit_array)+$sum_num;
if(!in_array($ku['id'],$visit_array) && $post['open']!=no){echo"<img src='/img/icons/forum_new.png' alt='*' n='*'>";} else {if($post['open']!=no)echo"<img src='/img/icons/forum.png' alt='*' n='*'>";}
if($post['open']!=no)echo " <a href='/forum/$post[id]'><span>".hsc($post['name'])."</span></a><br>".(strlen2($post['opis'])!=NULL?"".hsc($post['opis'])."":null)."";
echo "</li>";
}
echo "</ul></div>";
echo"</div></div><div class='rzd2'></div>";
include_once '../system/foot.php';
}
}
?>