Файл: vkollektive2014/soo/inc/them.php
Строк: 152
<?
echo "<div class='cred'><a href="forum.php?s=$soo[id]"> Форум</a> | <a href="?s=$soo[id]&id_forum=$forum[id]&act=new" title='Создать новую тему'><img src='img/add.png' alt='' class='icon'/> Новая тема</a></div>";
if (isset($u) && $them['close']==0 && mysql_result(mysql_query("SELECT COUNT(*) FROM `soo_users` WHERE `id_soo` = '$soo[id]' AND `id_user`='$u[id]' AND `invit`='0' AND `activate`='0' LIMIT 1"),0)==1 && isset($_GET['act']) && $_GET['act']=='new' && isset($_POST['msg']))
{
$time=time()-7200;
$msg=check(htmlspecialchars($_POST['msg'], ENT_QUOTES));
if (mysql_result(mysql_query("SELECT COUNT(*) FROM `soo_forum_mess` WHERE `id_them` = '$them[id]' AND `id_forum` = '$forum[id]' AND `id_soo` = '$soo[id]' AND `id_user` = '$u[id]' AND `mess` = '".$msg."' LIMIT 1"),0)!=0)error('Ваше сообщение повторяет предыдущее');
mysql_query("INSERT INTO `soo_forum_mess` (`id_forum`, `id_soo`, `id_them`, `id_user`, `mess`, `time`) values('$forum[id]', '$soo[id]', '$them[id]', '$u[id]', '".$msg."', '$time')");
$post1=mysql_fetch_array(mysql_query("SELECT * FROM `soo_forum_mess` WHERE `id_them` = '$them[id]' AND `id_razdel` = '$razdel[id]' AND `id_forum` = '$forum[id]' ORDER BY `time` ASC LIMIT 1"));
$an=mysql_fetch_array(mysql_query("SELECT * FROM `user` WHERE `id` = $post1[id_user] LIMIT 1"));
$us_adm = $an['id'];
/*
if($u['id']!=$us_adm) {
$msgrat1="В вашей теме [url=/soo/forum.php?s=$soo[id]&id_forum=$forum[id]&id_them=$them[id]&page=end&]$them[name][/url] оставили сообщение";
mysql_query("INSERT INTO `jurnal` (`id_user`, `id_kont`, `msg`, `time`, `type`) values('0', '$an[id]', '$msgrat1', '$time', 'forum')"); }
if($_GET[ud] && $u[id]!=$_GET[ud] && $_GET[ud]!=$us_adm) {
$msg1="Вам ответили в теме [url=/soo/forum.php?s=$soo[id]&id_forum=$forum[id]&id_them=$them[id]&page=end&]$them[name][/url]";
mysql_query("INSERT INTO `jurnal` (`id_user`, `id_kont`, `msg`, `time`, `type`) values('0', '$_GET[ud]', '$msg1', '$time', 'forum_otv')");
}
*/
$post_id=mysql_insert_id();
unset($_SESSION['msg']);
mysql_query("UPDATE `soo_forum_thems` SET `time` = '$time' WHERE `id` = '$them[id]' LIMIT 1");
header("Location: ?s=$soo[id]&id_forum=$forum[id]&id_them=$them[id]&page=end&".SID);
include_once '../foot.php';
}
if ($them['close']==1)
ok('Тема закрыта для обсуждения');
$k_post=mysql_result(mysql_query("SELECT COUNT(*) FROM `soo_forum_mess` WHERE `id_them` = '$them[id]' AND `id_forum` = '$forum[id]' AND `id_soo` = '$soo[id]'"),0);
$total = intval(($k_post - 1) / 10) + 1;
$page = intval(@$_GET['page']);
if(empty($page) or $page < 0) $page = 1;
if($page > $total) $page = $total;
$start = $page * 10 - 10;
echo "<class='post'>n";
$u_s = mysql_fetch_assoc(mysql_query("SELECT * FROM `soo_users` WHERE `id_soo`='$soo[id]' AND `id_user`='$u[id]' LIMIT 1"));
if ((isset($u) && $u_s['level']>'0' || isset($u) && $ank2['id']==$u['id']) && isset($_GET['act']) && $_GET['act']=='post_delete'){$lim=NULL;}else $lim=" LIMIT $start";
$tema = mysql_fetch_assoc(mysql_query("SELECT * FROM `soo_forum_thems` WHERE `id_soo`='$soo[id]' AND `id_forum`='$forum[id]' AND `id` = '$them[id]' LIMIT 1"));
$us_tem = mysql_fetch_assoc(mysql_query("SELECT * FROM `users` WHERE `id` = '$tema[id_user]' LIMIT 1"));
if (!isset($_GET['act'])){
echo "<div class='nav'>".ico($us_tem['sex'],$us_tem['admin'])." <a href='info.php?s=$soo[id]&id=$us_tem[id]' title='Анкета $us_tem[login]'>$us_tem[login]</a> ".online($us_tem['id_user'])." <span class='on'>[".vremya($tema['time_create'])."]</span><br />n";
if($tema['up']==1)echo "<img src='img/forum/them_2.png' alt='' class='icon'/>";
if($tema['close']==1)echo "<img src='img/forum/them_1.png' alt='' class='icon'/>";
if($tema['up']==0 && $tema['close']==0)echo "<img src='img/forum/them_0.png' alt='' class='icon'/>";
echo '<b>'.smile(links(bb_code($tema['name']))).'</b></br>';
echo ''.smile(links(bb_code($tema['text']))).'</div>';
}
///
$u_s = mysql_fetch_assoc(mysql_query("SELECT * FROM `soo_users` WHERE `id_soo`='$soo[id]' AND `id_user`='$u[id]'"));
if (isset($_GET['act']) && check($_GET['act'])=='mesto' && isset($u) && $u_s['level']>'0')
{
echo "<form method="post" action="?s=$soo[id]&id_forum=$forum[id]&id_them=$them[id]&act=mesto&ok">n";
echo "Форум:<br />n";
echo "<select name="forum">n";
$q2 = mysql_query("SELECT * FROM `soo_forums` WHERE `id_soo` = '$soo[id]' ORDER BY `name` ASC");
while ($forums = mysql_fetch_assoc($q2))
{
echo "<option".($forum['id']==$forums['id']?' selected="selected"':null)." value='$forums[id]'>$forums[name]</option>n";
}
echo "</select><br />n";
echo "<input value="Переместить" type="submit" /><br />n";
echo "«<a href='?s=$soo[id]&id_forum=$forum[id]&id_them=$them[id]'>Отмена</a><br />n";
echo "</form>n";
}
$u_s = mysql_fetch_assoc(mysql_query("SELECT * FROM `soo_users` WHERE `id_soo`='$soo[id]' AND `id_user`='$u[id]'"));
if (isset($_GET['act']) && check($_GET['act'])=='set' && isset($u) && ($u_s['level']>'0' || $tema['id_user']==$u['id']))
{
echo "<form method='post' action='?s=$soo[id]&id_forum=$forum[id]&id_them=$them[id]&act=set&ok'>n";
echo "Название темы:<br />n";
echo "<input name='name' type='text' maxlength='32' value='$them[name]' /><br />n";
echo "Сообщение:<br />n<textarea name="text">$tema[text]</textarea><br />n";
$u_s = mysql_fetch_assoc(mysql_query("SELECT * FROM `soo_users` WHERE `id_soo`='$soo[id]' AND `id_user`='$u[id]'"));
if ($u_s['level']>'0'){
if ($them['up']==1)$check=' checked="checked"';else $check=NULL;
echo "<label><input type="checkbox"$check name="up" value="1" /> Всегда наверху</label><br />n";
if ($them['close']==1)$check=' checked="checked"';else $check=NULL;
echo "<label><input type="checkbox"$check name="close" value="1" /> Закрыть</label><br />n";
echo "<input value="Изменить" type="submit" /><br />n";
echo "«<a href='?s=$soo[id]&id_forum=$forum[id]&id_them=$them[id]'>Отмена</a><br />n";
echo "</form>n";
}
$u_s = mysql_fetch_assoc(mysql_query("SELECT * FROM `soo_users` WHERE `id_soo`='$soo[id]' AND `id_user`='$u[id]'"));
if (isset($_GET['act']) && $_GET['act']=='del' && isset($u) && $u_s['level']>'0')
{
echo "<div class="err">n";
echo "Подтвердите удаление темы<br />n";
echo "<a href="?s=$soo[id]&id_forum=$forum[id]&id_them=$them[id]&act=delete&ok">Да</a> <a href="?s=$soo[id]&id_forum=$forum[id]&id_them=$them[id]">Нет</a><br />n";
echo "</div>n";
}
if (isset($u) && $u_s['level']>'0' && isset($_GET['act']) && $_GET['act']=='del_post')
{
mysql_query("DELETE FROM `soo_forum_mess` WHERE `id_them` = '$them[id]' AND `id` = '".intval($_GET['id_post'])."' LIMIT 1");
ok('Успешно удалено');
}
$u_s = mysql_fetch_assoc(mysql_query("SELECT * FROM `soo_users` WHERE `id_soo`='$soo[id]' AND `id_user`='$u[id]' LIMIT 1"));
if (!isset($_GET['act']) && isset($u) && $u_s['level']>'0' || ($tema['id_user']==$u['id'] && $tema['time_create']>time()-600)){
echo "<div class="foot">n";
echo "[<a href='?s=$soo[id]&id_forum=$forum[id]&id_them=$them[id]&act=set'>Парам.</a>]n";
echo "[<a href='?s=$soo[id]&id_forum=$forum[id]&id_them=$them[id]&act=mesto'>Перемест.</a>]n";
echo "[<a href='?s=$soo[id]&id_forum=$forum[id]&id_them=$them[id]&act=del'>Удалить</a>]n";
echo "<br /></div>n";
}
}
///
if ($u['id'] && $user_s['level']>'0'){echo "<div class='cred1'>[<a href='?s=$soo[id]&id_forum=$forum[id]&id_them=$them[id]&act=set'>Парам.</a>]n";echo "[<a href='?s=$soo[id]&id_forum=$forum[id]&id_them=$them[id]&act=mesto'>Перемест.</a>]n";echo "[<a href='?s=$soo[id]&id_forum=$forum[id]&id_them=$them[id]&act=del'>Удалить</a>]</div>n";}
if (!isset($_GET['act'])){
$q=mysql_query("SELECT * FROM `soo_forum_mess` WHERE `id_them` = '$them[id]' AND `id_forum` = '$forum[id]' AND `id_soo` = '$soo[id]'");
if (mysql_num_rows($q)==0) {
echo "Нет сообщений в теме "$them[name]"n";
} }
$post_k=$start;
while ($post = mysql_fetch_assoc($q))
{
$ank=$post['id_user'];
$post_k++;
if(@$num==1){
echo "<div class='div'>";
$num=0;
}else{
echo "<div class='div'>";
$num=1;}
$_Us = mysql_query("SELECT * FROM `users` WHERE `id` = '$ank[id_user]' LIMIT 1"); $us = mysql_fetch_assoc($_Us);
$_Sozd = mysql_query("SELECT * FROM `users` WHERE `id` = '$soo[admid]' LIMIT 1");
echo "".ico($us['sex'],$us['admin'])." <a href='info.php?s=$soo[id]&id=$ank[id]' title='Анкета $ank[login]'>".$us['login']."</a> ".online($us['id'])." <span class='on'>[".vremya($post['time'])."]</span><br />n";
echo ''.smile(links(bb_code($post['mess']))).'</br>';
$u_s = mysql_fetch_assoc(mysql_query("SELECT * FROM `soo_users` WHERE `id_soo`='$soo[id]' AND `id_user`='$u[id]' LIMIT 1"));
if (isset($u) && $u_s['level']>'0')
echo "[<a href='?s=$soo[id]&id_forum=$forum[id]&id_them=$them[id]&id_post=$post[id]&act=edit'>Ред.</a>]n";
elseif (isset($u) && $u['id']==$post['id_user'] && $post['time']>$time-600 && $post_k==$k_post)
echo "[<a href='?s=$soo[id]&id_forum=$forum[id]&id_them=$them[id]&id_post=$post[id]&act=edit'>Ред. (".($post['time']+600-time())." сек)</a>]n";
if (isset($u) && $u_s['level']>'0')
echo "[<a href='?s=$soo[id]&id_forum=$forum[id]&id_them=$them[id]&id_post=$post[id]&act=delete'>удал</a>]n";
if ($them['close']==0 && isset($u) && mysql_result(mysql_query("SELECT COUNT(*) FROM `soo_users` WHERE `id_soo` = '$soo[id]' AND `id_user`='$u[id]' AND `invit`='0' AND `activate`='0' LIMIT 1"),0)==1){
echo "[<a href='?s=$soo[id]&id_forum=$forum[id]&id_them=$them[id]&id_post=$post[id]&act=msg' title='Ответить $ank[nick]'>Ответ</a>]<br />n";}
echo "</div>n";
echo " </td>n";
echo " </tr>n";
}
echo "</table>n";
$u_s = mysql_fetch_assoc(mysql_query("SELECT * FROM `soo_users` WHERE `id_soo`='$soo[id]' AND `id_user`='$u[id]' LIMIT 1"));
if (isset($u) && $u_s['level']>'0' && isset($_GET['act']) && $_GET['act']=='post_delete'){}
elseif($page>1)navigation($page, $total,'?s=$soo[id]&id_forum=$forum[id]&id_them=$them[id]&'); // Вывод страниц
if (isset($u) && $u_s['level']>'0' && isset($_GET['act']) && $_GET['act']=='post_delete'){}
elseif (isset($u) && $them['close']==0 && mysql_result(mysql_query("SELECT COUNT(*) FROM `soo_users` WHERE `id_soo` = '$soo[id]' AND `id_user`='$u[id]' AND `invit`='0' AND `activate`='0' LIMIT 1"),0)==1)
{
echo "<div class='nav'><form method='post' name='message' action='?s=$soo[id]&id_forum=$forum[id]&id_them=$them[id]&act=new&$passgen'>n";
echo "Сообщение:<br />n<textarea name="msg">";
echo ''.smile(links(bb_code($_POST['mess']))).'';
echo "</textarea><br />n";
echo "<input name='post' value='Отправить' type='submit' /><br />n";
echo "</form></div>n";
}
echo "<div class="zona">n";
echo "»<a href="/rules.php">Правила</a> /n";
echo "<a href="/smiles.php">Смайлы</a><br />n";
echo "</div>n";
?>