Файл: forum.php
Строк: 779
<?
require_once("core/core.php");
$location = 'В форуме';
switch (@$_GET['act']) {
//~~~~~~~~~~Создание категории~~~~~~~~~~~~//
case 'add_cat':
if ($u['admin'] == 1 || $u['admin'] == 2 || $u['admin'] == 3) {
$flood = mysql_query("SELECT `time` FROM `forum_categories` WHERE `user` = '" . $u['id'] . "' AND `time` > '" . (time() - $system['cat_forum_antiflud']) . "'");
if (mysql_num_rows($flood)) {
require('head.php');
error(' <b>Ошибка</b>!</br> Можно добавлять категории только раз в ' . $system['cat_forum_antiflud'] . ' сек.');
header("Refresh: 3; URL=forum.php");
require('foot.php');
exit;
}
if (isset($_POST['submit']) and $_POST['name']) {
$name = check(substr($_POST['name'], 0, 100));
$opis = check(substr($_POST['opis'], 0, 100));
if (empty($name)) {
require('head.php');
error('Ошибка, так делать нельзя!');
$error = '1';
require('foot.php');
exit;
}
if (empty($error)) {
mysql_query("INSERT INTO `forum_categories` SET
`name` = '$name',
`opis` = '$opis',
`user` = '" . $u['id'] . "',
`time` = '" . time() . "',
`edit` = '" . $u['id'] . "',
`etime` = '" . time() . "',
`ord` = '0'
");
if ($u['sex'] == 'm') {
$action[0] = 'Создал';
} else {
$action[0] = 'Создала';
}
$text = $action[0] . ' раздел в <a href = "/forum.php">форуме</a>.';
mysql_query("INSERT INTO `admin_jurnal` SET
`user` = '" . $u['id'] . "',
`text` = '$text',
`time` = '" . time() . "',
`news` = '0',
`forum` = '1',
`diary` = '0',
`chat` = '0',
`blog` = '0',
`foto` = '0',
`ban` = '0',
`edit` = '0',
`new` = '1'
");
header("location: forum.php");
}
} else {
$title = $title . ' :: Форум';
require('head.php');
echo '<div class="title"><center>';
echo '<a href = "forum.php">Форум</a> :: Добавить категорию';
echo '</center></div>';
echo '<div class="div">';
echo '<form action=forum.php?act=add_cat method=post>
Название: 100 символов<br/><textarea cols="20" rows="1" name="name" style="width: 30%;height: 20px;"></textarea>
</div><div class="div">
Описание: 100 символов<br/><textarea cols="20" rows="1" name="opis" ></textarea><br/>
<input type=submit name="submit" value=Добавить class=submit white/ ></form>';
echo '</div>';
echo '<div class="title">';
echo '<img src="style/page/back.png" alt="Back"> <a href = "?sid=back" onclick="history.back()">Назад</a>';
echo '</div>';
require('foot.php');
}
} else {
require('head.php');
echo '<div class="title"><img src="ico/forum.png" alt="!"/> <a href = "forum.php">Форум</a> <b>Ошибка</b></div>';
error(' Отказано в доступе !');
require('foot.php');
}
break;
//~~~~~~~~~~~~~~~~~Создание подфорума~~~~~~~~~~~~~~~~~~~//
case 'add_forum':
if ($u['admin'] == 1 || $u['admin'] == 2 || $u['admin'] == 3) {
$flood = mysql_query("SELECT `time` FROM `forum_forums` WHERE `user` = '" . $u['id'] . "' AND `time` > '" . (time() - $system['cat_forum_antiflud']) . "'");
if (mysql_num_rows($flood)) {
require('head.php');
error(' <b>Ошибка</b>!</br> Можно добавлять подфорум только раз в ' . $system['cat_forum_antiflud'] . ' сек.');
require('foot.php');
exit;
}
if (isset($_GET['id'])) {
$id = num($_GET['id']);
$req = mysql_query("SELECT * FROM `forum_categories` WHERE `id` = '$id' LIMIT 1");
if (mysql_num_rows($req)) {
$category = mysql_fetch_assoc($req);
}
}
if ($category) {
if (isset($_POST['submit']) and $_POST['name']) {
$name = check(substr($_POST['name'], 0, 100));
if (empty($name)) {
require('head.php');
error(' Ошибка, так делать нельзя!');
$error = '1';
require('foot.php');
exit;
}
if (empty($error)) {
mysql_query("INSERT INTO `forum_forums` SET
`name` = '$name',
`time` = '" . time() . "',
`edit` = '" . $u['id'] . "',
`etime` = '" . time() . "',
`user` = '" . $u['id'] . "',
`cat` = '" . $category['id'] . "',
`ord` = '0'
");
if ($u['sex'] == 'm') {
$action[0] = 'Создал';
} else {
$action[0] = 'Создала';
}
$text = $action[0] . ' форум в <a href = "forum.php?act=cat&id=' . $category['id'] . '">разделе</a>.';
mysql_query("INSERT INTO `admin_jurnal` SET
`user` = '" . $u['id'] . "',
`text` = '$text',
`time` = '" . time() . "',
`news` = '0',
`forum` = '1',
`diary` = '0',
`chat` = '0',
`blog` = '0',
`foto` = '0',
`ban` = '0',
`edit` = '0',
`new` = '1'
");
header("location: forum.php?act=cat&id=" . $category['id'] . "");
}
} else {
$title = $title . ' :: Форум';
require('head.php');
$name_cat = $category['name'];
echo '<div class="title"><center><a href = "forum.php">Форум</a> :: <a href = "forum.php?act=cat&id=' . $category['id'] . '">' . $name_cat . '</a> :: Добавить подфорум</center></div>';
echo '<div class="div">';
echo '<form action=forum.php?act=add_forum&id=' . $id . ' method=post>
Название: 100 символов<br/><textarea cols="20" rows="1" name="name"style="width: 30%;height: 20px;""></textarea><br/>
<input type=submit name="submit" value=Добавить class=submit white/ ></form>';
echo '</div>';
echo '<div class="title">';
echo '<img src="style/page/back.png" alt="Back"> <a href = "?sid=back" onclick="history.back()">Назад</a>';
echo '</div>';
require('foot.php');
}
}
} else {
require('head.php');
echo '<div class="title"><center><a href = "forum.php">Форум</a></center></div>';
error('Отказано в доступе!');
require('foot.php');
}
break;
//~~~~~~~~~~~~~~~Создание темы~~~~~~~~~~~~~//
case 'add_theme':
$flood = mysql_query("SELECT `time` FROM `forum_themes` WHERE `user` = '" . $u['id'] . "' AND `time` > '" . (time() - $system['forum_theme']) . "'");
if (mysql_num_rows($flood)) {
require('head.php');
error(' <b>Ошибка</b>!</br> Можно добавлять темы в форуме только раз в ' . $system['forum_theme'] . ' сек.');
require('foot.php');
exit;
}
if (isset($_GET['id'])) {
$id = num($_GET['id']);
$req = mysql_query("SELECT * FROM `forum_forums` WHERE `id` = '$id' LIMIT 1");
if (mysql_num_rows($req)) {
$forum = mysql_fetch_assoc($req);
}
}
if ($forum) {
$cat = mysql_fetch_assoc(mysql_query("SELECT * FROM `forum_categories` WHERE `id` = '" . $forum['cat'] . "' LIMIT 1"));
if (isset($_POST['submit']) and $_POST['name'] and $_POST['opis']) {
$name = check(substr($_POST['name'], 0, 100));
$opis = check(substr($_POST['opis'], 0, 50000));
$sex = num($_POST['18']);
$admin = num($_POST['admin']);
if (empty($name)) {
require('head.php');
error('Ошибка, так делать нельзя!');
$error = '1';
require('foot.php');
exit;
}
if (empty($error)) {
mysql_query("INSERT INTO `forum_themes` SET
`user` = '" . $u['id'] . "',
`name` = '$name',
`opis` = '$opis',
`18` = '$sex',
`admin` = '$admin',
`time` = '" . time() . "',
`forum` = '" . $forum['id'] . "',
`cat` = '" . $cat['id'] . "',
`ord` = '" . time() . "'
");
$id = mysql_insert_id();
mysql_query("UPDATE `users` SET
`stat_forum_themes` = `stat_forum_themes`+1
WHERE `id` = '" . $u['id'] . "'
");
mysql_query("UPDATE `users` SET
`stat_forum_messages` = `stat_forum_messages`+1
WHERE `id` = '" . $u['id'] . "'
");
mysql_query("UPDATE `users` SET `rating` = `rating`+20 WHERE `id` = '" . $u['id'] . "'");
if ($u['sex'] == 'm') {
$action[0] = 'Создал';
} else {
$action[0] = 'Создала';
}
$text = $action[0] . ' тему в <a href = "forum.php?act=theme&id=' . $id . '&cat=1">форуме</a>.';
mysql_query("INSERT INTO `lenta` SET
`user` = '" . $u['id'] . "',
`text` = '$text',
`time` = '" . time() . "',
`forum` = '1',
`blog` = '0',
`foto` = '0',
`diary` = '0',
`comm` = '0'
");
header("Location: forum.php?act=theme&id=$id");
}
} else {
$name_cat = $cat['name'];
$name_forum = $forum['name'];
$title = $title . ' :: Форум';
require('head.php');
echo '<div class="title"><center><a href = "forum.php">Форум</a>
:: <a href = "forum.php?act=cat&id=' . $cat['id'] . '">' . $name_cat . '</a>
:: <a href = "forum.php?act=forum&id=' . $forum['id'] . '">' . $name_forum . '</a> :: Новая тема</div>';
echo '</center><div class="div">';
echo '<form action=forum.php?act=add_theme&id=' . $id . ' method=post>
Тема: 100 символов<br/><textarea cols="20" rows="1" name="name"style="width: 30%;height: 20px;"></textarea>
</div><div class="div">
Сообщение: 50000 символов<br/><textarea cols="50000" rows="2" name="opis"></textarea></div>';
echo '<div class="div">';
echo '<input name="18" type="checkbox" value="1"/> Только для взрослых <font color="red">(18+)</font><br/>';
if ($u['admin'] == 1 || $u['admin'] == 2 || $u['admin'] == 3) {
echo '<input name="admin" type="checkbox" value="1"/> Доступ только администраторам и модераторам<br/>';
}
echo '</div><div class="div">';
echo '<input type=submit name="submit" value="Создать"/></form>';
}
echo '</div>';
require('foot.php');
}
break;
//~~~~~~~~~~~~~~~~~Редактирование категории~~~~~~~~~~~~//
case 'edit_cat':
$flood = mysql_query("SELECT `etime` FROM `forum_categories` WHERE `edit` = '" . $u['id'] . "' AND `etime` > '" . (time() - $system['cat_edit_forum_antiflud']) . "'");
if (mysql_num_rows($flood)) {
require('head.php');
error(' <b>Ошибка</b>!</br> Можно редактировать категорию только раз в ' . $system['cat_edit_forum_antiflud'] . ' сек.');
require('foot.php');
exit;
}
if ($u['admin'] == 1 || $u['admin'] == 2 || $u['admin'] == 3) {
if (isset($_GET['id'])) {
$id = num($_GET['id']);
$req = mysql_query("SELECT * FROM `forum_categories` WHERE `id` = '$id' LIMIT 1");
if (mysql_num_rows($req)) {
$cat = mysql_fetch_assoc($req);
}
}
if ($cat) {
if (isset($_POST['submit']) and isset($_POST['name']) and isset($_POST['opis'])) {
$name = check(substr($_POST['name'], 0, 100));
$opis = check(substr($_POST['opis'], 0, 100));
if (empty($name)) {
require('head.php');
error(' Ошибка, так делать нельзя!');
$error = '1';
require('foot.php');
exit;
}
if (empty($error)) {
mysql_query("UPDATE `forum_categories` SET
`name` = '$name',
`edit` = '" . $u['id'] . "',
`etime` = '" . time() . "',
`opis` = '$opis'
WHERE `id` = '$id'
");
if ($u['sex'] == 'm') {
$action[0] = 'Отредактировал';
} else {
$action[0] = 'Отредактировала';
}
$text = $action[0] . ' категорию в <a href = "/forum.php">форуме</a>.';
mysql_query("INSERT INTO `admin_jurnal` SET
`user` = '" . $u['id'] . "',
`text` = '$text',
`time` = '" . time() . "',
`news` = '0',
`forum` = '1',
`diary` = '0',
`chat` = '0',
`blog` = '0',
`foto` = '0',
`ban` = '0',
`edit` = '0',
`new` = '1'
");
header("Location: forum.php");
}
} else {
$title = $title . ' :: Форум';
require('head.php');
echo '<div class="title"><center><a href = "forum.php">Форум</a> Редактировать категорию</center></div>';
echo '<div class="div">';
$name = $cat['name'];
$opis = $cat['opis'];
echo '<form action="forum.php?act=edit_cat&id=' . $id . '" method="post">';
echo 'Название: 100 символов<br/><textarea cols="20" rows="1" name="name" style="width: 30%;height: 20px;">' . $name . '</textarea>';
echo '</div><div class="div">';
echo 'Описание: 100 символов<br/><textarea cols="20" rows="3" name="opis" >' . $opis . '</textarea>';
echo '</div><div class="div">';
echo '<input type="submit" name="submit" value="Сохранить" class="submit white"/>';
echo '</form>';
}
echo '</div>';
echo '<div class="title">';
echo '<img src="style/page/back.png" alt="Back"> <a href = "?sid=back" onclick="history.back()">Назад</a>';
echo '</div>';
require('foot.php');
} else {
require('head.php');
echo '<div class="title"><center><a href = "forum.php">Форум</a> :: <b>Ошибка</b></center></div>';
error(' Ошибка, такой категории нет!');
require('foot.php');
}
} else {
require('head.php');
echo '<div class="title"><center><a href = "forum.php">Форум</a> :: <b>Ошибка</b></center></div>';
error(' Отказано в доступе!');
require('foot.php');
}
break;
//~~~~~~~~~~~~~Удаление категории~~~~~~~~~~~~~~~~~~//
case 'delete_cat':
if ($u['admin'] == 1 || $u['admin'] == 2 || $u['admin'] == 3) {
$flood = mysql_query("SELECT `time` FROM `forum_deleted` WHERE `user` = '" . $u['id'] . "' AND `time` > '" . (time() - $system['deleted_forum_antiflud']) . "'");
if (mysql_num_rows($flood)) {
require('head.php');
error(' <b>Ошибка</b>!</br> Можно удалять категории только раз в ' . $system['deleted_forum_antiflud'] . ' сек.');
require('foot.php');
exit;
}
if (isset($_GET['id'])) {
$id = num($_GET['id']);
$req = mysql_query("SELECT * FROM `forum_categories` WHERE `id` = '$id' LIMIT 1");
if (mysql_num_rows($req)) {
$cat = mysql_fetch_assoc($req);
}
}
if ($cat) {
if (isset($_POST['submit'])) {
mysql_query("DELETE FROM `forum_categories` WHERE `id` = '" . $cat['id'] . "'");
mysql_query("DELETE FROM `forum_forums` WHERE `cat` = '" . $cat['id'] . "'");
mysql_query("DELETE FROM `forum_themes` WHERE `cat` = '" . $cat['id'] . "'");
mysql_query("DELETE FROM `forum_messages` WHERE `cat` = '" . $cat['id'] . "'");
mysql_query("INSERT INTO `forum_deleted` SET
`user` = '" . $u['id'] . "',
`time` = '" . time() . "'
");
if ($u['sex'] == 'm') {
$action[0] = 'Удалил';
} else {
$action[0] = 'Удалила';
}
$text = $action[0] . ' категорию в <a href = "/forum.php">форуме</a>.';
mysql_query("INSERT INTO `admin_jurnal` SET
`user` = '" . $u['id'] . "',
`text` = '$text',
`time` = '" . time() . "',
`news` = '0',
`forum` = '1',
`diary` = '0',
`chat` = '0',
`blog` = '0',
`foto` = '0',
`ban` = '0',
`edit` = '0',
`new` = '1'
");
header("Location: forum.php");
} else {
$title = $title . ' :: Форум';
require('head.php');
$name = $cat['name'];
echo '<div class="title"><center><a href = "forum.php">Форум</a> :: <a href = "forum.php?act=cat&id=' . $id . '">' . $name . '</a> :: Удалить категорию</center></div>';
echo '<div class="div">';
echo 'Вы уверены, что хотите удалить категорию "<a href = "forum.php?act=cat&id=' . $id . '"><b>' . $name . '</b></a>" и все находящиеся в ней темы?<br/>';
echo '<form action="forum.php?act=delete_cat&id=' . $id . '" method="post">';
echo '<input type="submit" name="submit" value="Да, удалить" class="submit white"/>';
echo '</form></div>';
echo '<div class="title">';
echo '<img src="style/page/back.png" alt="Back"> <a href = "?sid=back" onclick="history.back()">Назад</a>';
echo '</div>';
}
require('foot.php');
} else {
require('head.php');
echo '<div class="title"><center><a href = "forum.php">Форум</a> :: <b>Ошибка</b></center></div>';
error(' Ошибка, такой категории нет!');
require('foot.php');
}
} else {
require('head.php');
echo '<div class="title"><center><a href = "forum.php">Форум</a> :: <b>Ошибка</b></center></div>';
error(' Отказано в доступе!');
require('foot.php');
}
break;
//~~~~~~~~~~~~~Редактирование форума~~~~~~~~~~~~~~~~~~//
case 'edit_forum':
$flood = mysql_query("SELECT `etime` FROM `forum_forums` WHERE `edit` = '" . $u['id'] . "' AND `etime` > '" . (time() - $system['edit_forum_antiflud']) . "'");
if (mysql_num_rows($flood)) {
require('head.php');
error(' <b>Ошибка</b>!</br> Можно редактировать форум только раз в ' . $system['edit_forum_antiflud'] . ' сек.');
require('foot.php');
exit;
}
if ($u['admin'] == 1 || $u['admin'] == 2 || $u['admin'] == 3) {
if (isset($_GET['id'])) {
$id = num($_GET['id']);
$req = mysql_query("SELECT * FROM `forum_forums` WHERE `id` = '$id' LIMIT 1");
if (mysql_num_rows($req)) {
$forum = mysql_fetch_assoc($req);
}
}
if ($forum) {
$cat = mysql_fetch_assoc(mysql_query("SELECT * FROM `forum_categories` WHERE `id` = '" . $forum['cat'] . "' LIMIT 1"));
$name_cat = checkout($cat['name']);
if (isset($_POST['submit']) and $_POST['name']) {
$name = check(substr($_POST['name'], 0, 100));
if (empty($name)) {
require('head.php');
error(' Ошибка, так делать нельзя!');
$error = '1';
require('foot.php');
exit;
}
if (empty($error)) {
mysql_query("UPDATE `forum_forums` SET
`name` = '$name',
`edit` = '" . $u['id'] . "',
`etime` = '" . time() . "'
WHERE `id` = '$id'
");
if ($u['sex'] == 'm') {
$action[0] = 'Отредактировал';
} else {
$action[0] = 'Отредактировала';
}
$text = $action[0] . ' форум в <a href = "forum.php?act=cat&id=' . $cat['id'] . '">категории</a>.';
mysql_query("INSERT INTO `admin_jurnal` SET
`user` = '" . $u['id'] . "',
`text` = '$text',
`time` = '" . time() . "',
`news` = '0',
`forum` = '1',
`diary` = '0',
`chat` = '0',
`blog` = '0',
`foto` = '0',
`ban` = '0',
`edit` = '0',
`new` = '1'
");
header("Location: forum.php?act=cat&id=" . $cat['id'] . "");
}
} else {
$title = $title . ' :: Форум';
require('head.php');
echo '<div class="title"><center><a href = "forum.php">Форум</a> :: <a href = "forum.php?act=cat&id=' . $cat['id'] . '">' . $name_cat . '</a> :: Изменить подфорум</center></div>';
echo '<div class="div">';
$name = $forum['name'];
echo '<form action="forum.php?act=edit_forum&id=' . $id . '" method="post">';
echo 'Название (100 символов):<br/><textarea cols="20" rows="1" name="name" style="width: 30%;height: 30px;">' . $name . '</textarea><br/>';
echo '<input type="submit" name="submit" value="Изменить" class="submit white"/>';
echo '</form></div>';
echo '<div class="title">';
echo '<img src="style/page/back.png" alt="Back"> <a href = "?sid=back" onclick="history.back()">Назад</a>';
echo '</div>';
}
require('foot.php');
} else {
require('head.php');
echo '<div class="title"><center><a href = "forum.php">Форум</a> :: <b>Ошибка</b></center></div>';
error(' Ошибка, такого подфорума нет!');
require('foot.php');
}
} else {
require('head.php');
echo '<div class="title"><center><a href = "forum.php">Форум</a> :: <b>Ошибка</b></center></div>';
error(' Отказано в доступе!');
require('foot.php');
}
break;
//~~~~~~~~~~~~~Удаление форума~~~~~~~~~~//
case 'delete_forum':
if ($u['admin'] == 1 || $u['admin'] == 2 || $u['admin'] == 3) {
$flood = mysql_query("SELECT `time` FROM `forum_deleted` WHERE `user` = '" . $u['id'] . "' AND `time` > '" . (time() - $system['deleted_forum_antiflud']) . "'");
if (mysql_num_rows($flood)) {
require('head.php');
error(' <b>Ошибка</b>!</br> Можно удалять форум только раз в ' . $system['deleted_forum_antiflud'] . ' сек.');
require('foot.php');
exit;
}
if (isset($_GET['id'])) {
$id = num($_GET['id']);
$req = mysql_query("SELECT * FROM `forum_forums` WHERE `id` = '$id' LIMIT 1");
if (mysql_num_rows($req)) {
$forum = mysql_fetch_assoc($req);
}
}
if ($forum) {
$cat = mysql_fetch_assoc(mysql_query("SELECT * FROM `forum_categories` WHERE `id` = '" . $forum['cat'] . "' LIMIT 1"));
$name_cat = checkout($cat['name']);
if (isset($_POST['submit'])) {
mysql_query("DELETE FROM `forum_forums` WHERE `id` = '" . $forum['id'] . "'");
mysql_query("DELETE FROM `forum_themes` WHERE `forum` = '" . $forum['id'] . "'");
mysql_query("DELETE FROM `forum_messages` WHERE `forum` = '" . $forum['id'] . "'");
if ($u['sex'] == 'm') {
$action[0] = 'Удалил';
} else {
$action[0] = 'Удалила';
}
$text = $action[0] . ' форум в <a href = "forum.php?act=cat&id=' . $cat['id'] . '">категории</a>.';
mysql_query("INSERT INTO `admin_jurnal` SET
`user` = '" . $u['id'] . "',
`text` = '$text',
`time` = '" . time() . "',
`news` = '0',
`forum` = '1',
`diary` = '0',
`chat` = '0',
`blog` = '0',
`foto` = '0',
`ban` = '0',
`edit` = '0',
`new` = '1'
");
header("Location: forum.php?act=cat&id=" . $cat['id'] . "");
} else {
$title = $title . ' :: Форум';
require('head.php');
echo '<div class="title"><center><a href = "forum.php">Форум</a> :: <a href = "forum.php?act=cat&id=' . $cat['id'] . '">' . $name_cat . '</a> :: Удалить подфорум</center></div>';
echo '<div class="div">';
$name = $forum['name'];
echo 'Вы уверены, что хотите удалить форум "<a href = "forum.php?act=forum&id=' . $id . '"><b>' . $name . '</b></a>" и все находящиеся в ней темы ?<br/>';
echo '<form action="forum.php?act=delete_forum&id=' . $id . '" method="post">';
echo '<input type="submit" name="submit" value="Да, удалить" class="submit white"/>';
echo '</form></div>';
echo '<div class="title">';
echo '<img src="style/page/back.png" alt="Back"> <a href = "?sid=back" onclick="history.back()">Назад</a>';
echo '</div>';
}
require('foot.php');
} else {
require('head.php');
echo '<div class="title"><center><a href = "forum.php">Форум</a> :: <b>Ошибка</b></center></div>';
error(' Ошибка, такого подфорума нет!');
require('foot.php');
}
} else {
require('head.php');
echo '<div class="title"><center><a href = "forum.php">Форум</a> :: <b>Ошибка</b></center></div>';
error(' Отказано в доступе!');
require('foot.php');
}
break;
//~~~~~~~~~~~Удаление темы~~~~~~~~~~~~~//
case 'delete_theme':
if (isset($_GET['id'])) {
$id = num($_GET['id']);
$req = mysql_query("SELECT * FROM `forum_themes` WHERE `id` = '$id' LIMIT 1");
if (mysql_num_rows($req)) {
$tema = mysql_fetch_assoc($req);
}
}
if ($tema) {
$cat = mysql_fetch_assoc(mysql_query("SELECT * FROM `forum_categories` WHERE `id` = '" . $tema['cat'] . "' LIMIT 1"));
$forum = mysql_fetch_assoc(mysql_query("SELECT * FROM `forum_forums` WHERE `id` = '" . $tema['forum'] . "' LIMIT 1"));
$all = mysql_result(mysql_query("SELECT COUNT(*) FROM `forum_messages` WHERE `theme` = '" . $tema['id'] . "'"), 0);
if ($u['admin'] == 1 || $u['admin'] == 2 || $u['admin'] == 3) {
if (isset($_POST['submit'])) {
mysql_query("DELETE FROM `forum_themes` WHERE `id` = '" . $id . "'");
mysql_query("DELETE FROM `forum_messages` WHERE `theme` = '" . $id . "'");
if ($u['sex'] == 'm') {
$action[0] = 'Удалил';
} else {
$action[0] = 'Удалила';
}
$text = $action[0] . ' тему в <a href = "forum.php?act=forum&id=' . $forum['id'] . '">в форуме</a>.';
mysql_query("INSERT INTO `admin_jurnal` SET
`user` = '" . $u['id'] . "',
`text` = '$text',
`time` = '" . time() . "',
`news` = '0',
`forum` = '1',
`diary` = '0',
`chat` = '0',
`blog` = '0',
`foto` = '0',
`ban` = '0',
`edit` = '0',
`new` = '1'
");
header("Location: forum.php?act=forum&id=" . $forum['id'] . "");
} else {
$name_cat = $cat['name'];
$name_forum = $forum['name'];
$name_theme = $tema['name'];
$title = $title . ' :: Форум';
require('head.php');
echo '<div class="title"><center><a href = "forum.php">Форум</a> :: <a href = "forum.php?act=cat&id=' . $cat['id'] . '">' . $name_cat . '</a>
:: <a href = "forum.php?act=forum&id=' . $forum['id'] . '">' . $name_forum . '</a> :: <a href = "forum.php?act=theme&id=' . $tema['id'] . '">' . $name_theme . '</a></div>';
echo '</center><div class="div">';
$name = $cat['name'];
echo 'Удалить тему "<a href = "forum.php?act=theme&id=' . $id . '"><b>' . $name_theme . '</b></a>" ?<br/>';
echo '<form action="forum.php?act=delete_theme&id=' . $id . '" method="post">';
echo '<input type="submit" name="submit" value="Да, удалить" class="submit white"/>';
echo '</form></div>';
echo '<div class="title">';
echo '<img src="style/page/back.png" alt="Back"> <a href = "?sid=back" onclick="history.back()">Назад</a>';
echo '</div>';
require('foot.php');
}
} else {
require('head.php');
echo '<div class="title"><center><a href = "forum.php">Форум</a> :: <b>Ошибка</b></center></div>';
error(' Отказано в доступе!');
require('foot.php');
}
} else {
require('head.php');
echo '<div class="title"><center><a href = "forum.php">Форум</a> :: <b>Ошибка</b></center></div>';
error(' Такой темы нет!');
require('foot.php');
}
break;
//~~~~~~~~~~~~~~Изменение темы~~~~~~~~~~~~~~//
case 'edit_theme':
$flood = mysql_query("SELECT `etime` FROM `forum_themes` WHERE `who` = '" . $u['id'] . "' AND `etime` > '" . (time() - $system['edit_forum_theme']) . "'");
if (mysql_num_rows($flood)) {
require('head.php');
error(' <b>Ошибка</b>!</br> Можно редактировать тему только раз в ' . $system['edit_forum_theme'] . ' сек.');
require('foot.php');
exit;
}
if (isset($_GET['id'])) {
$id = num($_GET['id']);
$req = mysql_query("SELECT * FROM `forum_themes` WHERE `id` = '$id' LIMIT 1");
if (mysql_num_rows($req)) {
$tema = mysql_fetch_assoc($req);
}
}
if ($tema) {
$cat = mysql_fetch_assoc(mysql_query("SELECT * FROM `forum_categories` WHERE `id` = '" . $tema['cat'] . "' LIMIT 1"));
$forum = mysql_fetch_assoc(mysql_query("SELECT * FROM `forum_forums` WHERE `id` = '" . $tema['forum'] . "' LIMIT 1"));
$opis = mysql_fetch_assoc(mysql_query("SELECT * FROM `forum_forums` WHERE `id` = '" . $tema['forum'] . "' LIMIT 1"));
$name_cat = $cat['name'];
$name_forum = $forum['name'];
$name_theme = $tema['name'];
$opis = checkout($tema['opis']);
if ($tema['user'] == $u['id'] || $u['admin'] == 1 || $u['admin'] == 2 || $u['admin'] == 3) {
if (isset($_POST['submit']) and $_POST['name'] and $_POST['opis']) {
$name = check(substr($_POST['name'], 0, 100));
$opis = check(substr($_POST['opis'], 0, 50000));
$sex = num($_POST['18']);
$admin = num($_POST['admin']);
if (empty($name)) {
require('head.php');
error(' Ошибка , так делать нельзя !');
$error = '1';
require('foot.php');
exit;
}
if (empty($error)) {
mysql_query("UPDATE `forum_themes` SET
`name` = '$name'
WHERE `id` = '" . $tema['id'] . "'
");
mysql_query("UPDATE `forum_themes` SET
`opis` = '$opis',
`18` = '$sex',
`who` = '" . $u['id'] . "'
WHERE `id` = '" . $tema['id'] . "'
");
mysql_query("UPDATE `forum_themes` SET
`cedit` = `cedit`+1
WHERE `id` = '" . $tema['id'] . "'
");
mysql_query("UPDATE `forum_themes` SET
`etime` = '" . time() . "'
WHERE `id` = '" . $tema['id'] . "'
");
if ($u['admin'] >= 1) {
mysql_query("UPDATE `forum_themes` SET
`admin` = '$admin'
WHERE `id` = '" . $tema['id'] . "'
");
}
if ($u['admin'] == 1 || $u['admin'] == 2 || $u['admin'] == 3) {
if ($u['sex'] == 'm') {
$action[0] = 'Отредактировал';
} else {
$action[0] = 'Отредактировала';
}
$text = $action[0] . ' тему в <a href = "forum.php?act=theme&id=' . $tema['id'] . '"> форуме</a>.';
mysql_query("INSERT INTO `admin_jurnal` SET
`user` = '" . $u['id'] . "',
`text` = '$text',
`time` = '" . time() . "',
`news` = '0',
`forum` = '1',
`diary` = '0',
`chat` = '0',
`blog` = '0',
`foto` = '0',
`ban` = '0',
`edit` = '0',
`new` = '1'
");
}
header("Location: forum.php?act=theme&id=" . $tema['id'] . "");
}
} else {
$title = $title . ' :: Форум';
require('head.php');
echo '<div class="title"><center><a href = "forum.php">Форум</a> :: <a href = "forum.php?act=theme&id=' . $tema['id'] . '">' . $name_theme . '</a> :: Изменить тему</center></div>';
echo '<div class="div">';
$name = $tema['name'];
$opis = $tema['opis'];
echo '<form action="forum.php?act=edit_theme&id=' . $id . '" method="post">';
echo 'Тема (100 символов):<br/><textarea cols="20" rows="1" name="name"style="width: 30%;height: 20px;">' . $name . '</textarea>';
echo '</div><div class="div">';
echo 'Сообщение (50000 символов):<br/><textarea cols="20" rows="3" name="opis">' . $opis . '</textarea><br/>';
echo '</div><div class="div">';
echo '<input name="18" type="checkbox" value="1"' . ($tema["18"] == 1 ? ' checked' : '') . '/> Только для взрослых <font color="red">(18+)</font><br/>';
if ($u['admin'] >= 1) {
echo '<input name="admin" type="checkbox" value="1"' . ($tema["admin"] == 1 ? ' checked' : '') . '/> Доступ только администраторам и модераторам<br/>';
}
echo '</div><div class="div">';
echo '<input type="submit" name="submit" value="Изменить" class="submit white"/>';
echo '</form></div>';
}
require('foot.php');
} else {
require('head.php');
echo '<div class="title"><center><a href = "forum.php">Форум</a> :: <b>Ошибка</b></center></div>';
error(' Отказано в доступе!');
require('foot.php');
}
} else {
require('head.php');
echo '<div class="title"><center><a href = "forum.php">Форум</a> :: <b>Ошибка</b></center></div>';
error(' Ошибка, такой темы нет!');
require('foot.php');
}
break;
//~~~~~~~~~~~Изменение сообщения~~~~~~~~~~~~~//
case 'edit_message':
$flood = mysql_query("SELECT `etime` FROM `forum_messages` WHERE `user` = '" . $u['id'] . "' AND `etime` > '" . (time() - $system['edit_comm_forum_theme']) . "'");
if (mysql_num_rows($flood)) {
require('head.php');
error(' <b>Ошибка</b>!</br> Можно редактировать сообщение только раз в ' . $system['edit_comm_forum_theme'] . ' сек.');
require('foot.php');
exit;
}
if (isset($_GET['id'])) {
$id = num($_GET['id']);
$req = mysql_query("SELECT * FROM `forum_messages` WHERE `id` = '$id' LIMIT 1");
if (mysql_num_rows($req)) {
$msg = mysql_fetch_assoc($req);
}
}
if ($msg) {
$cat = mysql_fetch_assoc(mysql_query("SELECT * FROM `forum_categories` WHERE `id` = '" . $msg['cat'] . "' LIMIT 1"));
$forum = mysql_fetch_assoc(mysql_query("SELECT * FROM `forum_forums` WHERE `id` = '" . $msg['forum'] . "' LIMIT 1"));
$tema = mysql_fetch_assoc(mysql_query("SELECT * FROM `forum_themes` WHERE `id` = '" . $msg['theme'] . "' LIMIT 1"));
$name_cat = $cat['name'];
$name_forum = $forum['name'];
$name_theme = $tema['name'];
if ($msg['user'] == $u['id'] || $u['admin'] == 1 || $u['admin'] == 2 || $u['admin'] == 3) {
if (isset($_POST['submit']) and $_POST['message']) {
$message = check(substr($_POST['message'], 0, 10000));
if (empty($message)) {
require('head.php');
error(' <div class="div"> Ошибка, так делать нельзя!');
$error = '1';
require('foot.php');
exit;
}
if (empty($error)) {
mysql_query("UPDATE `forum_messages` SET
`message` = '$message'
WHERE `id` = '" . $msg['id'] . "'
");
mysql_query("UPDATE `forum_messages` SET
`cedit` = `cedit`+1
WHERE `id` = '" . $msg['id'] . "'
");
mysql_query("UPDATE `forum_messages` SET
`etime` = '" . time() . "'
WHERE `id` = '" . $msg['id'] . "'
");
header("Location: forum.php?act=theme&id=" . $tema['id'] . "");
}
} else {
$title = $title . ' :: Форум';
require('head.php');
echo '<div class="title"><center><a href = "forum.php">Форум</a> :: <a href = "forum.php?act=cat&id=' . $cat['id'] . '">' . $name_cat . '</a>
:: <a href = "forum.php?act=forum&id=' . $forum['id'] . '">' . $name_forum . '</a> :: <a href = "forum.php?act=theme&id=' . $tema['id'] . '">' . $name_theme . '</a></div>';
echo '</center><div class="div">';
$message = $msg['message'];
echo '<form action="forum.php?act=edit_message&id=' . $id . '" method="post">';
echo 'Сообщение (10000 символов):<br/><textarea name="message">' . $message . '</textarea><br/>';
echo '<input type="submit" name="submit" value="Изменить" class="submit white"/>';
echo '</form></div>';
echo '<div class="title">';
echo '<img src="style/page/back.png" alt="Back"> <a href = "?sid=back" onclick="history.back()">Назад</a>';
echo '</div>';
}
require('foot.php');
} else {
require('head.php');
echo '<div class="title"><center><a href = "forum.php">Форум</a> :: <b>Ошибка</b></center></div>';
error(' Отказано в доступе!');
require('foot.php');
}
} else {
require('head.php');
echo '<div class="title"><center><a href = "forum.php">Форум</a> :: <b>Ошибка</b></center></div>';
error(' Ошибка, такого сообщения нет!');
require('foot.php');
}
break;
//~~~~~~~~~~~~~~~~~~~Ответ~~~~~~~~~~~~~//
case 'answer':
if (!$u['id']) {
header("Location: reg.php?err=1");
exit;
}
$flood = mysql_query("SELECT `time` FROM `forum_messages` WHERE `user` = '" . $u['id'] . "' AND `time` > '" . (time() - 10) . "'");
if (mysql_num_rows($flood)) {
require('head.php');
error(' <b>Ошибка</b>!</br> Можно добавлять сообщение только раз в 10 сек.');
require('foot.php');
exit;
}
if (isset($_GET['id'])) {
$id = num($_GET['id']);
$req = mysql_query("SELECT * FROM `forum_messages` WHERE `id` = '$id' LIMIT 1");
if (mysql_num_rows($req)) {
$msg = mysql_fetch_assoc($req);
}
}
if ($msg) {
$cat = mysql_fetch_assoc(mysql_query("SELECT * FROM `forum_categories` WHERE `id` = '" . $msg['cat'] . "' LIMIT 1"));
$forum = mysql_fetch_assoc(mysql_query("SELECT * FROM `forum_forums` WHERE `id` = '" . $msg['forum'] . "' LIMIT 1"));
$tema = mysql_fetch_assoc(mysql_query("SELECT * FROM `forum_themes` WHERE `id` = '" . $msg['theme'] . "' LIMIT 1"));
$name_cat = $cat['name'];
$name_forum = $forum['name'];
$name_theme = $tema['name'];
if ($msg['user'] == $u['id'] || $tema['close'] == 1) {
require('head.php');
error(' Отказано в доступе!');
require('foot.php');
exit;
}
if (isset($_POST['submit']) and $_POST['message']) {
$message = check(substr($_POST['message'], 0, 10000));
if (empty($message)) {
require('head.php');
error(' Ошибка, так делать нельзя!');
$error = '1';
require('foot.php');
exit;
}
if (empty($error)) {
mysql_query("INSERT INTO `forum_messages` SET
`user` = '" . $u['id'] . "',
`message` = '$message',
`time` = '" . time() . "',
`theme` = '" . $tema['id'] . "',
`forum` = '" . $forum['id'] . "',
`cat` = '" . $cat['id'] . "'
");
mysql_query("UPDATE `forum_themes` SET
`ord` = '" . time() . "'
WHERE `id` = '" . $tema['id'] . "'
");
mysql_query("UPDATE `users` SET
`stat_forum_messages` = `stat_forum_messages`+1
WHERE `id` = '" . $u['id'] . "'
");
if ($u['sex'] == 'm') {
$action[0] = 'Прокомментировал';
} else {
$action[0] = 'Прокомментировала';
}
$text = $action[0] . ' тему в <a href = "forum.php?act=theme&id=' . $tema['id'] . '&cat=1">форуме</a>.';
mysql_query("INSERT INTO `lenta` SET
`user` = '" . $u['id'] . "',
`text` = '$text',
`time` = '" . time() . "',
`forum` = '1',
`blog` = '0',
`foto` = '0',
`diary` = '0',
`comm` = '1'
");
if ($tema['user'] != $u['id']) {
if ($msg['id'] != $u['id']) {
if ($u['sex'] == 'm') {
$action[0] = 'Оставил';
} else {
$action[0] = 'Оставила';
}
$text = $action[0] . ' сообщение в вашей <a href = "forum.php?act=theme&id=' . $tema['id'] . '&cat=1">теме</a>.';
mysql_query("INSERT INTO `jurnal` SET
`user` = '" . $tema['user'] . "',
`outuser` = '" . $u['id'] . "',
`text` = '$text',
`time` = '" . time() . "',
`new` = '1'
");
}
}
if ($msg['id'] != $u['id']) {
if ($u['sex'] == 'm') {
$action[0] = 'Ответил';
} else {
$action[0] = 'Ответила';
}
$text = $action[0] . ' вам в <a href = "forum.php?act=theme&id=' . $tema['id'] . '&cat=1">форуме</a>.';
mysql_query("INSERT INTO `jurnal` SET
`user` = '" . $msg['user'] . "',
`outuser` = '" . $u['id'] . "',
`text` = '$text',
`time` = '" . time() . "',
`new` = '1'
");
}
header("Location: forum.php?act=theme&id=" . $tema['id'] . "");
}
} else {
$title = $title . ' :: Форум';
require('head.php');
echo '<div class="title"><center><a href = "forum.php">Форум</a> :: Ответить</center></div>';
echo '<div class="div">';
echo 'Ответ <a href = "page.php?id=' . $msg['user'] . '">' . login($msg['user']) . '</a>:<br/>';
echo '<form action="forum.php?act=answer&id=' . $id . '" method="post">';
echo '<textarea name="message">[u]' . login($msg['user']) . '[/u], </textarea><br/>';
echo '<input type="submit" name="submit" value="Ответить" class="submit white"/>';
echo '<small><a href = "smiles.php">Смайлы</a> | <a href = "code.php">Теги</a></small>';
echo '</form>';
echo '</div>';
echo '<div class="title">';
echo '<img src="style/page/back.png" alt="Back"> <a href = "?sid=back" onclick="history.back()">Назад</a>';
echo '</div>';
require('foot.php');
}
} else {
require('head.php');
echo '<div class="title"><center><a href = "forum.php">Форум</a> :: <b>Ошибка</b></center></div>';
error(' Ошибка, такого сообщения нет!');
require('foot.php');
}
break;
//~~~~~~~~~~~~~~~~~Просмотр темы~~~~~~~~~~~~~//
case 'theme':
if (isset($_GET['id'])) {
$id = num($_GET['id']);
$req = mysql_query("SELECT * FROM `forum_themes` WHERE `id` = '$id' LIMIT 1");
if (mysql_num_rows($req)) {
$tema = mysql_fetch_assoc($req);
}
}
if (@$tema) {
$cat = mysql_fetch_assoc(mysql_query("SELECT * FROM `forum_categories` WHERE `id` = '" . $tema['cat'] . "' LIMIT 1"));
$forum = mysql_fetch_assoc(mysql_query("SELECT * FROM `forum_forums` WHERE `id` = '" . $tema['forum'] . "' LIMIT 1"));
$name_cat = $cat['name'];
$name_forum = $forum['name'];
$name_theme = $tema['name'];
$them = checkout($tema['opis']);
if ($tema['close'] == 0 and $u['id']) {
if (@$_POST['message']) {
$message = check(substr($_POST['message'], 0, 10000));
if (empty($message)) {
require('head.php');
error(' Ошибка, так делать нельзя !');
$error = 1;
require('foot.php');
exit;
}
$flood = mysql_query("SELECT `time` FROM `forum_messages` WHERE `user` = '" . $u['id'] . "' AND `time` > '" . (time() - 5) . "'");
if (mysql_num_rows($flood)) {
header("Location: forum.php?act=theme&id=$id");
exit;
}
if (empty($error)) {
mysql_query("INSERT INTO `forum_messages` SET
`user` = '" . $u['id'] . "',
`message` = '$message',
`time` = '" . time() . "',
`theme` = '$id',
`forum` = '" . $forum['id'] . "',
`cat` = '" . $cat['id'] . "'
");
mysql_query("UPDATE `forum_themes` SET
`ord` = '" . time() . "'
WHERE `id` = '$id'
");
mysql_query("UPDATE `users` SET
`stat_forum_messages` = `stat_forum_messages`+1
WHERE `id` = '" . $u['id'] . "'
");
if ($u['sex'] == 'm') {
$action[0] = 'Прокомментировал';
} else {
$action[0] = 'Прокомментировала';
}
$text = $action[0] . ' тему в <a href = "forum.php?act=theme&id=' . $id . '&cat=1">форуме</a>.';
mysql_query("INSERT INTO `lenta` SET
`user` = '" . $u['id'] . "',
`text` = '$text',
`time` = '" . time() . "',
`forum` = '1',
`blog` = '0',
`foto` = '0',
`diary` = '0',
`comm` = '1'
");
if ($tema['user'] != $u['id']) {
if ($u['sex'] == 'm') {
$action[0] = 'Оставил';
} else {
$action[0] = 'Оставила';
}
$text = $action[0] . ' сообщение в вашей <a href = "forum.php?act=theme&id=' . $id . '&cat=1">теме</a>.';
mysql_query("INSERT INTO `jurnal` SET
`user` = '" . $tema['user'] . "',
`outuser` = '" . $u['id'] . "',
`text` = '$text',
`time` = '" . time() . "',
`new` = '1'
");
}
header("Location: forum.php?act=theme&id=$id&");
}
}
}
if ($u['admin'] >= 1) {
if (@$_GET['del']) {
$del = intval($_GET['del']);
$message = mysql_num_rows(mysql_query("SELECT * FROM `forum_messages` WHERE `id` = '$del' and `main` = '0'"));
if ($message) {
mysql_query("DELETE FROM `forum_messages` WHERE `id` = '$del' LIMIT 1");
header("Location: forum.php?act=theme&id=$id");
}
}
}
if ($u['admin'] == 1 || $u['admin'] == 2 || $u['admin'] == 3) {
@$close = num($_GET['close']);
if ($tema['close'] == 0 and $close == 1) {
mysql_query("UPDATE `forum_themes` SET
`close` = '1',
`close_id` = '" . $u['id'] . "'
WHERE `id` = '$id'
");
$tema['close_id'] = $u['id'];
header("Location: forum.php?act=theme&id=$id");
}
if ($tema['close'] == 1 and $close == 2) {
mysql_query("UPDATE `forum_themes` SET
`close` = '0'
WHERE `id` = '$id'
");
$tema['close'] = 0;
}
}
if ($u['admin'] == 1 || $u['admin'] == 2 || $u['admin'] == 3) {
@$fix = num($_GET['fix']);
if ($tema['fix'] == 0 and $fix == 1) {
mysql_query("UPDATE `forum_themes` SET
`fix` = '1'
WHERE `id` = '$id'
");
header("Location: forum.php?act=theme&id=$id");
}
if ($tema['fix'] == 1 and $fix == 2) {
mysql_query("UPDATE `forum_themes` SET
`fix` = '0'
WHERE `id` = '$id'
");
$tema['fix'] = 0;
}
}
$themeusers = mysql_fetch_assoc(mysql_query("SELECT * FROM `users` WHERE `id` = '" . $tema["user"] . "'"));
$themeclose = mysql_fetch_assoc(mysql_query("SELECT * FROM `users` WHERE `id` = '" . $tema["close_id"] . "'"));
$title = $title . ' :: Форум';
require('head.php');
require('core/bb_code.php');
require('core/panel.php');
echo '<div class="title">';
echo '<center><a href = "forum.php">Форум</a> :: <a href = "forum.php?act=cat&id=' . $cat['id'] . '">' . $name_cat . '</a>
:: <a href = "forum.php?act=forum&id=' . $forum['id'] . '">' . $name_forum . '</a>';
echo '</center></div>';
if (@$_GET['cat'] and $tema['18'] == 1) {
echo '<div class="div"> <font color="red">
Внимание! Это содержимое только для взрослых!</font></br>
Нажимая ДА, Вы подтверждаете, что Вам 18 или более лет.</br>
Если Вам менее 18 лет - нажмите НЕТ.</br>
<a href = "forum.php?act=theme&id=' . $tema['id'] . '">Да</a> |
<a href="?sid=Back" onclick="history.back()">Нет</a>
</div>';
require('foot.php');
exit;
}
if ($tema['admin'] == 1 and $u['admin'] == 0) {
error(' Отказано в доступе!');
require('foot.php');
exit;
}
echo '<div class="div">';
echo '' . ico($themeusers['sex'], $themeusers['admin'], $themeusers['online']) . ' <a href = "page.php?id=' . $tema['user'] . '"><b><font color="#79358c">' . login($tema['user']) . '</font></b></a>';
echo '' . medal($themeusers['rating']) . '';
echo '<span style="float:right;font-size: small; color:grey">(' . vremya($tema['time']) . ')</span>';
echo '<br /><b>' . $name_theme . '</b>';
if ($tema['close'] == 1) {
echo ' <img src="style/page/lock.gif" alt="image" /> ';
}
if ($tema['18'] == 1) {
echo ' <font color="red">18+</font> ';
}
echo '<br />';
echo '' . smile(links(bb_code($them))) . '<br /><small>';
if ($tema['user'] == $u['id']) {
if ($tema['time'] >= time() - 600)
echo ' [<a href = "forum.php?act=edit_theme&id=' . $id . '">ред</a>] ';
}
if($u['admin'] == 1 || $u['admin'] == 2 || $u['admin'] == 3)
{
echo ' [<a href = "forum.php?act=edit_theme&id=' . $id . '">ред</a>] ';
}
if ($u['admin'] == 1 || $u['admin'] == 2 || $u['admin'] == 3) {
echo '[<a href = "forum.php?act=delete_theme&id=' . $id . '">удалить</a>]';
if ($tema['close'] == 0) {
echo ' [<a href = "forum.php?act=theme&id=' . $id . '&close=1">Закрыть</a>] ';
} else {
echo ' [<a href = "forum.php?act=theme&id=' . $id . '&close=2">Открыть</a>] ';
}
if ($tema['fix'] == 0) {
echo ' [<a href = "forum.php?act=theme&id=' . $id . '&fix=1">Закрепить</a>] ';
} else {
echo ' [<a href = "forum.php?act=theme&id=' . $id . '&fix=2">Открепить</a>] ';
}
}
if ($u['admin'] == 1 || $u['admin'] == 2 || $u['admin'] == 3 and $u['id'] != $tema['user'])
echo ' [<a href = "adminka.php?act=ban_users&id=' . $tema['user'] . '"><font color="red">Бан</font></a>]';
echo '</small></div>';
if ($tema['cedit'] == 1){
echo '<div class="div">';
echo 'Последний раз редактировалось: <a href = "page.php?id=' . $tema['who'] . '"><b><font color="#79358c">' . login($tema['who']) . '</font></b></a> [' . vremya($tema['etime']) . '] [' . $tema['cedit'] . ' раз]</div>';
}
if ($themeclose['admin'] == '1' || $themeclose['admin'] == '2') {
$action[0] = 'администратором';
} else {
$action[0] = 'модератором';
}
if ($tema['close'] == 1){
echo '<div style="color:white;font-size:small;background-color:#999999;margin-top:0px;padding-left:5px;padding-bottom:2px;border:1px dotted darkred">';
echo 'Тема закрыта ' . $action[0] . ' <a href = "page.php?id=' . $tema['close_id'] . '"><b><font color="#79358c">' . login($tema['close_id']) . '</font></b></a></div>';
}
$all = mysql_result(mysql_query("SELECT COUNT(*) FROM `forum_messages` WHERE `theme` = '" . $tema['id'] . "'"), 0);
if ($all > 0) {
$total = num(($all - 1) / 10) + 1;
@$page = num($_GET['page']);
if (empty($page) or $page < 0)
$page = 1;
if ($page > $total)
$page = $total;
$start = $page * 10 - 10;
echo '<div class="title">';
echo ' Комментарии: (' . $all . ')';
echo '</div>';
if ($all >= 11)
echo '<div class="title">';
@$sort = check($_GET['sort']);
if ($sort == 'message') {
$sortq = 'ASC';
if ($all >= 11)
echo '<a href = "forum.php?act=theme&id=' . $id . '&sort=time&page=' . $page . '">Новые</a> | <b>Поcледние</b>';
}
if ($sort == 'time' || empty($sortq)) {
$sort = 'time';
$sortq = 'DESC';
if ($all >= 11)
echo '<b>Новые</b> | <a href = "forum.php?act=theme&id=' . $id . '&sort=message&page=' . $page . '">Поcледние</a>';
}
if ($all >= 11)
echo '</div>';
$result = mysql_query("SELECT * FROM `forum_messages` WHERE `theme` = '" . $tema['id'] . "' ORDER BY `time` $sortq LIMIT $start, 10");
while ($msg = mysql_fetch_assoc($result)) {
$user = mysql_fetch_assoc(mysql_query("SELECT * FROM `users` WHERE `id` = '" . $msg["user"] . "'"));
$message = checkout($msg['message']);
echo '<div class="div">';
if ($tema['user'] == $user['id'])
echo '<span style="float: right; font-size: x-small; color: grey"> / Автор</span>';
if ($user['delete'] == 1) {
echo '' . ico($user['sex'], $user['admin'], $user['online']) . ' <a href = "page.php?id=' . $user['id'] . '"><del><b><font color="#79358c">' . $user['login'] . '</font></b></del></a>';
} else {
echo '' . ico($user['sex'], $user['admin'], $user['online']) . ' <a href = "page.php?id=' . $user['id'] . '"><b><font color="#79358c">' . $user['login'] . '</font></b></a>';
}
echo '' . medal($user['rating']) . '';
echo '<span style="float:right;color:grey;">' . vremya($msg['time']) . '</span>';
echo '<br/>';
echo '' . smile(links(bb_code($message))) . '';
echo '</br>';
echo '<small>';
if ($tema['close'] == 0 and $u['id']) {
if ($msg['user'] != $u['id'])
echo '[<a href = "forum.php?act=answer&id=' . $msg['id'] . '">ответить</a>]';
}
if ($msg['main'] == 0 && $msg['user'] == $u['id']) {
if ($msg['time'] >= time() - 600)
echo ' [<a href = "forum.php?act=edit_message&id=' . $msg['id'] . '"><font color="green">ред</font></a>] ';
}
if ($u['admin'] >= 1) {
echo ' [<a href = "forum.php?act=theme&id=' . $id . '&del=' . $msg['id'] . '">удалить</a>]';
if (ban($user['id'])) {
if ($msg['user'] != $u['id'])
echo ' [<a href = "adminka.php?act=delban_users&id=' . $user['id'] . '"><font color="red">Разбанить</font></a>]';
} else {
if ($msg['user'] != $u['id'])
echo ' [<a href = "adminka.php?act=ban_users&id=' . $user['id'] . '"><font color="red">Бан</font></a>]';
}
}
echo '</small>';
echo '</div>';
}
echo '</div>';
navigation($page, $total, 'forum.php?act=theme&id=' . $id . '&sort=' . $sort . '&');
}
echo '</div>';
if ($u['id']) {
if ($tema['close'] == 0) {
echo '<div class="div">';
echo '<form action="forum.php?act=theme&id=' . $id . '&del=' . @$msg['id'] . '" method="post" name="form">';
echo '<textarea name="message">';
echo '</textarea><br/>';
echo "<input type='submit' title='Нажмите для отправки' name='submit' value='Написать'> <small><a href = 'smiles.php'>Смайлы</a>
| <a href = 'code.php'>Теги</a></small>
</form></div>";
}
} else {
echo '<div class="title">Извините, добавление комментариев доступно только зарегистрированным пользователям.
Регистрация быстрая и бесплатная.</div>';
}
require('foot.php');
} else {
require('head.php');
echo '<div class="title"><center><a href = "forum.php">Форум</a> <b>Ошибка</b></center></div>';
echo '<div class="div">';
echo '<table><tr><td VALIGN=top><img src="style/error/notice.png" alt="Ошибка" /></td><td VALIGN=top>Тема не найдена, возможно она была удалена ранее!</table></div>';
echo '</div>';
echo '<div class="title">';
echo '<img src="style/page/back.png" alt="Back"> <a href = "?sid=back" onclick="history.back()">Назад</a>';
echo '</div>';
require('foot.php');
}
break;
//-------------------------------Просмотр форума-------------------------------//
case 'forum':
if (isset($_GET['id'])) {
$id = num($_GET['id']);
$req = mysql_query("SELECT * FROM `forum_forums` WHERE `id` = '$id' LIMIT 1");
if (mysql_num_rows($req)) {
$forum = mysql_fetch_assoc($req);
}
}
if ($forum) {
$cat = mysql_fetch_assoc(mysql_query("SELECT * FROM `forum_categories` WHERE `id` = '" . $forum['cat'] . "' LIMIT 1"));
$name_cat = checkout($cat['name']);
$name_forum = checkout($forum['name']);
$title = $title . ' :: Форум';
require('head.php');
echo '<div class="title"><center>';
echo '<a href = "forum.php">Форум</a> :: <a href = "forum.php?act=cat&id=' . $cat['id'] . '">' . $name_cat . '</a> :: <a href = "forum.php?act=forum&id=' . $forum['id'] . '">' . $name_forum . '</a>';
echo '</center></div>';
if ($u['id']) {
echo '<div class="title">';
echo '<img src="style/page/add.gif" alt="!"/> <a href = "forum.php?act=add_theme&id=' . $forum['id'] . '"><b>Создать тему</b></a>';
echo '</div>';
}
$all = mysql_result(mysql_query("SELECT COUNT(*) FROM `forum_themes` WHERE `forum` = '" . $forum['id'] . "'"), 0);
if ($all > 0) {
$total = intval(($all - 1) / 10) + 1;
$page = num(@$_GET['page']);
if (empty($page) or $page < 0)
$page = 1;
if ($page > $total)
$page = $total;
$start = $page * 10 - 10;
if ($all >= 11)
echo '<div class="title">';
$sort = check(@$_GET['sort']);
if ($sort == 'ord') {
$sortq = 'time';
if ($all >= 11)
echo '<a href = "forum.php?act=forum&id=' . $forum['id'] . '&sort=fix&page=' . $page . '">Поcледние</a> | <b>Новые</b>';
}
if ($sort == 'fix' || empty($sortq)) {
$sort = 'fix';
$sortq = 'fix';
if ($all >= 11)
echo '<b>Поcледние</b> | <a href = "forum.php?act=forum&id=' . $forum['id'] . '&sort=ord&page=' . $page . '">Новые</a>';
}
if ($all >= 11)
echo '</div>';
$result = mysql_query("SELECT * FROM `forum_themes` WHERE `forum` = '" . $forum['id'] . "' ORDER BY $sortq DESC LIMIT $start, 10");
while ($theme = mysql_fetch_assoc($result)) {
echo '<div class="div">';
$end = mysql_query("SELECT `user`,`time` FROM `forum_themes` WHERE `id` = '" . $theme['id'] . "' ORDER BY `fix` DESC");
$end_msg = mysql_fetch_array($end);
$count = mysql_result(mysql_query("SELECT COUNT(`id`) FROM `forum_messages` WHERE `theme` = '" . $theme['id'] . "'"), 0);
$all_page = intval(($count - 1) / 10) + 1;
$name = checkout($theme['name']);
$who = checkout(@$theme['login']);
if ($theme['fix'] == 1) {
echo '<img src="style/page/stick.gif" alt=""/> ';
}
echo '<a href = "forum.php?act=theme&id=' . $theme['id'] . '&cat=1">' . $name . '</a> <font color="green">(' . vremya($end_msg['time']) . ')</font> (' . $count . ')</a>';
if ($theme['18'] == 1) {
echo ' <font color="red">18+</font>';
}
if ($theme['close'] == 1)
echo '<span style="float:right;"><img src="style/page/lock.gif" alt="image" /></span>';
echo '<br />';
echo 'Автор: <a href = "page.php?id=' . $theme['user'] . '"><b><font color="#79358c">' . login($theme['user']) . '</font></b></a>';
if ($u['admin'] == 1 || $u['admin'] == 2 || $u['admin'] == 3) {
echo '<br><small><a href = "forum.php?act=edit_theme&id=' . $theme['id'] . '">Изменить</a> - <a href = "forum.php?act=delete_theme&id=' . $theme['id'] . '">Удалить</a></small>';
}
echo '</div>';
}
echo '</div>';
navigation($page, $total, 'forum.php?act=forum&id=' . $forum['id'] . '&sort=' . $sort . '&');
}
if ($u['id']) {
echo '<div class="title">';
echo '<img src="style/page/add.gif" alt="!"/> <a href = "forum.php?act=add_theme&id=' . $forum['id'] . '"><b>Создать тему</b></a>';
echo '</div>';
}
require('foot.php');
} else {
require('head.php');
echo '<div class="title"><center><a href = "forum.php">Форум</a> :: Ошибка!</center></div>';
error(' Такого форума нет!');
require('foot.php');
}
break;
//--------------------------------------Просмотр категории---------------------------------//
case 'cat':
if (isset($_GET['id'])) {
$id = num($_GET['id']);
$req = mysql_query("SELECT * FROM `forum_categories` WHERE `id` = '$id' LIMIT 1");
if (mysql_num_rows($req)) {
$category = mysql_fetch_assoc($req);
}
}
if ($category) {
$name = $category['name'];
$title = $title . ' :: Форум';
require('head.php');
$cat = mysql_fetch_assoc(mysql_query("SELECT * FROM `forum_categories` WHERE `id`"));
echo '<div class="title"><center>';
echo '<a href = "forum.php">Форум</a> :: <a href = "forum.php?act=cat&id=' . $category['id'] . '">' . $name . '</a>';
echo '</center></div>';
if ($u['admin'] == 1 || $u['admin'] == 2 || $u['admin'] == 3) {
echo '<div class="title"><img src="style/page/add.gif" alt="!"/> <a href = "forum.php?act=add_forum&id=' . $category['id'] . '">Добавить форум</a> / <a href = "forum.php?act=cat&id=' . $category['id'] . '&info=1">Информация</a></div>';
}
$all = mysql_result(mysql_query("SELECT COUNT(*) FROM `forum_forums` WHERE `cat` = '" . $category['id'] . "'"), 0);
if ($all > 0) {
$total = intval(($all - 1) / 15) + 1;
@$page = num($_GET['page']);
if (empty($page) or $page < 0)
$page = 1;
if ($page > $total)
$page = $total;
$start = $page * 15 - 15;
$result = mysql_query("SELECT * FROM `forum_forums` WHERE `cat` = '" . $category['id'] . "' ORDER BY `ord` DESC LIMIT $start, 15");
while ($forum = mysql_fetch_assoc($result)) {
echo'<div class="div">';
$count = mysql_result(mysql_query("SELECT COUNT(`id`) FROM `forum_themes` WHERE `forum` = '" . $forum['id'] . "'"), 0);
$name = checkout($forum['name']);
if ($u['admin'] == 1 || $u['admin'] == 2 || $u['admin'] == 3) {
echo '<span style="float:right;"> <a href = "forum.php?act=edit_forum&id=' . $forum['id'] . '"><img src="style/page/edit.gif"></a> <a href = "forum.php?act=delete_forum&id=' . $forum['id'] . '"><img src="style/page/delete.gif"></a></span>';
}
echo '<a href = "forum.php?act=forum&id=' . $forum['id'] . '">' . $name . '</a> [' . $count . ']';
echo '</div>';
if ($u['admin'] == 1 || $u['admin'] == 2 || $u['admin'] == 3 || $u['admin'] == 4 || $u['admin'] == 5) {
if (@$_GET['info']) {
if ($u['sex'] == 'm') {
$action[0] = 'Создал';
} else {
$action[0] = 'Создала';
}
if ($u['sex'] == 'm') {
$who[0] = 'Редактировал';
} else {
$who[0] = 'Редактировала';
}
echo '<div class="title">';
echo '<small>' . $action[0] . ': <a href = "/' . $forum['user'] . '">' . login($forum['user']) . '</a>
<b>/</b> ' . $who[0] . ': <a href = "/' . $forum['edit'] . '">' . login($forum['edit']) . '</a> [' . vremya($forum['etime']) . '] </small>';
echo '</div>';
}
}
}
echo '</div>';
navigation($page, $total, 'forum.php?act=cat&id=' . $category['id'] . '&');
}
if ($u['admin'] == 1 || $u['admin'] == 2 || $u['admin'] == 3) {
echo '<div class="title"><img src="style/page/add.gif" alt="!"/> <a href = "forum.php?act=add_forum&id=' . $category['id'] . '">Добавить форум</a> / <a href = "forum.php?act=cat&id=' . $category['id'] . '&info=1">Информация</a></div>';
}
require('foot.php');
} else {
require('head.php');
echo '<div class="title"><center><a href = "forum.php">Форум</a> :: <b>ошибка</b></center></div>';
error(' Такого подфорума не существует!');
require('foot.php');
}
break;
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~Ретинг~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
case 'rating':
$title = $title . ' :: Топ читатели';
require('head.php');
echo '<div class="title"><center>';
echo '<a href = "forum.php">Форум</a> :: Топ читатели';
echo '</center></div>';
if ($u['setting_users_list'])
$count = $u['setting_users_list']; else
$count = 10;
$all = mysql_result(mysql_query("SELECT COUNT(*) FROM `users` WHERE `stat_forum_messages` > 0"), 0);
if ($all > 0) {
$total = num(($all - 1) / $count) + 1;
@$page = num($_GET['page']);
if (empty($page) or $page < 0)
$page = 1;
if ($page > $total)
$page = $total;
$start = $page * $count - $count;
$result = mysql_query("SELECT * FROM `users` WHERE `stat_forum_messages` > 0 ORDER BY `stat_forum_messages` DESC LIMIT $start, $count");
while ($user = mysql_fetch_assoc($result)) {
echo '<div class="div">';
if ($user['delete'] == 1) {
echo '' . ico($user['sex'], $user['admin'], $user['online']) . ' <a href = "/' . $user['id'] . '"><del><b><font color="#79358c">' . $user['login'] . '</font></b></del></a>';
} else {
echo '' . ico($user['sex'], $user['admin'], $user['online']) . ' <a href = "/' . $user['id'] . '"><b><font color="#79358c">' . $user['login'] . '</font></b></a>';
}
echo '' . medal($user['rating']) . '';
echo ' <font color="green">[' . $user['stat_forum_messages'] . ']</font> комм.';
echo '<br/>';
echo '</div>';
}
echo '</div>';
navigation($page, $total, 'forum.php?act=rating&');
} else {
error(' Пользователей не найдено!');
}
echo '</div>';
require('foot.php');
break;
//~~~~~~~~~~~~~~~~Поиск~~~~~~~~~~~~~~~~//
case 'search':
$title = $title . ' :: Поиск';
require('head.php');
echo '<div class="title"><center><a href = "forum.php">Форум</a> :: <b>Поиск</b></center></div>';
if (isset($_POST['ok'])) {
$s = check($_POST['s']);
if (empty($s)) {
header('Location: forum.php?act=search');
} else {
$all = mysql_result(mysql_query("SELECT COUNT(*) FROM `forum_themes` WHERE `name` LIKE '%$s%'"), 0);
if ($all > 0) {
@$total = intval(($all - 1) / $count) + 1;
@$page = num($_GET['page']);
if (empty($page) or $page < 0)
$page = 1;
if ($page > $total)
$page = $total;
@$start = $page * $count - $count;
echo '<div class="title"><center>По запросу: <b>' . $s . '</b> найдено <font color="green">' . $all . '</font> тем </center></div>';
$result = mysql_query("SELECT * FROM `forum_themes` WHERE `name` LIKE '%$s%' ORDER BY `id` LIMIT $start, 10");
while ($theme = mysql_fetch_assoc($result)) {
echo '<div class="div">';
$end = mysql_query("SELECT `user`,`time` FROM `forum_themes` WHERE `id` = '" . $theme['id'] . "' ORDER BY `fix` DESC");
$end_msg = mysql_fetch_array($end);
$count = mysql_result(mysql_query("SELECT COUNT(`id`) FROM `forum_messages` WHERE `theme` = '" . $theme['id'] . "'"), 0);
$all_page = intval(($count - 1) / 10) + 1;
$name = $theme['name'];
$who = @$theme['login'];
if ($theme['fix'] == 1) {
echo '<img src="style/page/stick.gif" alt=""/> ';
}
if ($theme['close'] == 1) {
echo '<span style="float:right;"><img src="style/page/lock.gif" alt="image" /></span>';
}
echo '<a href = "forum.php?act=theme&id=' . $theme['id'] . '&cat=1">' . $name . '</a> (' . $count . ')</a><br />';
echo '<small>';
echo 'Автор: <a href = "page.php?id=' . $theme['user'] . '"><b><font color="#79358c">' . login($theme['user']) . '</font></b></a> / <font color="grey">' . vremya($end_msg['time']) . '</font>';
if ($theme['18'] == 1) {
echo '/ <font color="red">18+</font>';
}
echo '</small>';
echo '</div>';
}
navigation($page, $total, 'forum.php?act=search&');
} else {
error(' По запросу <b>' . $s . '</b> ничего не найдено!');
}
}
} else {
error('Вы ничего не ввели!');
}
require('foot.php');
break;
//~~~~~~~~~~~~~Список категорий~~~~~~~~~~~~~~//
default:
$title = $title . ' :: Форум';
require('head.php');
echo '<div class="title"><center>Форум</center></div>';
if ($u['admin'] == 1 || $u['admin'] == 2 || $u['admin'] == 3) {
echo '<div class="nav"><img src="style/page/add.gif" alt="!"/> <a href = "forum.php?act=add_cat">Добавить категорию</a> / <a href = "?&info=1">Информация</a></div>';
}
$rating = mysql_result(mysql_query("SELECT COUNT(*) FROM `users` WHERE `stat_forum_messages` > 0"), 0);
echo '<div class="div">
<a href = "forum.php?act=rating">ТОП читатели форума</a> (' . $rating . ')
</div>';
echo '<div class="nav">
Поиск по форуму:
<FORM method="POST" action="forum.php?act=search&ok=1">
<input type="text" name="s" value="" placeholder="Введите пару слов для поиска..." style="width: 55%" />
<input type="submit" name="ok" value="Найти"/>
</form>
</div>';
$all = mysql_result(mysql_query("SELECT COUNT(*) FROM `forum_categories`"), 0);
if ($all > 0) {
$result = mysql_query("SELECT * FROM `forum_categories` ORDER BY `ord` DESC");
while ($cat = mysql_fetch_assoc($result)) {
echo '<div class="div">';
$opis = checkout($cat['opis']);
$name = checkout($cat['name']);
if ($u['admin'] == 1 || $u['admin'] == 2 || $u['admin'] == 3) {
echo '<span style="float:right"><a href = "forum.php?act=edit_cat&id=' . $cat['id'] . '"><img src="style/page/edit.gif"></a>
<a href = "forum.php?act=delete_cat&id=' . $cat['id'] . '"><img src="style/page/delete.gif"></a></span>';
}
echo '<a href = "forum.php?act=cat&id=' . $cat['id'] . '">' . $name . '</a>';
echo '</br>' . $opis . '';
echo '</div>';
if ($u['admin'] >= 1) {
if (@$_GET['info']) {
if ($u['sex'] == 'm') {
$action[0] = 'Создал';
} else {
$action[0] = 'Создала';
}
if ($u['sex'] == 'm') {
$who[0] = 'Редактировал';
} else {
$who[0] = 'Редактировала';
}
echo '<div class="title">';
echo '<small>' . $action[0] . ': <a href = "/' . $cat['user'] . '">' . login($cat['user']) . '</a>
<b>/</b> ' . $who[0] . ': <a href = "/' . $cat['edit'] . '">' . login($cat['edit']) . '</a> [' . vremya($cat['etime']) . '] </small>';
echo '</div>';
}
}
}
} else {
error(' Категорий пока нет!');
}
echo '</div>';
require('foot.php');
break;
}
?>