Файл: pages/forum/topic.php
Строк: 709
<?php
include '../../system/mysql.php';
include '../../system/sys_func.php';
$them = mysql_fetch_array(mysql_query("SELECT * FROM `f_theme` WHERE `id` = '". intval($_GET['id']) ."'"));
$cat = mysql_fetch_array(mysql_query("SELECT * FROM `f_category` WHERE `id` = '". $them['cat_id'] ."'"));
$forum = mysql_fetch_array(mysql_query("SELECT * FROM `forum` WHERE `id` = '". $them['forum_id'] ."'"));
// Проверяем существование темы
if (!isset($_GET['id']) || isset($_GET['id']) && mysql_result(mysql_query("SELECT COUNT(*) FROM `f_theme` WHERE `id` = '". $them['id'] ."'"), 0) != 1) {
$title = 'Форум/Ошибка';
include '../../system/head.php';
echo '<div class="title"><a href="/pages/forum/">Форум</a> / Ошибка</div>
<div class="err">Такой темы не существует!</div>
<a class="link" href="index.php"><img src="/design/imgs/arr_b.png" align="center"> Форум</a>';
include '../../system/foot.php';
exit;
}
switch ($_GET['menu']) {
default:
if (isset($user) && mysql_result(mysql_query("SELECT COUNT(*) FROM `f_views` WHERE `id_user` = '". $user['id'] ."' AND `id_them` = '". $them['id'] ."' LIMIT 1"), 0) == 0) {
mysql_query("INSERT INTO `f_views` SET `id_them` = '". $them['id'] ."', `id_user` = '". $user['id'] ."', `time` = '". time() ."'");
mysql_query("UPDATE `f_theme` SET `views` = '". ($them['views']+1) ."' WHERE `id` = '". $them['id'] ."' LIMIT 1");
header('Location: ?menu=view&id='. intval($_GET['id']) .'&page=end');
}
if (isset($user) && mysql_result(mysql_query("SELECT COUNT(*) FROM `f_views` WHERE `id_user` = '". $user['id'] ."' AND `id_them` = '". $them['id'] ."' LIMIT 1"), 0) == 1) {
mysql_query("UPDATE `f_views` SET `time` = '". time() ."' WHERE `id_them` = '". $them['id'] ."' AND `id_user` = '". $user['id'] ."' LIMIT 1");
}
// Добавляем комментарий
$error = false;
$errort = '';
if (isset($_POST['add'])) {
$msg = htmlspecialchars(mysql_real_escape_string($_POST['msg']));
if (strlen($msg) < 1) {
$error = true;
$errort .= '<div class="err">Длина сообщения должна быть не менее 1-ого символа.</div>';
} elseif (strlen($msg) > 20000) {
$error = true;
$errort .= '<div class="err">Длина сообщения должна быть не более 2000 символов.</div>';
}
if (!$error) {
mysql_query("INSERT INTO `f_post` (`forum_id`, `cat_id`, `them_id`, `id_user`, `msg`, `time`) values('". $forum['id'] ."', '". $cat['id'] ."', '". $them['id'] ."', '$user[id]', '$msg', '". time() ."')");
mysql_query("UPDATE `f_theme` SET `forum_id` = '". $forum['id'] ."', `cat_id` = '". $cat['id'] ."', `last_post` = '". time() ."' WHERE `id` = '". $them['id'] ."'");
if($user['pol'] == 1) $pol = 'Оставил';
else $pol = 'Оставила';
if ($user['id'] != $them['id_user']) mysql_query("INSERT INTO `notifications` (`user_id`, `from_id`, `msg`, `message`, `time`) values('". $them['id_user'] ."', '". $user['id'] ."', '". $pol ." сообщение в вашей теме "<a href="/pages/forum/topic.php?id=". $them['id'] ."">". $them['name'] ."</a>".', '". $msg ."', '". time() ."')");
$bon_rand = rand(1, 5);
mysql_query("UPDATE `users` SET `bonus` = '". ($user['bonus']+$bon_rand) ."' WHERE `id` = '". $user['id'] ."'");
header('Location: ?id='. $them['id'] .'&page=end');
exit;
}
}
$title = 'Форум/'. $them['name'];
include '../../system/head.php';
echo '<div class="title"><a href="index.php">Форум</a> / <a href="category.php?id='. $forum['id'] .'">'. $forum['name'] .'</a> / <a href="topics.php?id='. $cat['id'] .'">'. $cat['name'] .'</a> / '. $them['name'] .'</div>';
echo $errort;
// Далее идёт вывод информации
$who_in = mysql_result(mysql_query("SELECT COUNT(*) FROM `f_views` WHERE `id_them` = '". $them['id'] ."' AND `time` > '". (time()-300) ."'"), 0);
echo '<a class="link" href="/pages/forum/topic.php?menu=action&id='. $them['id'] .'&who_in">Кто в теме: '. $who_in .'</a>';
$ank = mysql_fetch_array(mysql_query("SELECT * FROM `users` WHERE `id` = '". $them['id_user'] ."'"));
echo '<div class="post">
<span class="c_date">'. ptime($them['time']) .'</span>
<table cellpadding="0" cellspacing="0">
<tr>
<td>';
avatar($ank['id'], 'b');
echo ' </td>
<td>';
echo online($ank['id']);
echo '<a href="/pages/users/user.php?name='. $ank['login'] .'">'. $ank['login'] .'</a>';
echo user($ank['id']);
echo '</td>
</tr>
</table>
<hr>';
echo ' <b>'. output($them['name']) .'</b>';
if ($them['close']==1) {
echo ' <img src="/design/imgs/topic_locked.gif" alt="top" />';
}
echo '<br>';
echo output($them['msg']);
echo '</div>';
if ($them['close'] == 1 && $them['who_close'] != NULL) {
echo '<div class="post">';
$who = mysql_fetch_assoc(mysql_query("SELECT * FROM `users` WHERE `login` = '$them[who_close]' LIMIT 1"));
echo 'Тема закрыта <a href="/pages/users/user.php?name='. $who['login'] .'">'. $who['login'] .'</a>
</div>';
}
if ($user['position'] == 'admin' || $user['position'] == 'mod_f') echo '<a class="link" href="?id='. $them['id'] .'&menu=edit">Редактировать</a>';
if ($user['position'] == 'admin' || $user['position'] == 'mod_f') {
echo '<div class="post_sys">';
if ($them['close'] == 0) {
echo '[<a href="?id='. $them['id'] .'&menu=action&close">Закрыть</a>] ';
} elseif ($them['close'] == 1) {
echo '[<a href="?id='. $them['id'] .'&menu=action&open">Открыть</a>] ';
}
if ($them['fix'] == 0) {
echo '[<a href="?id='. $them['id'] .'&menu=action&fasten">Закрепить</a>] ';
} elseif ($them['fix'] == 1) {
echo '[<a href="?id='. $them['id'] .'&menu=action&undock">Открепить</a>] ';
}
if ($user['position'] == 'admin' || $user['position'] == 'mod_f') echo '[<a href="?id='. $them['id'] .'&menu=action&move">Переместить</a>]';
echo '</div>';
}
echo '<a class="link" href="/pages/forum/topic.php?menu=action&id='. $them['id'] .'&who_looked">Просмотров: '. $them['views'] .'</a>';
$c_p = mysql_result(mysql_query("SELECT COUNT(*) FROM `f_post` WHERE `forum_id` = '". $forum['id'] ."' AND `cat_id` = '". $cat['id'] ."' AND `them_id` = '". $them['id'] ."'"), 0);
// Комментарии
if (isset($user)) $p_page = $user['p_page'];
else $p_page = '10';
$k_page = k_page($c_p, $p_page);
$page = page($k_page);
$start = $p_page*$page-$p_page;
if ($c_p == 0) {
echo '<div class="post">
Нет комментариев
</div>';
} else {
echo '<div class="post">
<b>Комментарии</b> ('. $c_p .')
</div>';
}
$q = mysql_query("SELECT * FROM `f_post` WHERE `forum_id` = '". $forum['id'] ."' AND `cat_id` = '". $cat['id'] ."' AND `them_id` = '". $them['id'] ."' ORDER BY `time` DESC LIMIT $start, ". $p_page);
while ($post = mysql_fetch_assoc($q)) {
$ank = mysql_fetch_assoc(mysql_query("SELECT * FROM `users` WHERE `id` = '". $post['id_user'] ."' LIMIT 1"));
$reply = mysql_fetch_array(mysql_query("SELECT `login` FROM `users` WHERE `id` = '". $post['reply'] ."' LIMIT 1"));
if ($post['hide'] == NULL) {
echo '<div class="post">
<span class="c_date">'. ptime($post['time']) .'</span>
<table cellpadding="0" cellspacing="0">
<tr>
<td>';
avatar($ank['id']);
echo ' </td><td>';
echo online($ank['id']);
echo '<a href="/pages/users/user.php?name='. $ank['login'] .'">'. $ank['login'] .'</a>';
echo user($ank['id']);
// like к посту
if (mysql_result(mysql_query("SELECT COUNT(*) FROM `like_f_post` WHERE `forum_id` = '". $forum['id'] ."' AND `cat_id` = '". $cat['id'] ."' AND `them_id` = '". $them['id'] ."' AND `post_id` = '".$post['id']."' AND `id_user` = '".$user['id']."'"), 0)==0 && $user['id'] != $post['id_user']){
echo ' <a href="?id='. $them['id'] .'&menu=action&like='.$post['id'].'&klike=1">-1</a> | <a href="?id='. $them['id'] .'&menu=action&like='.$post['id'].'&klike=0">+1</a> ';
}
echo ' (<font color="red">'.mysql_result(mysql_query("SELECT COUNT(*) FROM `like_f_post` WHERE `forum_id` = '". $forum['id'] ."' AND `cat_id` = '". $cat['id'] ."' AND `them_id` = '". $them['id'] ."' AND `post_id` = '".$post['id']."' AND `like` = '1'"), 0).'</font>/<font color="green">'.mysql_result(mysql_query("SELECT COUNT(*) FROM `like_f_post` WHERE `forum_id` = '". $forum['id'] ."' AND `cat_id` = '". $cat['id'] ."' AND `them_id` = '". $them['id'] ."' AND `post_id` = '".$post['id']."' AND `like` = '0'"), 0).'</font>) ';
echo '</td>
</tr>
</table>
<hr>';
if ($post['reply'] != NULL) echo 'Ответ <a href="/pages/users/user.php?name='. $reply['login'] .'"><b>'. $reply['login'] .'</b></a>:<br>';
if ($post['quote'] != NULL) echo '<div class="quote">Цитата:<br>'. htmlspecialchars_decode($post['quote']) .'</div>';
echo output($post['msg']);
if ($user['position']== 'admin' || $user['position'] == 'mod_f' || $them['close'] == 0 && isset($user)) {
echo '<br><br>';
if ($user['id'] != $post['id_user']) echo '[<a href="?id='. $them['id'] .'&menu=action&reply='. $post['id'] .'">Отв</a>]';
echo ' [<a href="?id='. $them['id'] .'&menu=action"e='. $post['id'] .'">Цит</a>]';
if ($user['position']== 'admin' || $user['position'] == 'mod_f') {
echo ' [<a href="?id='. $them['id'] .'&menu=action&delete='. $post['id'] .'">Удал</a>]';
echo ' [<a href="?id='. $them['id'] .'&menu=action&hide='. $post['id'] .'">Скр</a>]';
}
}
echo '</div>';
} else {
echo '<div class="post_sys">
<span class="c_date">'. ptime($post['time']) .'</span>
<table cellpadding="0" cellspacing="0">
<tr>
<td>';
avatar($ank['id']);
echo ' </td><td>';
echo online($ank['id']);
echo '<a href="?id='. $them['id'] .'&menu=action&post='. $post['id'] .'">'. $ank['login'] .'</a>';
echo user($ank['id']);
if ($user['position']== 'admin' || $user['position'] == 'mod_f') {
echo '<br>Комментарий скрыл <a href="/pages/users/user.php?name='. $post['hide'] .'">'. $post['hide'] .'</a>.
</td>
</tr>
</table>
<hr>';
if ($post['reply'] != NULL) echo '<span style="color:gray">Ответ</span> <a href="/pages/users/user.php?name='. $reply['login'] .'"><b>'. $reply['login'] .'</b></a>:<br>';
if ($post['quote'] != NULL) echo '<div class="quote">Цитата:<br>'. htmlspecialchars_decode($post['quote']) .'</div>';
echo output($post['msg']);
} else {
echo '<br>Комментарий скрыт
</td>
</tr>
</table>';
}
if ($user['position']== 'admin' || $user['position'] == 'mod_f') {
echo '<br><br>';
if ($user['id'] != $post['id_user']) echo '[<a href="?id='. $them['id'] .'&menu=action&reply='. $post['id'] .'">Отв</a>]';
echo ' [<a href="?id='. $them['id'] .'&menu=action"e='. $post['id'] .'">Цит</a>]';
echo ' [<a href="?id='. $them['id'] .'&menu=action&delete='. $post['id'] .'">Удал</a>]';
echo ' [<a href="?id='. $them['id'] .'&menu=action&hide='. $post['id'] .'">Показ</a>]';
}
echo '</div>';
}
}
if ($k_page > 1) str('?id='. $them['id'] .'&', $k_page, $page);
// Форма для ввода комментария
if (isset($user)) {
if ($user['position']== 'admin' || $user['position'] == 'mod_f' || $them['close'] == 0) {
echo '<form method="post" name="message">';
include '../../system/bbcodes.php';
echo '<textarea class="resize" name="msg"></textarea><br>';
include '../../system/smiles.php';
echo '<input value="Добавить" type="submit" name="add" />';
echo '</form>';
}
} else {
echo '<div class="err">Чтобы оставлять комментарии, вы должны <a href="/pages/registration/">зарегистрироваться</a> или <a href="/pages/registration/?menu=login">авторизоваться</a>!</div>';
}
if ($user['position'] == 'admin' || $user['id'] == $them['id_user']){
echo '<a class="link" href="?id='. $them['id'] .'&menu=action&truncate"><img src="/design/imgs/delete.png" /> Очистить тему от комментариев</a>';
}
echo '<a class="link" href="topics.php?id='. $cat['id'] .'"><img src="/design/imgs/arr_b.png" align="center"> '. $cat['name'] .'</a>
<a class="link" href="category.php?id='. $forum['id'] .'"><img src="/design/imgs/arr_b.png" align="center"> '. $forum['name'] .'</a>
<a class="link" href="index.php"><img src="/design/imgs/arr_b.png" align="center"> Разделы</a>';
include '../../system/foot.php';
break;
case 'edit':
if ($user['position'] == 'admin' || $user['position'] == 'mod_f') {
// Удаляем тему
if (isset($_GET['del'])) {
if (isset($_POST['yes'])) {
mysql_query("DELETE FROM `f_theme` WHERE `id` = '". $them['id'] ."'");
mysql_query("DELETE FROM `f_post` WHERE `them_id` = '". $them['id'] ."'");
header('Location: topics.php?id='. $cat['id'] .'');
exit;
}
$title = 'Форум/Удаление темы';
include '../../system/head.php';
echo '<div class="title"><a href="/pages/forum/">Форум</a> / Удаление темы</div>
<form method="post">
Вы уверены что хотите удалить эту тему со всеми комментариями?<br>
<input type="submit" name="yes" value="Да" /> <a href="?id='. $them['id'] .'&menu=edit">Нет</a>
</form>';
include '../../system/foot.php';
}
// Сохраняем изменённые данные
$error = false;
$errort = '';
if (isset($_POST['change'])) {
$name = filter($_POST['name']);
$msg = filter($_POST['msg']);
if (string($name) < 1) {
$error = true;
$errort .= '<div class="err">Длина имени должна быть не менее 1-ого символа.</div>';
} elseif (string($name) > 64) {
$error = true;
$errort .= '<div class="err">Длина имени должна быть не более 64-х символов.</div>';
}
if (string($msg) < 1) {
$error = true;
$errort .= '<div class="err">Длина сообщения должна быть не менее 1-ого символа.</div>';
} elseif (string($msg) > 20000) {
$error = true;
$errort .= '<div class="err">Длина сообщения должна быть не более 20 000 символов.</div>';
}
if (!$error) {
mysql_query("UPDATE `f_theme` SET `name` = '$name', `msg` = '$msg' WHERE `id` = '". $them['id'] ."'");
header('Location: ?id='. $them['id']);
exit;
}
}
$title = 'Форум/Редактирование темы';
include '../../system/head.php';
echo '<div class="title"><a href="/forum/">Форум</a> / <a href="category.php?id='. $forum['id'] .'">'. $forum['name'] .'</a> / <a href="topics.php?id='. $cat['id'] .'">'. $cat['name'] .'</a> / <a href="?id='. $them['id'] .'">'. $them['name'] .'</a> / Редактирование темы</div>';
echo $errort;
echo '<form method="post" name="message">
<b>Имя темы</b>:<br><input type="text" name="name" value="'. $them['name'] .'"><br>
<b>Сообщение темы</b>:<br>';
include '../../system/bbcodes.php';
echo '<textarea class="resize" name="msg">'. $them['msg'] .'</textarea><br>';
include '../../system/smiles.php';
echo '<input value="Изменить" type="submit" name="change" />
</form>';
echo '<a class="link" href="?id='. $them['id'] .'&menu=edit&del"><img src="/design/imgs/delete.png"> Удалить тему</a>';
echo '<a class="link" href="?id='. $them['id'] .'"><img src="/design/imgs/arr_b.png" align="center"> Отмена</a>';
include '../../system/foot.php';
exit;
} else {
echo '<div class="err">У вас недостаточно прав!</div>
<a class="link" href="?id='. $them['id'] .'"><img src="/design/imgs/arr_b.png" align="center"> Назад</a>';
include '../../system/foot.php';
exit;
}
break;
case 'action':
if (isset($_GET['reply']) || isset($_GET['quote']) || isset($_GET['post'])) {
if ($user['position'] != 'admin' && $user['position'] != 'mod_f') {
if (isset($_GET['reply'])) {
$int = intval($_GET['reply']);
} elseif (isset($_GET['quote'])) {
$int = intval($_GET['quote']);
} elseif (isset($_GET['post'])) {
$int = intval($_GET['post']);
}
$post = mysql_fetch_array(mysql_query("SELECT * FROM `f_post` WHERE `id` = '". $int ."' LIMIT 1"));
if ($post['hide'] != NULL) {
$title = 'Форум/Ошибка';
include '../../system/head.php';
echo '<div class="title"><a href="index.php">Форум</a> / <a href="category.php?id='. $forum['id'] .'">'. $forum['name'] .'</a> / <a href="topics.php?id='. $cat['id'] .'">'. $cat['name'] .'</a> / <a href="?id='. $them['id'] .'">'. $them['name'] .'</a> / Ошибка</div>
<div class="err">Вы не можете отвечать/цитировать/просматривать этот комментарий!</div>
<a class="link" href="?id='. $them['id'] .'"><img src="/design/imgs/arr_b.png" align="center"> Назад</a>';
include '../../system/foot.php';
exit;
}
}
}
// Кто заходил
if (isset($_GET['who_looked'])) {
if (!isset($user)) {
$title = 'Форум/Ошибка';
include '../../system/head.php';
echo '<div class="title"><a href="index.php">Форум</a> / <a href="category.php?id='. $forum['id'] .'">'. $forum['name'] .'</a> / <a href="topics.php?id='. $cat['id'] .'">'. $cat['name'] .'</a> / <a href="?id='. $them['id'] .'">'. $them['name'] .'</a> / Ошибка</div>
<div class="err">Чтобы просматривать данную страницу вы должны <a href="/reg.php">зарегистрироваться</a> или <a href="/login.php">авторизоваться</a>!</div>
<a class="link" href="?id='. $them['id'] .'"><img src="/design/imgs/arr_b.png" align="center"> Назад</a>';
include '../../system/foot.php';
exit;
}
$title = 'Форум/Кто просматривал';
include '../../system/head.php';
echo '<div class="title"><a href="index.php">Форум</a> / <a href="category.php?id='. $forum['id'] .'">'. $forum['name'] .'</a> / <a href="topics.php?id='. $cat['id'] .'">'. $cat['name'] .'</a> / <a href="?id='. $them['id'] .'">'. $them['name'] .'</a> / Кто просматривал</div>';
$c_u = mysql_result(mysql_query("SELECT COUNT(*) FROM `f_views` WHERE `id_them` = '". $them['id'] ."'"), 0);
if (isset($user)) $p_page = $user['p_page'];
else $p_page = '10';
$k_page = k_page($c_u, $p_page);
$page = page($k_page);
$start = $p_page*$page-$p_page;
if ($c_u == 0) {
echo '<div class="post">
Пока никто не просматривал.
</div>';
} else {
echo '<div class="post">
<b>Просмотров</b> ('. $c_u .')
</div>';
}
$q = mysql_query("SELECT * FROM `f_views` WHERE `id_them` = '". $them['id'] ."' ORDER BY `time` DESC LIMIT $start, ". $p_page);
while ($post = mysql_fetch_assoc($q)) {
$ank = mysql_fetch_assoc(mysql_query("SELECT * FROM `users` WHERE `id` = '". $post['id_user'] ."' LIMIT 1"));
echo '<a class="link" href="/pages/users/user.php?name='. $ank['login'] .'">
<span class="c_date">'. ptime($post['time']) .'</span>
<table cellpadding="0" cellspacing="0">
<tr>
<td>';
avatar($ank['id']);
echo ' </td><td>';
echo online($ank['id']);
echo $ank['login'];
echo user($ank['id']);
echo '</td>
</tr>
</table>
</a>';
}
include '../../system/foot.php';
}
// Кто в теме
if (isset($_GET['who_in'])) {
if (!isset($user)) {
$title = 'Форум/Ошибка';
include '../../system/head.php';
echo '<div class="title"><a href="index.php">Форум</a> / <a href="category.php?id='. $forum['id'] .'">'. $forum['name'] .'</a> / <a href="topics.php?id='. $cat['id'] .'">'. $cat['name'] .'</a> / <a href="?id='. $them['id'] .'">'. $them['name'] .'</a> / Ошибка</div>
<div class="err">Чтобы просматривать данную страницу вы должны <a href="/reg.php">зарегистрироваться</a> или <a href="/login.php">авторизоваться</a>!</div>
<a class="link" href="?id='. $them['id'] .'"><img src="/design/imgs/arr_b.png" align="center"> Назад</a>';
include '../../system/foot.php';
exit;
}
$title = 'Форум/Кто в теме';
include '../../system/head.php';
echo '<div class="title"><a href="index.php">Форум</a> / <a href="category.php?id='. $forum['id'] .'">'. $forum['name'] .'</a> / <a href="topics.php?id='. $cat['id'] .'">'. $cat['name'] .'</a> / <a href="?id='. $them['id'] .'">'. $them['name'] .'</a> / Кто в теме</div>';
$c_u = mysql_result(mysql_query("SELECT COUNT(*) FROM `f_views` WHERE `id_them` = '". $them['id'] ."' AND `time` > '". (time()-300) ."'"), 0);
if (isset($user)) $p_page = $user['p_page'];
else $p_page = '10';
$k_page = k_page($c_u, $p_page);
$page = page($k_page);
$start = $p_page*$page-$p_page;
if ($c_u == 0) {
echo '<div class="post">
Пока никого нет.
</div>';
} else {
echo '<div class="post">
<b>В теме</b> ('. $c_u .')
</div>';
}
$q = mysql_query("SELECT * FROM `f_views` WHERE `id_them` = '". $them['id'] ."' AND `time` > '". (time()-300) ."' ORDER BY `time` DESC LIMIT $start, ". $p_page);
while ($post = mysql_fetch_assoc($q)) {
$ank = mysql_fetch_assoc(mysql_query("SELECT * FROM `users` WHERE `id` = '". $post['id_user'] ."' LIMIT 1"));
echo '<a class="link" href="/pages/users/user.php?name='. $ank['login'] .'">
<span class="c_date">'. ptime($post['time']) .'</span>
<table cellpadding="0" cellspacing="0">
<tr>
<td>';
avatar($ank['id']);
echo ' </td><td>';
echo online($ank['id']);
echo $ank['login'];
echo user($ank['id']);
echo '</td>
</tr>
</table>
</a>';
}
include '../../system/foot.php';
}
// Ответ
if (isset($_GET['reply']) && mysql_result(mysql_query("SELECT COUNT(*) FROM `f_post` WHERE `id` = '". intval($_GET['reply']) ."'"),0) == 1) {
$post = mysql_fetch_array(mysql_query("SELECT * FROM `f_post` WHERE `id` = '". intval($_GET['reply']) ."' LIMIT 1"));
$ank = mysql_fetch_array(mysql_query("SELECT * FROM `users` WHERE `id` = '". $post['id_user'] ."' LIMIT 1"));
if (!isset($user)) {
$title = 'Форум/Ошибка';
include '../../system/head.php';
echo '<div class="title"><a href="index.php">Форум</a> / <a href="category.php?id='. $forum['id'] .'">'. $forum['name'] .'</a> / <a href="topics.php?id='. $cat['id'] .'">'. $cat['name'] .'</a> / <a href="?id='. $them['id'] .'">'. $them['name'] .'</a> / Ошибка</div>
<div class="err">Чтобы просматривать данную страницу вы должны <a href="/reg.php">зарегистрироваться</a> или <a href="/login.php">авторизоваться</a>!</div>
<a class="link" href="?id='. $them['id'] .'"><img src="/design/imgs/arr_b.png" align="center"> Назад</a>';
include '../../system/foot.php';
exit;
}
if ($post['id_user'] == $user['id']) {
$title = 'Форум/Ошибка';
include '../../system/head.php';
echo '<div class="title"><a href="index.php">Форум</a> / <a href="category.php?id='. $forum['id'] .'">'. $forum['name'] .'</a> / <a href="topics.php?id='. $cat['id'] .'">'. $cat['name'] .'</a> / <a href="?id='. $them['id'] .'">'. $them['name'] .'</a> / Ошибка</div>
<div class="err">Вы не можете отвечать сами себе.</div>
<a class="link" href="?id='. $them['id'] .'"><img src="/design/imgs/arr_b.png" align="center"> Назад</a>';
include '../../system/foot.php';
exit;
}
$error = false;
$errort = '';
if (isset($_POST['msg'])) {
$msg = filter($_POST['msg']);
if (strlen($msg) < 1) {
$error = true;
$errort .= '<div class="err">Длина сообщения должна быть не менее 1-ого символа.</div>';
} elseif (strlen($msg) > 20000) {
$error = true;
$errort .= '<div class="err">Длина сообщения должна быть не более 2000 символов.</div>';
}
if (!$error) {
mysql_query("INSERT INTO `f_post` (`forum_id`, `cat_id`, `them_id`, `id_user`, `time`, `msg`, `reply`) VALUES ('". $forum['id'] ."', '". $cat['id'] ."', '". $them['id'] ."', '". $user['id'] ."', '". time() ."', '$msg', '". $ank['id'] ."')");
if($user['pol'] == 1) $pol = 'Ответил';
else $pol = 'Ответила';
mysql_query("INSERT INTO `notifications` (`user_id`, `from_id`, `msg`, `message`, `time`) values('". $ank['id'] ."', '". $user['id'] ."', '". $pol ." на ваше сообщение в теме "<a href="/pages/forum/topic.php?id=". $them['id'] ."">". $them['name'] ."</a>".', '". $msg ."', '". time() ."')");
$bon_rand = rand(1, 5);
mysql_query("UPDATE `users` SET `bonus` = '". ($user['bonus']+$bon_rand) ."' WHERE `id` = '". $user['id'] ."'");
header('Location: ?id='. $them['id']);
exit;
}
}
$title = 'Форум/Ответ '. $ank['login'];
include '../../system/head.php';
echo '<div class="title"><a href="index.php">Форум</a> / <a href="category.php?id='. $forum['id'] .'">'. $forum['name'] .'</a> / <a href="topics.php?id='. $cat['id'] .'">'. $cat['name'] .'</a> / <a href="?id='. $them['id'] .'">'. $them['name'] .'</a> / Ответ '. $ank['login'] .'</div>';
echo $errort;
echo '<div class="post">
<span class="c_date">'. ptime($post['time']) .'</span>
<table cellpadding="0" cellspacing="0">
<tr>
<td>';
avatar($ank['id'], 'b');
echo ' </td>
<td>';
echo online($ank['id']);
echo '<a href="/pages/users/user.php?name='. $ank['login'] .'">'. $ank['login'] .'</a>';
echo user($ank['id']);
echo '</td>
</tr>
</table>
<hr>';
echo '<div>
'. output($post['msg']) .'
</div>
</div>
<form method="post" name="message">';
include '../../system/bbcodes.php';
echo '<textarea class="resize" name="msg"></textarea><br>';
include '../../system/smiles.php';
echo '<input value="Ответить" type="submit" name="add" />
</form>
<a class="link" href="?id='. $them['id'] .'&menu=action&post='. $post['id'] .'"><img src="/design/imgs/arr_b.png" align="center"> Просмотр поста</a>
<a class="link" href="?id='. $them['id'] .'"><img src="/design/imgs/arr_b.png" align="center"> Вернуться в тему</a>';
include '../../system/foot.php';
}
// Цитирование
if (isset($_GET['quote']) && mysql_result(mysql_query("SELECT COUNT(*) FROM `f_post` WHERE `id` = '". intval($_GET['quote']) ."'"),0) == 1) {
$post = mysql_fetch_array(mysql_query("SELECT * FROM `f_post` WHERE `id` = '". intval($_GET['quote']) ."' LIMIT 1"));
$ank = mysql_fetch_array(mysql_query("SELECT * FROM `users` WHERE `id` = '". $post['id_user'] ."' LIMIT 1"));
if (!isset($user)) {
$title = 'Форум/Ошибка';
include '../../system/head.php';
echo '<div class="title"><a href="index.php">Форум</a> / Ошибка</div>
<div class="err">Чтобы просматривать данную страницу вы должны <a href="/reg.php">зарегистрироваться</a> или <a href="/login.php">авторизоваться</a>!</div>
<a class="link" href="?id='. $them['id'] .'"><img src="/design/imgs/arr_b.png" align="center"> Назад</a>';
include '../../system/foot.php';
exit;
}
$error = false;
$errort = '';
if (isset($_POST['msg'])) {
$msg = filter($_POST['msg']);
$p_msg = filter($post['msg']);
if (strlen($msg) < 1) {
$error = true;
$errort .= '<div class="err">Длина сообщения должна быть не менее 1-ого символа.</div>';
} elseif (strlen($msg) > 20000) {
$error = true;
$errort .= '<div class="err">Длина сообщения должна быть не более 2000 символов.</div>';
}
if (!$error) {
mysql_query("INSERT INTO `f_post` (`forum_id`, `cat_id`, `them_id`, `id_user`, `time`, `msg`, `reply`, `quote`) VALUES ('". $forum['id'] ."', '". $cat['id'] ."', '". $them['id'] ."', '$user[id]', '". time() ."', '$msg', '". $ank['id'] ."', '". filter($post['msg']) ."')");
if($user['pol'] == 1) $pol = 'Процитировал';
else $pol = 'Процитировала';
if ($user['id'] != $ank['id']) mysql_query("INSERT INTO `notifications` (`user_id`, `from_id`, `msg`, `message`, `time`) values('". $ank['id'] ."', '". $user['id'] ."', '". $pol ." ваше сообщение в теме "<a href="/pages/forum/topic.php?id=". $them['id'] ."">". $them['name'] ."</a>".', '". $msg ."', '". time() ."')");
$bon_rand = rand(1, 5);
mysql_query("UPDATE `users` SET `bonus` = '". ($user['bonus']+$bon_rand) ."' WHERE `id` = '". $user['id'] ."'");
header('Location: ?id='. $them['id']);
exit;
}
}
$title = 'Форум/Цитирование '. $ank['login'];
include '../../system/head.php';
echo '<div class="title"><a href="index.php">Форум</a> / <a href="category.php?id='. $forum['id'] .'">'. $forum['name'] .'</a> / <a href="topics.php?id='. $cat['id'] .'">'. $cat['name'] .'</a> / <a href="?id='. $them['id'] .'">'. $them['name'] .'</a> / Ответ '. $ank['login'] .'</div>';
echo $errort;
echo '<div class="post">
<span class="c_date">'. ptime($post['time']) .'</span>
<table cellpadding="0" cellspacing="0">
<tr>
<td>';
avatar($ank['id'], 'b');
echo ' </td>
<td>';
echo online($ank['id']);
echo '<a href="/pages/users/user.php?name='. $ank['login'] .'">'. $ank['login'] .'</a>';
echo user($ank['id']);
echo '</td>
</tr>
</table>
<hr>';
echo output($post['msg']) .'
</div>
<form method="post" name="message">';
include '../../system/bbcodes.php';
echo '<textarea class="resize" name="msg"></textarea><br>';
include '../../system/smiles.php';
echo '<input value="Цитировать" type="submit" name="add" />
</form>
<a class="link" href="?id='. $them['id'] .'&menu=action&post='. $post['id'] .'"><img src="/design/imgs/arr_b.png" align="center"> Просмотр поста</a>
<a class="link" href="?id='. $them['id'] .'"><img src="/design/imgs/arr_b.png" align="center"> Вернуться в тему</a>';
include '../../system/foot.php';
}
// Просмотр поста
if (isset($_GET['post']) && mysql_result(mysql_query("SELECT COUNT(*) FROM `f_post` WHERE `id` = '". intval($_GET['post']) ."'"), 0) == 1) {
$post = mysql_fetch_assoc(mysql_query("SELECT * FROM `f_post` WHERE `id` = '". intval($_GET['post']) ."' LIMIT 1"));
$ank = mysql_fetch_assoc(mysql_query("SELECT * FROM `users` WHERE `id` = '". $post['id_user'] ."' LIMIT 1"));
if (!isset($user)) {
$title = 'Форум/Ошибка';
include '../../system/head.php';
echo '<div class="title"><a href="index.php">Форум</a> / Ошибка</div>';
echo '<div class="err">Чтобы просматривать данную страницу, вы должны <a href="/pages/registration/">зарегистрироваться</a> или <a href="/pages/registration/?menu=login">авторизоваться</a>!</div>
<a class="link" href="index.php"><img src="/design/imgs/arr_b.png" align="center"> Назад</a>';
include '../../system/foot.php';
exit;
}
$title = 'Форум/Просмотр поста №'. $post['id'];
include '../../system/head.php';
echo '<div class="title"><a href="index.php">Форум</a> / <a href="category.php?id='. $forum['id'] .'">'. $forum['name'] .'</a> / <a href="topics.php?id='. $cat['id'] .'">'. $cat['name'] .'</a> / <a href="?id='. $them['id'] .'">'. $them['name'] .'</a> / Пост №'. $post['id'] .'</div>';
echo '<div class="post">
<span class="c_date">'. ptime($post['time']) .'</span>
<table cellpadding="0" cellspacing="0">
<tr>
<td>';
avatar($ank['id'], 'b');
echo ' </td>
<td>';
echo online($ank['id']);
echo '<a href="?menu=action&post='. $post['id'] .'">'. $ank['login'] .'</a>';
echo user($ank['id']);
echo '</td>
</tr>
</table><hr>';
echo output($post['msg']) .'
</div>
<a class="link" href="/pages/users/user.php?name='. $ank['login'] .'"><img src="/design/imgs/ank_view.png"> Посмотреть анкету</a>';
if ($user['id'] != $post['id_user']) echo '<a class="link" href="?id='. $them['id'] .'&menu=action&reply='. $post['id'] .'"><img src="/design/imgs/reply.png"> Ответить</a>';
echo '<a class="link" href="?id='. $them['id'] .'&menu=action"e='. $post['id'] .'"><img src="/design/imgs/quote_mess.png"> Цитировать</a>';
if ($user['position'] == 'admin' || $user['position'] == 'mod_c') {
if ($post['hide'] == NULL) echo '<a class="link" href="?id='. $them['id'] .'&menu=action&hide='. $post['id'] .'"><img src="/design/imgs/hide.png"> Скрыть</a>';
elseif ($post['hide'] != NULL) echo '<a class="link" href="?id='. $them['id'] .'&menu=action&hide='. $post['id'] .'"><img src="/design/imgs/hide.png"> Восстановить</a>';
}
if ($user['position'] == 'admin' || $user['position'] == 'mod_c' || $user['id'] == $post['id_user']) echo '<a class="link" href="?id='. $them['id'] .'&menu=action&delete='. $post['id'] .'"><img src="/design/imgs/delete.png"> Удалить</a>';
echo '<a class="link" href="?id='. $them['id'] .'"><img src="/design/imgs/arr_b.png" align="center"> Вернуться в тему</a>';
include '../../system/foot.php';
exit;
}
// Скрываем/Восстанавливаем комментарий
if (isset($_GET['hide']) && mysql_result(mysql_query("SELECT COUNT(*) FROM `f_post` WHERE `id` = '". intval($_GET['hide']) ."'"), 0) == 1) {
if ($user['position'] == 'admin' || $user['position'] == 'mod_f') {
$post = mysql_fetch_assoc(mysql_query("SELECT * FROM `f_post` WHERE `id` = '". intval($_GET['hide']) ."' LIMIT 1"));
if ($post['hide'] == NULL) {
mysql_query("UPDATE `f_post` SET `hide` = '$user[login]' WHERE `id` = '". intval($_GET['hide']) ."'");
} else {
mysql_query("UPDATE `f_post` SET `hide` = '' WHERE `id` = '". intval($_GET['hide']) ."'");
}
header('Location: ?id='. $them['id'] .'&page=end');
exit;
} else {
$title = 'Форум/Ошибка';
include '../../system/head.php';
echo '<div class="title"><a href="/pages/forum/">Форум</a> / Ошибка</div>
<div class="err">У вас недостаточно прав!</div><a class="link" href="?id='. $them['id'] .'&page=end">Назад</a>';
include '../../system/foot.php';
exit;
}
}
// Открываем тему
if (isset($_GET['open'])) {
if ($user['position'] == 'admin' || $user['position'] == 'mod_f') {
mysql_query("UPDATE `f_theme` SET `close` = '0' WHERE `id` = '". $them['id'] ."' LIMIT 1");
mysql_query("INSERT INTO `f_post` (`forum_id`, `cat_id`, `them_id`, `id_user`, `msg`, `time`) values('". $forum['id'] ."', '". $cat['id'] ."', '". $them['id'] ."', '2', 'Тему открыл <a href="/pages/users/user.php?name=$user[login]">$user[login]</a>.', '". time() ."')");
header('Location: ?id='. $them['id'] .'&page=end');
exit;
}
// Закрываем тему
} elseif (isset($_GET['close'])) {
if ($user['position'] == 'admin' || $user['position'] == 'mod_f') {
mysql_query("UPDATE `f_theme` SET `close` = '1', `who_close` = '$user[login]' WHERE `id` = '". $them['id'] ."' LIMIT 1");
mysql_query("INSERT INTO `f_post` (`forum_id`, `cat_id`, `them_id`, `id_user`, `msg`, `time`) values('". $forum['id'] ."', '". $cat['id'] ."', '". $them['id'] ."', '2', 'Тему закрыл <a href="/pages/users/user.php?name=". $user['login'] ."">". $user['login'] ."</a>.', '". time() ."')");
header('Location: ?id='. $them['id'] .'&page=end');
exit;
}
}
// Перемещаем тему
if (isset($_GET['move'])) {
if ($user['position'] == 'admin' || $user['position'] == 'mod_f') {
if (isset($_POST['go']) && isset($_POST['cat']) && is_numeric($_POST['cat']) && (mysql_result(mysql_query("SELECT COUNT(*) FROM `f_category` WHERE `id` = '". intval($_POST['cat']) ."'"), 0) == 1 || mysql_result(mysql_query("SELECT COUNT(*) FROM `f_category` WHERE `id` = '". intval($_POST['cat']) ."' WHERE `forum_id` = '$forum[id]'"), 0) == 1 && $ank['id'] == $user['id'])) {
$cat_new = mysql_fetch_assoc(mysql_query("SELECT * FROM `f_category` WHERE `id` = '". intval($_POST['cat']) ."' LIMIT 1"));
mysql_query("UPDATE `f_post` SET `forum_id` = '". $cat_new['forum_id'] ."', `cat_id` = '". $cat_new['id'] ."' WHERE `forum_id` = '". $forum['id'] ."' AND `cat_id` = '".$cat['id'] ."' AND `them_id` = '". $them['id'] ."'");
mysql_query("UPDATE `f_theme` SET `forum_id` = '". $cat_new['forum_id'] ."', `cat_id` = '". $cat_new['id'] ."' WHERE `forum_id` = '". $forum['id'] ."' AND `cat_id` = '". $cat['id'] ."' AND `id` = '". $them['id']."'");
$old_cat = $cat;
$forum = mysql_fetch_assoc(mysql_query("SELECT * FROM `forum` WHERE `id` = '". $cat_new['forum_id'] ."' LIMIT 1"));
$catg = mysql_fetch_assoc(mysql_query("SELECT * FROM `f_category` WHERE `id` = '". $cat_new['id'] ."' LIMIT 1"));
$them = mysql_fetch_assoc(mysql_query("SELECT * FROM `f_theme` WHERE `cat_id` = '". $catg['id'] ."' AND `id` = '". $them['id'] ."' LIMIT 1"));
mysql_query("INSERT INTO `f_post` (`forum_id`, `cat_id`, `them_id`, `id_user`, `msg`, `time`) values('". $forum['id'] ."', '". $catg['id'] ."', '". $them['id'] ."', '2', 'Тему переместил <a href="/pages/users/user.php?name=". $user['login']. "">". $user['login'] ."</a> из <a href="/pages/forum/topics.php?id=". $old_cat['id']. ""><b>". $old_cat['name'] ."</b></a> в <a href="/pages/forum/topics.php?id=". $catg['id']. ""><b>". $catg['name'] ."</b></a>.', '". time() ."')");
header('Location: ?id='. $them['id']);
exit;
}
$title = 'Форум/Перемещение темы';
include '../../system/head.php';
echo '<div class="title"><a href="/pages/forum/">Форум</a> / Перемещение темы</div>
<div class="post">
Перемещение темы <b>'. output($them['name']) .'</b>
</div>
<form method="post">
Раздел:<br>
<select name="cat">';
$q = mysql_query("SELECT * FROM `forum` ORDER BY `id` ASC");
while ($forum = mysql_fetch_assoc($q)) {
echo '<optgroup label="'. $forum['name'] .'">';
$q2 = mysql_query("SELECT * FROM `f_category` WHERE `forum_id` = '". $forum['id'] ."' ORDER BY `id` ASC");
while ($razdels = mysql_fetch_assoc($q2)) {
echo '<option '. ($cat['id'] == $razdels['id'] ? "selected='selected'" : null) .' value="'. $razdels['id'] .'">'. output($razdels['name']) . '</option>';
}
echo '</optgroup>';
}
echo '</select><br>
<input value="Переместить" type="submit" name="go">
</form>
<a class="link" href="?id='. $them['id'] .'&page=end"><img src="/design/imgs/arr_b.png" align="center"> Назад</a>';
include '../../system/foot.php';
exit;
}
}
// Открепляем тему
if (isset($_GET['undock'])) {
if ($user['position'] == 'admin' || $user['position'] == 'mod_f') {
mysql_query("UPDATE `f_theme` SET `fix` = '0' WHERE `id` = '". $them['id'] ."' LIMIT 1");
mysql_query("INSERT INTO `f_post` (`forum_id`, `cat_id`, `them_id`, `id_user`, `msg`, `time`) values('". $forum['id'] ."', '". $cat['id'] ."', '". $them['id'] ."', '2', 'Тему открепил <a href="/pages/users/user.php?name=$user[login]">$user[login]</a>.', '". time() ."')");
header('Location: ?id='. $them['id'] .'&page=end');
exit;
}
// Закрепляем тему
} elseif (isset($_GET['fasten'])) {
if ($user['position'] == 'admin' || $user['position'] == 'mod_f') {
mysql_query("UPDATE `f_theme` SET `fix` = '1' WHERE `id` = '". $them['id'] ."' LIMIT 1");
mysql_query("INSERT INTO `f_post` (`forum_id`, `cat_id`, `them_id`, `id_user`, `msg`, `time`) values('". $forum['id'] ."', '". $cat['id'] ."', '". $them['id'] ."', '2', 'Тему закрепил <a href="/pages/users/user.php?name=$user[login]">$user[login]</a>.', '". time() ."')");
header('Location: ?id='. $them['id'] .'&page=end');
exit;
}
}
// Удаляем комментарий
if (isset($_GET['delete']) && mysql_result(mysql_query("SELECT COUNT(*) FROM `f_post` WHERE `id` = '". intval($_GET['delete']) ."'"), 0) == 1) {
$post = mysql_fetch_assoc(mysql_query("SELECT * FROM `f_post` WHERE `id` = '". intval($_GET['delete']) ."' LIMIT 1"));
if ($user['position'] == 'admin' || $user['position'] == 'mod_f' || $user['id'] == $post['id_user']) {
mysql_query("DELETE FROM `f_post` WHERE `id` = '".intval($_GET['delete'])."'");
header('Location: ?id='. $them['id'] .'&page=end');
exit;
} else {
$title = 'Форум/Ошибка';
include '../../system/head.php';
echo '<div class="title"><a href="/pages/forum/">Форум</a> / Ошибка</div>
<div class="err">У вас недостаточно прав!</div>
<a class="link" href="?id='. $them['id'] .'&page=end">Назад</a>';
include '../../system/foot.php';
exit;
}
}
// Ставим +1 или -1 к посту
if (isset($_GET['like']) && mysql_result(mysql_query("SELECT COUNT(*) FROM `f_post` WHERE `id` = '". intval($_GET['like']) ."'"),0) == 1 && isset($_GET['klike'])) {
if (isset($_GET['klike']) && intval($_GET['klike']) == 0)$klike = '0'; else $klike = '1';
$post = mysql_fetch_array(mysql_query("SELECT * FROM `f_post` WHERE `id` = '". intval($_GET['like']) ."' LIMIT 1"));
$ank = mysql_fetch_array(mysql_query("SELECT * FROM `users` WHERE `id` = '". $post['id_user'] ."' LIMIT 1"));
if (!isset($user)) {
$title = 'Форум/Ошибка';
include '../../system/head.php';
echo '<div class="title"><a href="index.php">Форум</a> / Ошибка</div>
<div class="err">Чтобы просматривать данную страницу вы должны <a href="/reg.php">зарегистрироваться</a> или <a href="/login.php">авторизоваться</a>!</div>
<a class="link" href="?id='. $them['id'] .'"><img src="/design/imgs/arr_b.png" align="center"> Назад</a>';
include '../../system/foot.php';
exit;
}elseif (mysql_result(mysql_query("SELECT COUNT(*) FROM `like_f_post` WHERE `forum_id` = '". $forum['id'] ."' AND `cat_id` = '". $cat['id'] ."' AND `them_id` = '". $them['id'] ."' AND `post_id` = '".$post['id']."' AND `id_user` = '".$user['id']."'"), 0)==1){
$title = 'Форум/Ошибка';
include '../../system/head.php';
echo '<div class="title"><a href="index.php">Форум</a> / Ошибка</div>
<div class="err">Вы уже ставили like</div>';
include '../../system/foot.php';
exit;
}
mysql_query("INSERT INTO `like_f_post` (`forum_id`, `cat_id`, `them_id`, `post_id`, `id_user`, `like`, `time`) VALUES ('". $forum['id'] ."', '". $cat['id'] ."', '". $them['id'] ."', '". $post['id'] ."', '$user[id]', '". $klike ."', '". time() ."')");
if (isset($_GET['klike']) && intval($_GET['klike']) == 0)$nlike = 'положительно'; else $nlike = 'отрицательно';
if ($user['id'] != $ank['id']) mysql_query("INSERT INTO `notifications` (`user_id`, `from_id`, `message`, `time`) values('". $ank['id'] ."', '". $user['id'] ."', '".$user['login']." оценил ".$nlike." ваш пост в теме "<a href="/pages/forum/topic.php?id=". $them['id'] ."">". $them['name'] ."</a>".', '". time() ."')");
header('Location: ?id='. $them['id']);
exit;
}
break;
}
?>