Файл: forum/inc/them.php
Строк: 471
<?
if (isset($_GET['act']) && $_GET['act'] == 'txt') {
ob_clean();
ob_implicit_flush();
header('Content-Type: text/plain; charset=utf-8', true);
header('Content-Disposition: attachment; filename="' . retranslit($them['name']) . '.txt";');
echo "Тема: $them[name] ($forum[name]/$razdel[name])rn";
$q = mysql_query("SELECT * FROM `forum_p` WHERE `id_them` = '$them[id]' AND `id_forum` = '$forum[id]' AND `id_razdel` = '$razdel[id]' ORDER BY `time` ASC");
while ($post = mysql_fetch_assoc($q)) {
echo "rn";
$ank = get_user($post['id_user']);
echo "$ank[nick] (" . date("j M Y в H:i", $post['time']) . ")rn";
if ($post['cit'] != NULL && mysql_result(mysql_query("SELECT COUNT(*) FROM `forum_p` WHERE `id` = '$post[cit]'"), 0) == 1) {
$cit = mysql_fetch_assoc(mysql_query("SELECT * FROM `forum_p` WHERE `id` = '$post[cit]' LIMIT 1"));
$ank_c = get_user($cit['id_user']);
echo "--Цитата--rn";
echo "$ank_c[nick] (" . date("j M Y в H:i", $cit['time']) . "):rn";
echo trim(br(htmlspecialchars($cit['msg']), "rn")) . "rn";
echo "----------rn";
}
echo trim(br(htmlspecialchars($post['msg']), "rn")) . "rn";
}
echo "rnИсточник: http://$_SERVER[SERVER_NAME]/forum/$forum[id]/$razdel[id]/$them[id]/rn";
exit;
}
if (isset($user) && isset($_GET['f_del']) && is_numeric($_GET['f_del']) && isset($_SESSION['file'][$_GET['f_del']])) {
@unlink($_SESSION['file'][$_GET['f_del']]['tmp_name']);
}
if (isset($user) && isset($_GET['zakl']) && $_GET['zakl'] == 1) {
if (mysql_result(mysql_query("SELECT COUNT(*) FROM `bookmarks` WHERE `id_user` = '$user[id]' AND `id_object` = '$them[id]' AND `type`='forum'"), 0) != 0) {
$err[] = "Тема уже есть в ваших закладках";
} else {
mysql_query("INSERT INTO `bookmarks` (`id_user`, `time`, `id_object`, `type`) values('$user[id]', '$time', '$them[id]', 'forum')");
msg('Тема добавлена в закладки');
}
} elseif (isset($user) && isset($_GET['zakl']) && $_GET['zakl'] == 0) {
mysql_query("DELETE FROM `bookmarks` WHERE `id_user` = '$user[id]' AND `id_object` = '$them[id]' AND `type`='forum'");
msg('Тема удалена из закладок');
}
if (isset($user) && isset($_GET['act']) && $_GET['act'] == 'new' && isset($_FILES['file_f']) && preg_match('#.#', $_FILES['file_f']['name']) && isset($_POST['file_s'])) {
copy($_FILES['file_f']['tmp_name'], H . 'sys/tmp/' . $user['id'] . '_' . md5_file($_FILES['file_f']['tmp_name']) . '.forum.tmp');
chmod(H . 'sys/tmp/' . $user['id'] . '_' . md5_file($_FILES['file_f']['tmp_name']) . '.forum.tmp', 0777);
if (isset($_SESSION['file']))
$next_f = count($_SESSION['file']);
else
$next_f = 0;
$file = esc(stripcslashes(htmlspecialchars($_FILES['file_f']['name'])));
$_SESSION['file'][$next_f]['name'] = preg_replace('#.[^.]*$#i', NULL, $file); // имя файла без расширения
$_SESSION['file'][$next_f]['ras'] = strtolower(preg_replace('#^.*.#i', NULL, $file));
$_SESSION['file'][$next_f]['tmp_name'] = H . 'sys/tmp/' . $user['id'] . '_' . md5_file($_FILES['file_f']['tmp_name']) . '.forum.tmp';
$_SESSION['file'][$next_f]['size'] = filesize(H . 'sys/tmp/' . $user['id'] . '_' . md5_file($_FILES['file_f']['tmp_name']) . '.forum.tmp');
$_SESSION['file'][$next_f]['type'] = $_FILES['file_f']['type'];
}
if (isset($user) && ($them['close'] == 0 || $them['close'] == 1 && user_access('forum_post_close')) && isset($_GET['act']) && $_GET['act'] == 'new' && isset($_POST['msg']) && !isset($_POST['file_s'])) {
$msg = $_POST['msg'];
if (strlen2($msg) < 2)
$err = 'Короткое сообщение';
if (strlen2($msg) > 1024)
$err = 'Длина сообщения превышает предел в 1024 символа';
$mat = antimat($msg);
if ($mat)
$err[] = 'В тексте сообщения обнаружен мат: ' . $mat;
if (mysql_result(mysql_query("SELECT COUNT(*) FROM `forum_p` WHERE `id_them` = '$them[id]' AND `id_forum` = '$forum[id]' AND `id_razdel` = '$razdel[id]' AND `id_user` = '$user[id]' AND `msg` = '" . my_esc($msg) . "' LIMIT 1"), 0) != 0)
$err = 'Ваше сообщение повторяет предыдущее';
if (!isset($err)) {
if (isset($_POST['cit']) && is_numeric($_POST['cit']) && mysql_result(mysql_query("SELECT COUNT(*) FROM `forum_p` WHERE `id` = '" . intval($_POST['cit']) . "' AND `id_them` = '" . intval($_GET['id_them']) . "' AND `id_razdel` = '" . intval($_GET['id_razdel']) . "' AND `id_forum` = '" . intval($_GET['id_forum']) . "'"), 0) == 1)
$cit = intval($_POST['cit']);
else
$cit = 'null';
mysql_query("UPDATE `user` SET `balls` = '" . ($user['balls'] + 1) . "' WHERE `id` = '$user[id]' LIMIT 1");
mysql_query("UPDATE `forum_zakl` SET `time_obn` = '$time' WHERE `id_them` = '$them[id]'");
mysql_query("INSERT INTO `forum_p` (`id_forum`, `id_razdel`, `id_them`, `id_user`, `msg`, `time`, `cit`) values('$forum[id]', '$razdel[id]', '$them[id]', '$user[id]', '" . my_esc($msg) . "', '$time', $cit)");
$post_id = mysql_insert_id();
if (isset($_SESSION['file']) && isset($user)) {
for ($i = 0; $i < count($_SESSION['file']); $i++) {
if (isset($_SESSION['file'][$i]) && is_file($_SESSION['file'][$i]['tmp_name'])) {
mysql_query("INSERT INTO `forum_files` (`id_post`, `name`, `ras`, `size`, `type`) values('$post_id', '" . $_SESSION['file'][$i]['name'] . "', '" . $_SESSION['file'][$i]['ras'] . "', '" . $_SESSION['file'][$i]['size'] . "', '" . $_SESSION['file'][$i]['type'] . "')");
$file_id = mysql_insert_id();
copy($_SESSION['file'][$i]['tmp_name'], H . 'sys/forum/files/' . $file_id . '.frf');
unlink($_SESSION['file'][$i]['tmp_name']);
}
}
unset($_SESSION['file']);
}
unset($_SESSION['msg']);
$ank = get_user($them['id_user']); // Определяем автора
mysql_query("UPDATE `user` SET `rating_tmp` = '" . ($user['rating_tmp'] + 1) . "' WHERE `id` = '$user[id]' LIMIT 1");
mysql_query("UPDATE `forum_r` SET `time` = '$time' WHERE `id` = '$razdel[id]' LIMIT 1");
/*
====================================
Обсуждения
====================================
*/
$q = mysql_query("SELECT * FROM `frends` WHERE `user` = '" . $them['id_user'] . "' AND `i` = '1'");
while ($f = mysql_fetch_array($q)) {
$a = get_user($f['frend']);
$discSet = mysql_fetch_array(mysql_query("SELECT * FROM `discussions_set` WHERE `id_user` = '" . $a['id'] . "' LIMIT 1")); // Общая настройка обсуждений
if ($f['disc_forum'] == 1 && $discSet['disc_forum'] == 1) /* Фильтр рассылки */ {
// друзьям автора
if (mysql_result(mysql_query("SELECT COUNT(*) FROM `discussions` WHERE `id_user` = '$a[id]' AND `type` = 'them' AND `id_sim` = '$them[id]' LIMIT 1"), 0) == 0) {
if ($them['id_user'] != $a['id'] || $a['id'] != $user['id'])
mysql_query("INSERT INTO `discussions` (`id_user`, `avtor`, `type`, `time`, `id_sim`, `count`) values('$a[id]', '$them[id_user]', 'them', '$time', '$them[id]', '1')");
}
else {
$disc = mysql_fetch_array(mysql_query("SELECT * FROM `discussions` WHERE `id_user` = '$a[id_user]' AND `type` = 'them' AND `id_sim` = '$them[id]' LIMIT 1"));
if ($them['id_user'] != $a['id'] || $a['id'] != $user['id'])
mysql_query("UPDATE `discussions` SET `count` = '" . ($disc['count'] + 1) . "', `time` = '$time' WHERE `id_user` = '$a[id]' AND `type` = 'them' AND `id_sim` = '$them[id]' LIMIT 1");
}
}
}
// отправляем автору
if (mysql_result(mysql_query("SELECT COUNT(*) FROM `discussions` WHERE `id_user` = '$them[id_user]' AND `type` = 'them' AND `id_sim` = '$them[id]' LIMIT 1"), 0) == 0) {
if ($them['id_user'] != $user['id'] && $them['id_user'] != $ank_otv['id'])
mysql_query("INSERT INTO `discussions` (`id_user`, `avtor`, `type`, `time`, `id_sim`, `count`) values('$them[id_user]', '$them[id_user]', 'them', '$time', '$them[id]', '1')");
}
else {
$disc = mysql_fetch_array(mysql_query("SELECT * FROM `discussions` WHERE `id_user` = '$them[id_user]' AND `type` = 'them' AND `id_sim` = '$them[id]' LIMIT 1"));
if ($them['id_user'] != $user['id'] && $them['id_user'] != $ank_otv['id'])
mysql_query("UPDATE `discussions` SET `count` = '" . ($disc['count'] + 1) . "', `time` = '$time' WHERE `id_user` = '$them[id_user]' AND `type` = 'them' AND `id_sim` = '$them[id]' LIMIT 1");
}
/*
==========================
Уведомления об ответах
==========================
*/
if (isset($user) && $respons == TRUE) {
$notifiacation = mysql_fetch_assoc(mysql_query("SELECT * FROM `notification_set` WHERE `id_user` = '" . $ank_otv['id'] . "' LIMIT 1"));
if ($notifiacation['komm'] == 1)
mysql_query("INSERT INTO `notification` (`avtor`, `id_user`, `id_object`, `type`, `time`) VALUES ('$user[id]', '$ank_otv[id]', '$them[id]', 'them_komm', '$time')");
}
$_SESSION['message'] = 'Сообщение успешно добавлено';
header("Location: ?page=" . intval($_GET['page']) . "");
exit;
}
}
/*
================================
Модуль жалобы на пользователя
и его сообщение либо контент
в зависимости от раздела
================================
*/
if (isset($_GET['spam']) && isset($user)) {
$mess = mysql_fetch_assoc(mysql_query("SELECT * FROM `forum_p` WHERE `id` = '" . intval($_GET['spam']) . "' limit 1"));
$spamer = get_user($mess['id_user']);
if (mysql_result(mysql_query("SELECT COUNT(*) FROM `spamus` WHERE `id_user` = '$user[id]' AND `id_spam` = '$spamer[id]' AND `razdel` = 'forum' AND `spam` = '" . $mess['msg'] . "'"), 0) == 0) {
if (isset($_POST['spamus'])) {
if ($mess['id_user'] != $user['id']) {
$msg = mysql_real_escape_string($_POST['spamus']);
if (strlen2($msg) < 3)
$err = 'Укажите подробнее причину жалобы';
if (strlen2($msg) > 1512)
$err = 'Длина текста превышает предел в 512 символов';
if (isset($_POST['types']))
$types = intval($_POST['types']);
else
$types = '0';
if (!isset($err)) {
mysql_query("INSERT INTO `spamus` (`id_object`, `id_user`, `msg`, `id_spam`, `time`, `types`, `razdel`, `spam`) values('$them[id]', '$user[id]', '$msg', '$spamer[id]', '$time', '$types', 'forum', '" . my_esc($mess['msg']) . "')");
$_SESSION['message'] = 'Заявка на рассмотрение отправлена';
header("Location: /forum/$forum[id]/$razdel[id]/$them[id]/?spam=$mess[id]&page=$pageEnd");
exit;
}
}
}
}
aut();
err();
if (mysql_result(mysql_query("SELECT COUNT(*) FROM `spamus` WHERE `id_user` = '$user[id]' AND `id_spam` = '$spamer[id]' AND `razdel` = 'forum'"), 0) == 0) {
echo "<div class='mess'>Ложная информация может привести к блокировке ника.
Если вас постоянно достает один человек - пишет всякие гадости, вы можете добавить его в черный список.</div>";
echo "<form class='nav1' method='post' action='/forum/$forum[id]/$razdel[id]/$them[id]/?spam=$mess[id]&page=" . intval($_GET['page']) . "'>n";
echo "<b>Пользователь:</b> ";
echo " " . avatar($spamer['id']) . " " . group($spamer['id']) . " <a href="/info.php?id=$spamer[id]">$spamer[nick]</a>n";
echo "" . medal($spamer['id']) . " " . online($spamer['id']) . " (" . vremja($mess['time']) . ")<br />";
echo "<b>Нарушение:</b> <font color='green'>" . output_text($mess['msg']) . "</font><br />";
echo "Причина:<br />n<select name='types'>n";
echo "<option value='1' selected='selected'>Спам/Реклама</option>n";
echo "<option value='2' selected='selected'>Мошенничество</option>n";
echo "<option value='3' selected='selected'>Оскорбление</option>n";
echo "<option value='0' selected='selected'>Другое</option>n";
echo "</select><br />n";
echo "Комментарий:";
echo $tPanel . "<textarea name="spamus"></textarea><br />";
echo "<input value="Отправить" type="submit" />n";
echo "</form>n";
} else {
echo "<div class='mess'>Жалоба на <font color='green'>$spamer[nick]</font> будет рассмотрена в ближайшее время.</div>";
}
echo "<div class='foot'>n";
echo "<img src='/style/icons/str2.gif' alt='*'> <a href='?page=" . intval($_GET['page']) . "'>Назад</a><br />n";
echo "</div>n";
include_once '../sys/inc/tfoot.php';
exit;
}
if ($them['close'] == 1)
$err = 'Тема закрыта для обсуждения';
$k_post = mysql_result(mysql_query("SELECT COUNT(*) FROM `forum_p` WHERE `id_them` = '$them[id]' AND `id_forum` = '$forum[id]' AND `id_razdel` = '$razdel[id]'"), 0);
$k_page = k_page($k_post, $set['p_str']);
$page = page($k_page);
$start = $set['p_str'] * $page - $set['p_str'];
$avtor = get_user($them['id_user']);
err();
aut();
echo "<div class='foot'>";
echo '<a href="/forum/' . $forum['id'] . '/' . $razdel['id'] . '/">' . text($razdel['name']) . '</a> | <b>' . output_text($them['name']) . '</b>';
echo "</div>n";
/*
======================================
Перемещение темы
======================================
*/
if (isset($_GET['act']) && $_GET['act'] == 'mesto' && (user_access('forum_them_edit') || $ank2['id'] == $user['id'])) {
echo "<form method="post" action="/forum/$forum[id]/$razdel[id]/$them[id]/?act=mesto&ok">n";
echo "<div class='mess'>";
echo "Перемещение темы <b>" . output_text($them['name']) . "</b>n";
echo "</div>";
echo "<div class='main'>";
echo "Раздел:<br />n";
echo "<select name="razdel">n";
if (user_access('forum_them_edit')) {
$q = mysql_query("SELECT * FROM `forum_f` ORDER BY `pos` ASC");
while ($forums = mysql_fetch_assoc($q)) {
echo "<optgroup label='$forums[name]'>n";
$q2 = mysql_query("SELECT * FROM `forum_r` WHERE `id_forum` = '$forums[id]' ORDER BY `time` DESC");
while ($razdels = mysql_fetch_assoc($q2)) {
echo "<option" . ($razdel['id'] == $razdels['id'] ? ' selected="selected"' : null) . " value="$razdels[id]">" . text($razdels['name']) . "</option>n";
}
echo "</optgroup>n";
}
} else {
$q2 = mysql_query("SELECT * FROM `forum_r` WHERE `id_forum` = '$forum[id]' ORDER BY `time` DESC");
while ($razdels = mysql_fetch_assoc($q2)) {
echo "<option" . ($razdel['id'] == $razdels['id'] ? ' selected="selected"' : null) . " value='$razdels[id]'>" . text($razdels['name']) . "</option>n";
}
}
echo "</select><br />n";
echo "<input value="Переместить" type="submit" /> n";
echo "<img src='/style/icons/delete.gif' alt='*'> <a href='/forum/$forum[id]/$razdel[id]/$them[id]/'>Отмена</a><br />n";
echo "</form>n";
echo "</div>";
echo "<div class='foot'>";
echo "<img src='/style/icons/str2.gif' alt='*'> <a href='/forum/$forum[id]/$razdel[id]/$them[id]/?'>В тему</a><br />n";
echo "</div>";
include_once '../sys/inc/tfoot.php';
exit;
}
/*
======================================
Редактирование темы
======================================
*/
if (isset($_GET['act']) && $_GET['act'] == 'set' && (user_access('forum_them_edit') || $ank2['id'] == $user['id'])) {
echo "<form method='post' action='/forum/$forum[id]/$razdel[id]/$them[id]/?act=set&ok'>n";
echo "<div class='mess'>";
echo "Редактирование темы <b>" . output_text($them['name']) . "</b>n";
echo "</div>";
echo "<div class="main">n";
echo "Название:<br />n";
echo "<input name='name' type='text' maxlength='32' value='" . text($them['name']) . "' /><br />n";
echo "Сообщение:$tPanel<textarea name="msg">" . text($them['text']) . "</textarea><br />n";
if ($user['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";
if ($ank2['id'] != $user['id']) {
echo "<label><input type="checkbox" name="autor" value="1" /> Забрать у автора права</label><br />n";
}
echo "<input value="Изменить" type="submit" /> n";
echo "<img src='/style/icons/delete.gif' alt='*'> <a href='/forum/$forum[id]/$razdel[id]/$them[id]/'>Отмена</a><br />n";
echo "</form>n";
echo "</div>";
echo "<div class='foot'>";
echo "<img src='/style/icons/str2.gif' alt='*'> <a href='/forum/$forum[id]/$razdel[id]/$them[id]/?'>В тему</a><br />n";
echo "</div>";
include_once '../sys/inc/tfoot.php';
exit;
}
/*
======================================
Опрос
======================================
*/
if (isset($_GET['act']) && $_GET['act'] == 'vote' && (user_access('forum_them_edit') || $ank2['id'] == $user['id'])) {
if (mysql_result(mysql_query("SELECT COUNT(*) FROM `votes_forum` WHERE `them` = '".abs(intval($them['id']))."' LIMIT 1"),0)!=0){
if(isset($_POST['del']) && isset($user)){
mysql_query("UPDATE `forum_t` SET `vote`='',`vote_time`='',`vote_close` ='0' WHERE `id` = '$them[id]' LIMIT 1");
mysql_query("DELETE FROM `votes_forum` WHERE `them` = '$them[id]' ");
mysql_query("DELETE FROM `votes_user` WHERE `them` = '$them[id]' ");
$_SESSION['message'] = 'Опрос удалён!';
header ("Location:/forum/$forum[id]/$razdel[id]/$them[id]/");
}
if(isset($_POST['send']) && isset($user)){
$close=(isset($_POST['close'])? 1: 0);
$text=my_esc($_POST['text']);
if (strlen2($text)<3)$err[] = 'Короткая тема опроса';
if (strlen2($text)>42)$err[] = 'Тема опроса должна быть короче 40 символов';
$mat = antimat($text);
if ($mat)$err[] = 'В теме опроса обнаружен мат: '.$mat;
if(!isset($err)){
mysql_query("UPDATE `forum_t` SET `vote`='$text',`vote_close` ='$close' WHERE `id` = '$them[id]' LIMIT 1");
}
for ($x=1; $x<7; $x++){
$add=my_esc($_POST['vote_'.$x.'']);
if (strlen2($add)>23)$err = 'Вариант опроса № '.$x.' слишком длинный';
if($_POST['vote_1']==NULL || $_POST['vote_2']==NULL )$err = 'Два первых варианта должны быть заполнены';
$mat = antimat($add);
if ($mat)$err = 'В варианте опроса № '.$x.' обнаружен мат: '.$mat;
if(!isset($err)){
mysql_query("UPDATE `votes_forum` SET `var`='$add' WHERE `num` = '$x' LIMIT 1");
$_SESSION['message'] = 'Опрос изменён!';
header ("Location:/forum/$forum[id]/$razdel[id]/$them[id]/");
}
}
}
err();
function sub($str,$ch){
if($ch < strlen($str))
{
$str = iconv('UTF-8','windows-1251',$str );
$str = substr($str ,0,$ch);
$str = iconv('windows-1251','UTF-8',$str );
$str .='...';
}
return $str;
}
echo "<form method='post' action='/forum/$forum[id]/$razdel[id]/$them[id]/?act=vote'>";
echo "<div class='nav1'>";
echo "<img src='/style/icons/rating.png' alt='*'> Опрос: <b>" .(mb_strlen($them['vote'])<=15 ? output_text($them['vote']) : output_text(sub($them['vote'],15))). "</b></br>";
echo "</div>";
echo "<div class='main'>";
echo "<b>Тема опроса</b>: <div style='border-top: 1px dashed red; padding: 2px;'>".$tPanel."<textarea name='text'>" . output_text($them['vote']) . "</textarea></div>";
$q=mysql_query("SELECT * FROM `votes_forum` WHERE `them` = '".abs(intval($them['id']))."' ORDER BY `id` ASC LIMIT 6");
while ($row = mysql_fetch_assoc($q)){
echo "Вариант № $row[num] <div style='border-top: 1px dashed red; padding: 2px;'><input name='vote_$row[num]' type='text' value='".(isset($row['var'])? output_text($row['var']):NULL)."' maxlength='24' placeholder='Не заполнено' /></div>";
}
echo "<label><input type='checkbox' name='close' ".($them['vote_close']=='1'? "checked='checked' value='1' /> Открыть опроc" : "value='1'/> Закрыть опрос")." </label>
";
echo '<input value="Изменить" name="send" type="submit" />
<input value="Удалить опрос" name="del" type="submit" />
</form>';
}
else
{
if(isset($_POST['send']) && isset($user)){
$text=my_esc($_POST['text']);
if (strlen2($text)<3)$err[] = 'Короткая тема опроса';
if (strlen2($text)>42)$err[] = 'Тема опроса должна быть короче 40 символов';
$mat = antimat($text);
if ($mat)$err[] = 'В теме опроса обнаружен мат: '.$mat;
if(!isset($err)){
mysql_query("UPDATE `forum_t` SET `vote`='$text',`vote_close` ='0' WHERE `id` = '$them[id]' LIMIT 1");
}
for ($x=1; $x<7; $x++){
$add=my_esc($_POST['add_'.$x.'']);
if (strlen2($add)>23)$err = 'Вариант опроса № '.$x.' слишком длинный';
if($_POST['add_1']==NULL || $_POST['add_2']==NULL )$err = 'Два первых варианта должны быть заполнены';
$mat = antimat($add);
if ($mat)$err = 'В варианте опроса № '.$x.' обнаружен мат: '.$mat;
if(!isset($err)){
mysql_query("INSERT INTO `votes_forum` (`them`,`var`,`num`) values('$them[id]','$add','$x')");
$_SESSION['message'] = 'Опрос добавлен!';
header ("Location:/forum/$forum[id]/$razdel[id]/$them[id]/");
}
}
}
err();
echo "<form method='post' action='/forum/$forum[id]/$razdel[id]/$them[id]/?act=vote'>";
echo "<div class='main'>";
echo 'Тема опроса:'.$tPanel.'<textarea name="text"></textarea>
';
for ($x=1; $x<7; $x++)
echo "Вариант № $x <div style='border-top: 1px dashed red; padding: 2px;'><input name='add_$x' type='text' maxlength='15' placeholder='Не заполнено' /></div>";
echo '<input value="Добавить" type="submit" name="send" /> </form>';
}
echo "<img src='/style/icons/delete.gif' alt='*'> <a href='/forum/$forum[id]/$razdel[id]/$them[id]/'>Отмена</a>
";
echo "</form>";
echo "</div>";
echo "<div class='foot'>";
echo "<img src='/style/icons/str2.gif' alt='*'> <a href='/forum/$forum[id]/$razdel[id]/$them[id]/?'>В тему</a>
";
echo "</div>";
include_once '../sys/inc/tfoot.php';
exit;
}
if (isset($_GET['vote_user']) && mysql_result(mysql_query("SELECT COUNT(*) FROM `votes_user` WHERE `var` = '".intval($_GET['vote_user'])."' AND `them`='$them[id]' "),0)!=0 ) {
$us=intval($_GET['vote_user']);
$k_post = mysql_result(mysql_query("SELECT COUNT(*) FROM `votes_user` WHERE `var` = '$us' AND `them`='$them[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 `votes_user` WHERE `var` = '$us' AND `them`='$them[id]' ORDER BY `time` LIMIT $start, $set[p_str] ");
while ($row = mysql_fetch_assoc($q)){
$ank=get_user($row['id_user']);
echo "<table class='post'>";
if ($num==0){
echo '<div class="nav1">';
$num=1;
}
elseif ($num==1){
echo '<div class="nav2">';
$num=0;
}
echo avatar($ank['id']).group($ank['id']).' ';
echo user::nick($ank['id'],1,1,1).' '.vremja($row['time']).'</div>';
}
if ($k_page > 1)
str("/forum/$forum[id]/$razdel[id]/$them[id]/?vote_user=$us&", $k_page, $page);
echo "<div class='foot'>";
echo "<img src='/style/icons/fav.gif' alt='*'> <a href='/forum/$forum[id]/$razdel[id]/$them[id]/?'>В тему</a>
n";
echo "</div>";
include_once '../sys/inc/tfoot.php';
exit;
}
if (user_access('forum_post_ed') && isset($_GET['del'])) { // удаление поста
mysql_query("DELETE FROM `forum_p` WHERE `id` = '" . intval($_GET['del']) . "' LIMIT 1");
$_SESSION['message'] = 'Сообщение успешно удалено';
header("Location: /forum/$forum[id]/$razdel[id]/$them[id]/?page=" . intval($_GET['page']) . "");
exit;
}
/*
======================================
Удаление темы
======================================
*/
if (isset($_GET['act']) && $_GET['act'] == 'del' && user_access('forum_them_del') && ($ank2['level'] <= $user['level'] || $ank2['id'] == $user['id'])) {
echo "<div class="mess">n";
echo "Подтвердите удаление темы <b>" . output_text($them['name']) . "</b><br />n";
echo "</div>n";
echo "<div class="main">n";
echo "[<a href="/forum/$forum[id]/$razdel[id]/$them[id]/?act=delete&ok"><img src='/style/icons/ok.gif' alt='*'> Да</a>] [<a href="/forum/$forum[id]/$razdel[id]/$them[id]/"><img src='/style/icons/delete.gif' alt='*'> Нет</a>]<br />n";
echo "</div>n";
echo "<div class='foot'>";
echo "<img src='/style/icons/fav.gif' alt='*'> <a href='/forum/$forum[id]/$razdel[id]/$them[id]/?'>В тему</a><br />n";
echo "</div>";
include_once '../sys/inc/tfoot.php';
exit;
}
if (isset($_POST['go']) && isset($_POST['vote']) && isset($user)) {
$vote=abs(intval($_POST['vote']));
if (mysql_result(mysql_query("SELECT COUNT(*) FROM `votes_user` WHERE `them` = '".abs(intval($them['id']))."' AND `id_user`='$user[id]' LIMIT 1"),0)==0 && $them['vote_close']!='1' && $them['close']=='0'){
mysql_query("INSERT INTO `votes_user` (`them`,`id_user`,`var`,`time`) values('$them[id]','$user[id]','$vote','".time()."')");
$_SESSION['message'] = 'Ваш голос принят!';
header ("Location:/forum/$forum[id]/$razdel[id]/$them[id]/");
}
else
{
$_SESSION['message'] = 'Ошибка !';
header ("Location:/forum/$forum[id]/$razdel[id]/$them[id]/");
}
}
create::them($them['id']);
if (isset($user) && (((!isset($_GET['act']) || $_GET['act'] != 'post_delete') && (user_access('forum_post_ed') || $ank2['id'] == $user['id'])) || ((user_access('forum_them_edit') || $ank2['id'] == $user['id'])) || (user_access('forum_them_del') || $ank2['id'] == $user['id']))) {
echo "<div class="nav2"><img src='/style/icons/settings.gif'><span style='float:right;'>n";
if (user_access('forum_them_edit') || $ank2['id'] == $user['id']) {
echo "<a href='/forum/$forum[id]/$razdel[id]/$them[id]/?act=mesto'>Перем.</a> / n";
echo "<a href='/forum/$forum[id]/$razdel[id]/$them[id]/?act=set'>Ред. </a> / n";
echo " <a href='/forum/$forum[id]/$razdel[id]/$them[id]/?act=vote'> Опрос </a> ";
}
if (user_access('forum_them_del') || $ank2['id'] == $user['id']) {
echo " / <a href='/forum/$forum[id]/$razdel[id]/$them[id]/?act=del'>Удал. </a>n";
}
echo "</span><br/></div>n";
}
echo "<div class='foot'><b>Комментарии:</b> </div>";
/* ------------сортировка по времени-------------- */
if (isset($user)) {
echo "<div id='comments' class='menus'>";
echo "<div class='webmenu'>";
echo "<a href='/forum/$forum[id]/$razdel[id]/$them[id]/?page=$page&sort=1' class='" . ($user['sort'] == 1 ? 'activ' : '') . "'>Внизу</a>";
echo "</div>";
echo "<div class='webmenu'>";
echo "<a href='/forum/$forum[id]/$razdel[id]/$them[id]/?page=$page&sort=0' class='" . ($user['sort'] == 0 ? 'activ' : '') . "'>Вверху</a>";
echo "</div>";
echo "</div>";
}
/* ---------------alex-borisi--------------------- */
if ((user_access('forum_post_ed') || isset($user) && $ank2['id'] == $user['id']) && isset($_GET['act']) && $_GET['act'] == 'post_delete') {
$lim = NULL;
} else
$lim = " LIMIT $start, $set[p_str]";
$q = mysql_query("SELECT * FROM `forum_p` WHERE `id_them` = '$them[id]' AND `id_forum` = '$forum[id]' AND `id_razdel` = '$razdel[id]' ORDER BY `time` $sort$lim");
if (mysql_num_rows($q) == 0) {
echo "<div class='mess'>";
echo "Нет сообщений в темеn";
echo "</div>";
}
while ($post = mysql_fetch_assoc($q)) {
$ank = get_user($post['id_user']);
/* -----------зебра----------- */
if ($num == 0) {
echo '<div class="nav1">';
$num = 1;
} elseif ($num == 1) {
echo '<div class="nav2">';
$num = 0;
}
/* --------------------------- */
if ((user_access('forum_post_ed') || isset($user) && $ank2['id'] == $user['id']) && isset($_GET['act']) && $_GET['act'] == 'post_delete') {
echo '<input type="checkbox" name="post_' . $post['id'] . '" value="1" />';
}
echo user::avatar($post['id_user'], 2) . user::nick($post['id_user'], 1, 1, 1);
echo ' <span style="float:right;color:#666">' . vremja($post['time']) . '</span><br />';
$postBan = mysql_result(mysql_query("SELECT COUNT(*) FROM `ban` WHERE (`razdel` = 'all' OR `razdel` = 'forum') AND `post` = '1' AND `id_user` = '$ank[id]' AND (`time` > '$time' OR `navsegda` = '1')"), 0);
if ($postBan == 0) { // Блок сообщения
if ($them['id_user'] == $post['id_user']) // Отмечаем автора темы
echo '<font color="green">Автор темы</font><br />';
# Цитирование поста
if ($post['cit'] != NULL && mysql_result(mysql_query("SELECT COUNT(*) FROM `forum_p` WHERE `id` = '$post[cit]'"), 0) == 1) {
$cit = mysql_fetch_assoc(mysql_query("SELECT * FROM `forum_p` WHERE `id` = '$post[cit]' LIMIT 1"));
$ank_c = get_user($cit['id_user']);
echo '<div class="cit">
<b>' . $ank_c['nick'] . ' (' . vremja($cit['time']) . '):</b><br />
' . output_text($cit['msg']) . '<br />
</div>';
}
echo output_text($post['msg']) . '<br />'; // Посты темы
echo '<table>';
include H . '/forum/inc/file.php'; // Прекрепленные файлы
echo '</table>';
} else {
echo output_text($banMess) . '<br />';
}
if (isset($user)) {
if ($them['close'] == 0) {
if (isset($user) && $user['id'] != $ank['id'] && $ank['id'] != 0) { // Кроме автора поста и системы
echo ' <a href="/forum/' . $forum['id'] . '/' . $razdel['id'] . '/' . $them['id'] . '/?response=' . $ank['id'] . '&page=' . $page . '" title="Ответить ' . $ank['nick'] . '">Ответ</a> | ';
echo '<a href="/forum/' . $forum['id'] . '/' . $razdel['id'] . '/' . $them['id'] . '/' . $post['id'] . '/cit" title="Цитировать ' . $ank['nick'] . '">Цитата</a> ';
}
}
echo '<span style="float:right;">';
if (user_access('forum_post_ed') && ($ank['level'] <= $user['level'] || $ank['level'] == $user['level'] && $ank['id'] == $user['id'])) // Редактирование поста
echo " <a href="/forum/$forum[id]/$razdel[id]/$them[id]/$post[id]/edit" title='Изменить пост $ank[nick]'>".($webbrowser ? "Редакт." : "<img src='/style/icons/edit_post.png'>")."</a> n";
elseif ($user['id'] == $post['id_user'] && $post['time'] > time() - 600) // Редактирование поста если не прошло 10 минут
echo " | <a href="/forum/$forum[id]/$razdel[id]/$them[id]/$post[id]/edit" title='Изменить мой пост'>".($webbrowser ? "Ред." : "<img src='/style/icons/edit_post.png'>")." (" . ($post['time'] + 600 - time()) . " с)</a> n";
if (isset($user) && $user['id'] != $ank['id'] && $ank['id'] != 0) { // Кроме автора поста и системы
echo " | <a href="/forum/$forum[id]/$razdel[id]/$them[id]/?spam=$post[id]&page=$page" title='Это спам'>".($webbrowser ? "<font color='#666'>Жалоба</font>" : "<img src='/style/icons/blackList.gif'>")."</a>n";
}
if (user_access('forum_post_ed')) { // удаление поста
echo " | <a href="/forum/$forum[id]/$razdel[id]/$them[id]/?del=$post[id]&page=$page" title='Удалить'>".($webbrowser ? "Удал." : "<img src='/style/icons/cross_r.gif'>")."</a>n";
}
echo '</span><br/>';
}
echo '</div>';
}
echo ' </div>';
if ((user_access('forum_post_ed') || isset($user) && $ank2['id'] == $user['id']) && isset($_GET['act']) && $_GET['act'] == 'post_delete') {
} elseif ($k_page > 1)
str("/forum/$forum[id]/$razdel[id]/$them[id]/?", $k_page, $page); // Вывод страниц
if ((user_access('forum_post_ed') || isset($user) && $ank2['id'] == $user['id']) && isset($_GET['act']) && $_GET['act'] == 'post_delete') {
} elseif (isset($user) && ($them['close'] == 0 || $them['close'] == 1 && user_access('forum_post_close'))) {
if (isset($user)) {
echo "<div class='foot'>";
echo 'Новое сообщение:';
echo "</div>";
}
if ($user['set_files'] == 1)
echo "<form method='post' name='message' enctype='multipart/form-data' action='/forum/$forum[id]/$razdel[id]/$them[id]/new?page=$page&$passgen&" . $go_otv . "'>n";
else
echo "<form method='post' name='message' action='/forum/$forum[id]/$razdel[id]/$them[id]/new?page=$page&$passgen&" . $go_otv . "'>n";
if (isset($_POST['msg']) && isset($_POST['file_s']))
$msg2 = output_text($_POST['msg'], false, true, false, false, false);
else
$msg2 = NULL;
if ($set['web'] && is_file(H . 'style/themes/' . $set['set_them'] . '/altername_post_form.php'))
include H . 'style/themes/' . $set['set_them'] . '/altername_post_form.php';
else
echo "$tPanel<textarea name="msg">$otvet$msg2</textarea><br />n";
if ($user['set_files'] == 1) {
if (isset($_SESSION['file'])) {
echo "Прикрепленные файлы:<br />n";
for ($i = 0; $i < count($_SESSION['file']); $i++) {
if (isset($_SESSION['file'][$i]) && is_file($_SESSION['file'][$i]['tmp_name'])) {
echo "<img src='/style/themes/$set[set_them]/forum/14/file.png' alt='' />n";
echo $_SESSION['file'][$i]['name'] . '.' . $_SESSION['file'][$i]['ras'] . ' (';
echo size_file($_SESSION['file'][$i]['size']);
echo ") <a href='/forum/$forum[id]/$razdel[id]/$them[id]/d_file$i' title='Удалить из списка'><img src='/style/themes/$set[set_them]/forum/14/del_file.png' alt='' /></a>n";
echo "<br />n";
}
}
}
echo "<input name='file_f' type='file' /><br />n";
echo "<input name='file_s' value='Прикрепить файл' type='submit' /><br />n";
}
echo '<input name="post" value="Отправить" type="submit" /><br />
</form>';
}
echo "<div class="foot">n";
if ((!isset($_GET['act']) || $_GET['act']!='post_delete') && (user_access('forum_post_ed') || (isset($user) && $ank2['id']==$user['id']))){
echo "<a href='/forum/$forum[id]/$razdel[id]/$them[id]/?act=post_delete'><img src='/style/forum/inc/trun.png' alt='*'></a> | n";
}
echo '<a href="txt"><img src="/style/forum/inc/txt.png" alt="*"></a> ';
echo "</div>n";
?>