Вход Регистрация
Файл: public_html/forum.php
Строк: 225
<?php
include ('./system/system.php');
$title 'Форум';
include (
'./system/head.php');
if(!
$user) {
header('location: /index.php');
exit();
}
$topic abs(intval($_GET['topic']));
if(
$topic){
$topic mysql_fetch_assoc(mysql_query("SELECT * FROM `topic` WHERE `id` = '".$topic."'"));
if(!
$topic){
header('Location: /forum.php');
exit();
}
if(isset(
$_GET['delete_post']) and $user['access'] >= 1){
$post _string(_num($_GET['delete_post']));
mysql_query("DELETE FROM `topic_msg` WHERE `id` = '".$post."'");
header('Location: /forum.php?id='.$topic['id_forum'].'&topic='.$topic['id'].'');
exit();
}
if(isset(
$_GET['delete_ok']) and $user['access'] >= 1){
mysql_query("DELETE FROM `topic` WHERE `id` = '".$topic[id]."'");
mysql_query("DELETE FROM `topic_msg` WHERE `id_topic` = '".$topic['id']."'");
header("Location: /forum.php?id=$topic[id_forum]");
exit();
}
if(isset(
$_GET['close']) and $user['access'] >= 1){
mysql_query("UPDATE `topic` SET `close` = '1' WHERE `id` = '$topic[id]'");
header('Location: /forum.php?id='.$topic['id_forum'].'&topic='.$topic['id'].'');
exit();
}
if(isset(
$_GET['no_close']) and $user['access'] >= 1){
mysql_query("UPDATE `topic` SET `close` = '0' WHERE `id` = '$topic[id]'");
header('Location: /forum.php?id='.$topic['id_forum'].'&topic='.$topic['id'].'');
exit();
}
if(isset(
$_GET['top']) and $user['access'] >= 1){
mysql_query("UPDATE `topic` SET `top` = '1' WHERE `id` = '$topic[id]'");
header('Location: /forum.php?id='.$topic['id_forum'].'&topic='.$topic['id'].'');
exit();
}
if(isset(
$_GET['no_top']) and $user['access'] >= 1){
mysql_query("UPDATE `topic` SET `top` = '0' WHERE `id` = '$topic[id]'");
header('Location: /forum.php?id='.$topic['id_forum'].'&topic='.$topic['id'].'');
exit();
}
if(isset(
$_GET['text']) && $user['ban_time'] < time()){
if(
$user['level'] < 15) {
echo 
'<div class="block small red center">Писать на форуме разрешено с 15 уровня!</div>';
include (
'./system/foot.php');
exit();
}
if(isset(
$_POST['text'])){
$text _string($_POST['text']);
if(
strlen($text) < or strlen($text) > 5000) {
echo 
'<div class="block small red center">Длина сообщения должна быть в пределах 3 - 5000 символов!</div>';
echo 
'<a href="/forum.php?id='.$topic['id_forum'].'&topic='.$topic['id'].'" class="link"><img src="/images/icons/forward.png"> Вернуться</a>';
include (
'./system/foot.php');
exit();
}
mysql_query("INSERT INTO `topic_msg` SET `id_topic` = '$topic[id]', `id_user` = '".$user[id]."', `text` = '$text' , `time` = '".time()."'");
mysql_query("UPDATE `topic` SET `onlick` = '".time()."' WHERE `id` = '$topic[id]'");
header('Location: /forum.php?id='.$topic['id_forum'].'&topic='.$topic['id'].'');
exit();
}
}
if(isset(
$_GET['sett_topic_post']) && $user['ban_time'] < time()){
if(
$user['level'] < 15 && $user['access'] == 0) {
echo 
'<div class="block small red center">Создавать топики разрешено с 15 уровня!</div>';
include (
'./system/foot.php');
exit();
}
if(isset(
$_POST['text']) && isset($_POST['name'])){
$text _string($_POST['text']);
$name _string($_POST['name']);
if(
strlen($name) < or strlen($name) > 40) {
echo 
'<div class="block small red center">Длина названия должна быть в пределах 3 - 40 символов!</div>';
echo 
'<a href="/forum.php?id='.$topic['id_forum'].'&topic='.$topic['id'].'" class="link"><img src="/images/icons/forward.png"> Вернуться</a>';
include (
'./system/foot.php');
exit();
}
if(
strlen($text) < or strlen($text) > 5000) {
echo 
'<div class="block small red center">Длина сообщения должна быть в пределах 3 - 5000 символов!</div>';
echo 
'<a href="/forum.php?id='.$topic['id_forum'].'&topic='.$topic['id'].'" class="link"><img src="/images/icons/forward.png"> Вернуться</a>';
include (
'./system/foot.php');
exit();
}
mysql_query("UPDATE `topic` SET `text` = '$text', `name` = '$name' WHERE `id` = '$topic[id]'");
header('Location: /forum.php?id='.$topic['id_forum'].'&topic='.$topic['id'].'');
exit();
}
}
if(
$user['access'] >= 1){
if(isset(
$_GET['sett_topic'])){
echo 
"<div class='block'>";
echo 
'<form name="text" method="post" action="/forum.php?id='.$forum['id'].'&topic='.$topic['id'].'&sett_topic_post">';
echo 
"Название: <br>
<input type='text' name='name' placeholder='' class='text' value='
$topic[name]' style='width: 97%'><br>";
echo 
'Описание: <br> <textarea name="text" placeholder="" class="text" maxlength="5000" style="width: 97%">'.$topic['text'].'</textarea><br>';
echo 
'<input class="submit" type="submit" value="Изменить">';
echo 
"</form>";
echo 
"</div>";
echo 
'<a href="/forum.php?id='.$topic['id_forum'].'&topic='.$topic['id'].'" class="link"><img src="/images/icons/forward.png"> Вернуться</a>';
require_once (
'./system/foot.php');
break;
}
}
$ank mysql_fetch_assoc(mysql_query("SELECT * FROM `users` WHERE `id` = $topic[id_user] LIMIT 1"));
if(
$ank['access'] == 2) {
$access " <b>[ADM]</b>";
}
if(
$ank['access'] == 1) {
$access " <b>[MD]</b>";
}
if(
$ank['access'] == 0) {
$access "";
}
echo 
"<div class='block'> <img src='/images/race/$ank[race].png'> <a href='/profile.php?id=$ank[id]'>$ank[login]</a>$access: ";
if(
$ank['access'] != 0) {
echo 
'<font color="#f09050">';
echo 
''.smiles($topic['text']).'';
if(
$ank['access'] != 0) echo '</font>';
}else{
echo 
"".smiles($topic['text']);
}
echo 
"</div>";
if(
$user['access'] >= 1){
echo 
"<a href='/forum.php?id=$topic[id_forum]&topic=$topic[id]&sett_topic' class='link'><img src='/images/icons/forward.png'> Редактировать</a>";
if(
$topic['close'] == and $user['access'] > 0)echo "<a href='/forum.php?id=$topic[id_forum]&topic=$topic[id]&close' class='link'><img src='/images/icons/forward.png'> Закрыть</a>";
if(
$topic['close'] == and $user['access'] > 0)echo "<a href='/forum.php?id=$topic[id_forum]&topic=$topic[id]&no_close' class='link'><img src='/images/icons/forward.png'> Открыть</a>";
if(
$topic['top'] == and $user['access'] > 0)echo "<a href='/forum.php?id=$topic[id_forum]&topic=$topic[id]&top' class='link'><img src='/images/icons/forward.png'> Прикрепить</a>";
if(
$topic['top'] == and $user['access'] > 0)echo "<a href='/forum.php?id=$topic[id_forum]&topic=$topic[id]&no_top' class='link'><img src='/images/icons/forward.png'> Открепить</a>";
if(
$user['access'] > 0)echo "<a href='/forum.php?id=$topic[id_forum]&topic=$topic[id]&delete_ok' class='link'><img src='/images/icons/forward.png'> Удалить топик</a>";
}
$set['p_str'] = 10;
$k_post mysql_result(mysql_query("SELECT COUNT(*) FROM `topic_msg` WHERE `id_topic` = '$topic[id]'"),0);
echo 
"<div class='block'><b>Комментарии: [$k_post]</b></div>";
$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 `topic_msg` WHERE `id_topic` = '$topic[id]' ORDER BY `id` DESC LIMIT $start$set[p_str]");
while (
$post mysql_fetch_assoc($q)){
$ank mysql_fetch_assoc(mysql_query("SELECT * FROM `users` WHERE `id` = $post[id_user] LIMIT 1"));
echo 
"<div class='block'> <img src='/images/race/$ank[race].png'> <a href='/profile.php?id=$ank[id]' >$ank[login]</a>";
if(
$ank['access'] == 1) echo ' <b>[MD]</b>';
if(
$ank['access'] == 2) echo ' <b>[ADM]</b>';
echo 
": ";
if(
$ank[id] != $user[id] and $topic[close] == 0)echo "<a href='/forum.php?id=$forum[id]&topic=$topic[id]&to=$ank[id]'>(»)</a>";
if(
$ank['access'] != 0) {
echo 
'<font color="#f09050">';
echo 
''.smiles($post['text']).'';
if(
$ank['access'] != 0) echo '</font>';
}else{
echo 
" ".smiles($post['text']);
}
if(
$user[access] > 0)echo " <a href='/forum.php?id=$forum[id]&topic=$topic[id]&delete_post=$post[id]' class='red small'>(x)</a>";
echo 
"</div>";
}
if(
$k_page>1)  echo str('/forum.php?id='.$topic['id_forum'].'&topic='.$topic['id'].'&',$k_page,$page);
if(
$topic['close'] == 0){
if(
$user['ban_time'] < time()) {
if(isset(
$_GET[to])){
$opponent mysql_fetch_assoc(mysql_query("SELECT * FROM `users` WHERE `id` = $_GET[to] LIMIT 1"));
echo 
'<form class="block center" name="text" method="post" action="/forum.php?id='.$topic['id_forum'].'&topic='.$topic['id'].'&text">';
echo 
'<textarea name="text" class="text" maxlength="5000">'.$opponent[login].', </textarea><br>';
echo 
'<input class="submit" type="submit" value="Ответить">';
echo 
"</form>";
}else{
echo 
'<form class="block center" name="text" method="post" action="/forum.php?id='.$topic['id_forum'].'&topic='.$topic['id'].'&text">';
echo 
'<textarea name="text" class="text placeholder="" maxlength="5000"></textarea><br>';
echo 
'<input class="submit" type="submit" value="Отправить">';
echo 
"</form>";
}
}
}else{
echo 
"<div class='block small red center'>Топик закрыт!</div>";
}
}else{
## Раздел ##
$id abs(intval($_GET['id']));
if(
$id){
$forum mysql_fetch_assoc(mysql_query("SELECT * FROM `forum` WHERE `id` = '".$id."'"));
# Ошибки #
if(!$forum){
header('Location: /forum.php');
exit();
}
if(isset(
$_GET['new_topic_post']) && $user['ban_time'] < time()){
if(isset(
$_POST['name']) && isset($_POST['text'])){
$name _string($_POST['name']);
$text _string($_POST['text']);
if(
strlen($name) < or strlen($name) > 40) {
echo 
'<div class="block small red center">Длина названия должна быть в пределах 3 - 40 символов!</div>';
echo 
'<a href="/forum.php?id='.$forum['id'].'&new_topic" class="link"><img src="/images/icons/forward.png"> Вернуться</a>';
include (
'./system/foot.php');
exit();
}
if(
strlen($text) < or strlen($text) > 5000) {
echo 
'<div class="block small red center">Длина сообщения должна быть в пределах 3 - 5000 символов!</div>';
echo 
'<a href="/forum.php?id='.$forum['id'].'&new_topic" class="link"><img src="/images/icons/forward.png"> Вернуться</a>';
include (
'./system/foot.php');
exit();
}
mysql_query("INSERT INTO `topic` SET `id_forum` = '$forum[id]', `id_user` = '".$user[id]."', `name` = '$name', `text` = '$text', `time` = '".time()."', `onlick` = '".time()."'");
header('Location: /forum.php?id='.$forum['id'].'');
exit();
}
}
$title ''.$forum['name'];
require_once (
'./system/head.php');
if(isset(
$_GET['new_topic']) and $user['access'] >= $forum['access']){
echo 
"<div class='block'>";
echo 
'<form name="text" method="post" action="/forum.php?id='.$forum['id'].'&new_topic_post">';
echo 
"Название: <br><input type='text' class='text' name='name' placeholder='' style='width: 97%'><br>";
echo 
'Описание: <br>
<textarea name="text" class="text" placeholder="" maxlength="5000" style="width: 97%"></textarea><br>'
;
echo 
'<input class="submit" type="submit" value="Создать">';
echo 
"</form></div>";
echo 
'<a href="/forum.php?id='.$forum['id'].'" class="link"><img src="/images/icons/forward.png"> Вернуться</a>';
require_once (
'./system/foot.php');
break;
}
$set['p_str'] = 10;
$k_post mysql_result(mysql_query("SELECT COUNT(*) FROM `topic` WHERE `id_forum` = '$forum[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 `topic` WHERE `id_forum` = '$forum[id]' ORDER BY `top` DESC, `onlick` DESC LIMIT $start$set[p_str]");
if(
$k_post == 0)echo "<div class='block red small center'>В данном разделе нет топиков!</div>";
while (
$post mysql_fetch_assoc($q)){
echo 
"<a href='/forum.php?id=$forum[id]&topic=$post[id]' class='link'><img src='/images/icons/forum.png'> ";
if(
$post['close'] == and $post['top'] == 1)echo "<b>$post[name]</b>";
elseif(
$post['close'] == 1)echo "<font color='red'>$post[name]</font>";
elseif(
$post['top'] == 1)echo "<b>$post[name]</b>";
else echo 
$post['name'];
echo 
"</a>";
}
if(
$k_page>1)  echo str('/forum.php?id='.$forum['id'].'&',$k_page,$page);
if(
$user['ban_time'] < time()) {
if(
$user['access'] >= $forum['access'])echo "<a href='/forum.php?id=$forum[id]&new_topic' class='link'><img src='/images/icons/edit.png'> Создать топик</a>";
}
}else{
## Форум ##
$title 'Форум';
require_once (
'./system/head.php');
$set['p_str'] = 10;
$k_post mysql_result(mysql_query("SELECT COUNT(*) FROM `forum`"),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 `forum` ORDER BY `id` ASC LIMIT $start$set[p_str]");
if(
$k_post == 0)echo "<div class='block red small center'>Нет разделов!</div>";
while(
$post mysql_fetch_assoc($q)) {
echo 
"<a href='/forum.php?id=$post[id]' class='link'><img src='/images/icons/forum.png'> $post[name]</a>";
}
if(
$k_page>1)  echo str('?',$k_page,$page);
echo 
'<a href="/faq.php" class="link"><img src="/images/icons/faq.png"> ЧаВо</a>';
echo 
'<a href="/a_list.php" class="link"><img src="/images/icons/a_list.png"> Администрация</a>';
}
}
include (
'./system/foot.php');
?>
Онлайн: 0
Реклама