Файл: WM-Koder/forum/index.php
Строк: 1201
<?php
require '../system/sid.php';
require '../system/config.php';
if (isset($_SESSION['us']))
{
include '../system/user.php';
whorm(0, 'forum');
}
require '../system/head.php';
include '../system/navigator.php';
##################Разделы #################################
$do = (isset($_GET['do'])) ? $_GET['do'] : NULL;
switch($do) {
default:
echo $div_title . 'Форум мастеров' . $div_end;
echo '<div class="auth2"><a href="index.php?do=search">Поиск</a> |
<a href="index.php?do=act">Активные</a> |
<a href="index.php?do=newt">Новые</a> |
<a href="index.php?do=my">Мои темы</a></div>';
$razdel = mysql_result(mysql_query("SELECT COUNT(id) FROM `f_razdel`"), 0);
// разделы
if ($razdel != FALSE) {
$look = mysql_query("SELECT `f_razdel`.*,
(SELECT COUNT(id) FROM `f_pod` WHERE `f_pod`.`pid` = `f_razdel`.`id`) AS c,
(SELECT COUNT(id) FROM `f_pod` WHERE `f_pod`.`pid` = `f_razdel`.`id` AND `f_pod`.`time` > '" . (time() - 86400) . "') AS t,
(SELECT COUNT(id) FROM `f_them` WHERE `f_razdel`.`id` = `f_them`.`razdel_id`) AS m
FROM `f_razdel` ORDER BY `f_razdel`.`id` ASC {$n->limit}");
$dv = 0;
while($a = mysql_fetch_assoc($look)) {
$new_in = (!empty($a['t'])) ? '<span style="color: #FF0000;">+' . $a['t'] . '</span>' : '';
echo ($dv ++ % 2) ? $div_tworazdel : $div_razdel;
}
}
else
{
echo 'Разделы не созданы!<br/>';
}
include 'pod.php';
break;
case razdel:
$r = my_int($_GET['r']);
$empty = mysql_query("SELECT * FROM `f_razdel` WHERE `id` = '$r' LIMIT 1");
if (mysql_num_rows($empty) == FALSE) {
err('Раздела не существует!');
include '../system/foot.php';
exit();
}
#################Подфорумы #######################################
// информация о разделе
$i_rzd = mysql_fetch_assoc($empty);
##
$pod = mysql_result(mysql_query("SELECT COUNT(id) FROM `f_pod` WHERE `pid` = '$r' LIMIT 1"), 0);
echo $div_title . $i_rzd['name'] . $div_end;
echo '<div class="auth2"><a href="index.php?do=search">Поиск</a> |
<a href="index.php?do=act">Активные</a> |
<a href="index.php?do=newt">Новые</a> |
<a href="index.php?do=my">Мои темы</a></div>';
// список подфорумов
if ($pod != FALSE) {
$n = new navigator($pod, 10, '?do=razdel&r='.$r.'&');
$look = mysql_query("SELECT `f_pod`.*,
(SELECT COUNT(id) FROM `f_them` WHERE `f_them`.`rid` = `f_pod`.`id`) AS c,
(SELECT COUNT(id) FROM `f_them` WHERE `f_them`.`rid` = `f_pod`.`id` AND `date` > '" . (time() - 86400) . "') AS t,
(SELECT COUNT(id) FROM `f_message` WHERE `f_message`.`podforum` = `f_pod`.`id`) AS m
FROM `f_pod` WHERE `f_pod`.`pid` = '$r' ORDER BY `f_pod`.`id` ASC {$n->limit}");
$dv = 0;
while($a = mysql_fetch_assoc($look)) {
$new_themes = (!empty($a['t'])) ? '<span style="color: #FF0000;">+' . $a['t'] . '</span>' : '';
echo ($dv ++ % 2) ? $div_tworazdel : $div_razdel;
echo '<div class="menu"> <a class="ssyl2" href="index.php?do=pod&p='.$a['id'].'&r='.$a['pid'].'"> <img src="http://digmas.tk/ico/f.gif" alt="*"/> ' . $a['name'] . ' (' . $a['c'] . '/' . $a['m'] . ') ' . $new_themes . '</div></a>' . $div_end;
#######
}
echo $n->navi();
}
else
{
echo '<div class="menu">Подфорумы не созданы!</div>';
}
break;
case pod:
$r = my_int($_GET['r']);
$p = my_int($_GET['p']);
$empty_1 = mysql_query("SELECT * FROM `f_razdel` WHERE `id` = '$r' LIMIT 1");
$empty_2 = mysql_query("SELECT * FROM `f_pod` WHERE `id` = '$p' LIMIT 1");
if (mysql_num_rows($empty_1) == FALSE) {
err('Раздела не существует!');
include '../system/foot.php';
exit();
}
if (mysql_num_rows($empty_2) == FALSE) {
err('Подфорума не существует!');
include '../system/foot.php';
exit();
}
#####################################################
// информация о разделе
$i_rzd = mysql_fetch_assoc($empty_1);
// информация о подфоруме
$i_pdf = mysql_fetch_assoc($empty_2);
##
$them = mysql_result(mysql_query("SELECT COUNT(id) FROM `f_them` WHERE `rid` = '$i_pdf[id]'"), 0);
echo $div_title . $i_rzd['name'] . $div_end;
echo '<div class="auth2"><a href="index.php?do=search">Поиск</a> |
<a href="index.php?do=act">Активные</a> |
<a href="index.php?do=newt">Новые</a> |
<a href="index.php?do=my">Мои темы</a></div>';
// список тем
if ($them != FALSE) {
$num_th = (!empty($_SESSION['onp_themes'])) ? $user['onp_themes'] : 10;
$n = new navigator($them, $num_th, '?do=pod&p='.$p.'&r='.$r.'&');
$look = mysql_query("SELECT `f_them`.*,
(SELECT COUNT(id) FROM `f_message` WHERE `f_message`.`tid` = `f_them`.`id`) AS c,
(SELECT COUNT(id) FROM `f_message` WHERE `f_message`.`tid` = `f_them`.`id` AND `time` > '" . (time() - 86400) . "') AS t
FROM `f_them` WHERE `rid` = '$i_pdf[id]' ORDER BY `fix` DESC, `last` DESC {$n->limit}");
$dv = 0;
while($a = mysql_fetch_assoc($look)) {
// закрытая тема
if ($a['close'] == 1 && $a['fix'] == 0) {
$cl = '<img src="http://digmas.tk/ico/f_zakryt.gif" alt="*"/>';
// открытая тема
} elseif ($a['close'] == 0 && $a['fix'] == 0) {
$cl = '<img src="http://digmas.tk/ico/f.gif" alt="*"/>';
// закрепленная тема
} elseif ($a['fix'] == 1) {
$cl = '<img src="http://digmas.tk/ico/f_zakrep.gif" alt="*"/>';
// обычная тема
} else {
$cl = '<img src="http://digmas.tk/ico/f.gif" alt="*"/>';
}
#######
$new_mess = (!empty($a['t'])) ? '<span style="color: #FF0000;">+' . $a['t'] . '</span>' : '';
// последний написавший
$luser = mysql_fetch_assoc(mysql_query("SELECT `user`, `time` FROM `f_message` WHERE `tid` = '$a[id]' ORDER BY `time` DESC LIMIT 1"));
$gmdate = (time() - 86400 < $luser['time'])
? gmdate('Gч. iмин. назад', (time() - $luser['time']))
: date('d-m-Y G:i', $luser['time']);
if ($luser['time'] != FALSE) $kogda = ($luser['user'] != 0 ? us($luser['user']) : 'Система') . ' ' . $gmdate;
else $kogda = '';
###############################
if ($a['c'] > 10) {
$pg = ceil($a['c'] / 10);
$st = ' <a href="index.php?do=them&r='.$r.'&p='.$p.'&t='.$a['id'].'&page='.$pg.'"><b>»»</b></a>';
} else {
$st = '';
}
###############################
echo ($dv ++ % 2) ? $div_tworazdel : $div_razdel;
echo '<div class="menu"><a class="ssyl2" href="index.php?do=them&r='.$r.'&p='.$p.'&t='.$a['id'].'"> ' . $cl . ' ' . $a['name'] . ' (' . $a['c'] . $new_mess . ') ' . $st . '</div></a>';
#######
}
echo $n->navi();
}
else
{
echo '<div class="menu">Темы не созданы!</div>';
}
echo (!empty($_SESSION['us'])) ? '<div class="menu2"><a class="ssyl2" href="index.php?do=add_them&r='.$r.'&p='.$p.'">Создать тему</a></div>' : '';
break;
case them:
$t = my_int($_REQUEST['t']);
$p = my_int($_REQUEST['p']);
$r = my_int($_REQUEST['r']);
$empty_1 = mysql_query("SELECT * FROM `f_them` WHERE `id` = '$t' AND `rid` = '$p' LIMIT 1");
$empty_2 = mysql_query("SELECT * FROM `f_pod` WHERE `id` = '$p' AND `pid` = '$r' LIMIT 1");
$empty_3 = mysql_query("SELECT * FROM `f_razdel` WHERE `id` = '$r' LIMIT 1");
if (mysql_num_rows($empty_1) == FALSE) {
err('Тема не найдена, возможна она была удалена.');
include '../system/foot.php';
exit();
}
if (mysql_num_rows($empty_2) == FALSE) {
err('Подфорума не существует!');
include '../system/foot.php';
exit();
}
if (mysql_num_rows($empty_3) == FALSE) {
err('Раздела не существует!');
include '../system/foot.php';
exit();
}
//////////////////////////////
// Запись "кто в теме"
$InThem = mysql_query("SELECT `id` FROM `inthem` WHERE `who` = '$user[id]' AND `time` + '100' > '" . time() . "' LIMIT 1");
if (mysql_num_rows($InThem) == false && !empty($_SESSION['us']))
{
$rnd = mt_rand(10000000, 99999999);
mysql_query("INSERT INTO `inthem` SET `id` = '$rnd', `who` = '$user[id]', `uid` = '$t', `time` = '" . time() . "'");
}
elseif (mysql_num_rows($InThem) != false && !empty($_SESSION['us']))
{
mysql_query("UPDATE `inthem` SET `time` = '" . time() . "', `uid` = '$t' WHERE `who` = '$user[id]' LIMIT 1");
}
mysql_query("DELETE FROM `inthem` WHERE `time` + '100' < '" . time() . "'");
//////////////////////////////
// информация о теме
$i_th = mysql_fetch_assoc($empty_1);
// информация о разделе
$i_rzd = mysql_fetch_assoc(mysql_query("SELECT `id`, `name` FROM `f_razdel` WHERE `id` = '$r' LIMIT 1"));
// информация о подфоруме
$i_pdf = mysql_fetch_assoc(mysql_query("SELECT `id`, `name` FROM `f_pod` WHERE `id` = '$p' LIMIT 1"));
$mes = mysql_result(mysql_query("SELECT COUNT(id) FROM `f_message` WHERE `tid` = '$t'"), 0);
//-------------------------------------------//
$sqlLenta = mysql_query("SELECT id FROM lenta WHERE user = '$user[id]' AND `read` = '1' AND type = 'comments' AND uid = 'forum$t' LIMIT 1");
if (mysql_num_rows($sqlLenta) != false)
{
mysql_query("UPDATE lenta SET `read` = '0' WHERE user = '$user[id]' AND `read` = '1' AND type = 'comments' AND uid = 'forum$t' LIMIT 1");
}
//-------------------------------------------//
// закрытие темы
if ($i_th['close'] == 1) {
$_cls_1 = 'open_them';
$_cls_2 = 'Открыть';
} else {
$_cls_1 = 'close_them';
$_cls_2 = 'Закрыть';
}
// фиксация темы
if ($i_th['fix'] == 0) {
$_fix_1 = 'fix_them';
$_fix_2 = 'Закрепить';
} else {
$_fix_1 = 'detach_them';
$_fix_2 = 'Открепить';
}
// апдейт темы
if ($user['level'] >= 3 && $user['level'] <= 5)
{
if (empty($i_th['quest']) && $i_th['author'] == $user['id'] && $i_th['close'] == 0)
{
$ed .= ' | <a href="index.php?do=edit_them&r='.$r.'&p='.$p.'&x='.$t.'">Изменить</a>';
}
$ed = '<a href="index.php?do=del_them&r='.$r.'&p='.$p.'&x='.$t.'">Удалить</a> |
<a href="index.php?do=edit_them&r='.$r.'&p='.$p.'&x='.$t.'">Изменить</a> |
<a href="index.php?do='.$_fix_1.'&r='.$r.'&p='.$p.'&x='.$t.'">' . $_fix_2 . '</a> |
<a href="index.php?do='.$_cls_1.'&r='.$r.'&p='.$p.'&x='.$t.'">' . $_cls_2 . '</a> |
<a href="index.php?do=move_them&r='.$r.'&p='.$p.'&x='.$t.'">Переместить</a>' . $ed;
}
elseif (empty($i_th['quest']) && $i_th['author'] == $user['id'] && $i_th['close'] == 0)
{
$ed = '<a href="index.php?do=edit_them&r='.$r.'&p='.$p.'&x='.$t.'">Изменить</a>
<a href="index.php?do='.$_cls_1.'&r='.$r.'&p='.$p.'&x='.$t.'">' . $_cls_2 . '</a>';
}
elseif (!empty($i_th['quest']) && $i_th['author'] == $user['id'] && $i_th['close'] == 0)
{
$ed = '<a href="index.php?do=edit_them&r='.$r.'&p='.$p.'&x='.$t.'">Изменить</a>
<a href="index.php?do='.$_cls_1.'&r='.$r.'&p='.$p.'&x='.$t.'">' . $_cls_2 . '</a>';
}
elseif ($i_th['author'] == $user['id'] && $i_th['close'] == 1)
{
$ed = '<a href="index.php?do='.$_cls_1.'&r='.$r.'&p='.$p.'&x='.$t.'">' . $_cls_2 . '</a><br>';
}
// последнее редактирование
$redact = (!empty($i_th['whoedit']))
? $div_razdel . 'Редактировалось: <a href="/'.$i_th['whoedit'].'">' . user_inf($i_th['whoedit'], 'user') . '</a>' . $div_end
: '';
// первый пост в теме
if (mb_strlen($i_th['firstpost'], 'UTF8') > 100000 && !isset($_GET['read'])) {
$i_th['firstpost'] = mb_substr($i_th['firstpost'], 0, 150, 'UTF8') . '...<br/>
<a href="index.php?do=them&r='.$r.'&p='.$p.'&t='.$t.'&read"><span class="next">Читать полностью</span></a>';
} elseif (mb_strlen($i_th['firstpost'], 'UTF8') > 150000000 && isset($_GET['read'])) {
$i_th['firstpost'] = $i_th['firstpost'] . '<br/>
<a href="index.php?do=them&r='.$r.'&p='.$p.'&t='.$t.'"><span class="next">«Скрыть</span></a>';
} else {
$i_th['firstpost'] = $i_th['firstpost'];
}
#################Шапка###########################################
echo '<div class="title"><a href="index.php?do=pod&r='.$i_rzd['id'].'&p='.$i_pdf['id'].'">' . $i_pdf['name'] . '</a> | '.$i_th['name'].'</div>';
echo '<div class="menu">'.$ed.'</div>';
echo '<div class="menu">';
if (user_inf($i_th['author'], 'onl') + 300 > time())
{
$online = ' <img src="/views/default/img/on.png" alt="on">';
}
else
{
$online = ' <img src="/views/default/img/off.png" alt="off">';
}
echo ''.uus($i_th['author']).'<div class="auth2"><b>'.us($i_th['author']).'</b>'.$online.'</div>';
echo '('.date('d-m-Y H:i', $i_th['date']).')</td></tr></table>';
echo ''.smiles(bb_code($i_th['firstpost'])).'<br><br>'.$redact.'';
echo '</td></tr></table></div>';
echo '</div>';
################################################################
// запись сообщения
if (isset($_POST['add'])) {
if (empty($_SESSION['us'])) {
header('Location: /reg.php?');
die();
}
$msg = trim(mysql_real_escape_string(check($_POST['msg'])));
if (empty($msg)) {
header('Location: index.php?do=them&r='.$r.'&p='.$p.'&t=' . $t);
} else {
if ($_POST['up'] == 1) {
echo 'Сообщение: ' . $msg . '<br/>
<FORM ENCTYPE="multipart/form-data" action="index.php?do=them" method="POST">
<label>Выбрать файл:</label><br/>
<input name="object" type="file"/>
<br/>
<label>Импорт файла:</label><br/>
<input type="text" name="url" value="http://"/>
<br/>
<input type="radio" name="upl" checked value="1"/> Обычная загрузка
<input type="radio" name="upl" value="2"/> Импорт
<br/>
<input type="hidden" name="r" value="' . $r . '"/>
<input type="hidden" name="p" value="' . $p . '"/>
<input type="hidden" name="t" value="' . $t . '"/>
<input type="hidden" name="act" value="1"/>
<input type="hidden" name="msg" value="' . str_replace('<br />', "n", $msg) . '"/>
<input type="submit" name="add" value="Прикрепить"/>
</FORM>';
include '../system/foot.php';
exit();
}
if ($_POST['act'] == 1) {
$upl = my_int($_POST['upl']);
if (isset($_POST['url'])) $url = htmlentities($_POST['url']);
if ($upl == 1)
{
$FileName = $_FILES['object']['name'];
$FileSize = $_FILES['object']['size'];
// если тема закрыта
if ($i_th['close'] == 1) {
header('Location: index.php?do=them&r='.$r.'&p='.$p.'&t=' . $t);
die();
}
$GetExt = array('.bmp',
'.gif',
'.jpeg',
'.jpg',
'.png',
'.amr',
'.mp3',
'.pdf',
'.swf',
'.txt',
'.zip',
'.txt',
'.rar',
'.tar',
'.gz',
'.gzip',
'.cab');
$ext = strtolower(strrchr($_FILES['object']['name'], '.'));
if (empty($FileName)) $err .= 'Не выбран файл!';
elseif (!preg_match('#([a-z0-9-_]{1,32})#i', $FileName)) $err .= 'Не правильное имя файла!';
elseif ($FileSize > 1024 * 2 * 1024) $err .= 'Размер файла более 2 Мб!';
elseif (preg_match('/(.php|.pl|.htaccess)/i', $FileName) || !in_array($ext, $GetExt)) $err .= 'Запрещенный формат файла!';
if (!empty($err)) {
err($err);
} else {
$name = $site . '_' . mt_rand(100000, 9999999) . $ext;
if ($ext == '.jpg'
|| $ext == '.jpeg'
|| $ext == '.bmp')
{
$imgc = @imagecreatefromstring(file_get_contents($_FILES['object']['tmp_name']));
$imgc = img_copyright($imgc); // наложение копирайта
$foto = 'upload/' . $name;
imagejpeg($imgc, $foto, 90);
} else {
copy($_FILES['object']['tmp_name'], 'upload/' . $name);
}
// Антиреклама
$_ant = mysql_fetch_assoc(mysql_query("SELECT `on_rekl`, `text_rekl` FROM `setting` WHERE `ids` = '1'"));
if ($_ant['on_rekl'] == 1 && filesize($_SERVER['DOCUMENT_ROOT'] . '/domains.dat') > 0) {
$ex = explode(',', file_get_contents('../domains.dat'));
foreach($ex as $value) {
if ($user['level'] != 4 && $user['level'] != 5 && !preg_match('/[url=http://(.*)[/url]/si', $msg)) {
$msg = preg_replace("/(w)(s|,|.|*|_|-|+)+$value/si", $_ant['text_rekl'], $msg);
}
}
}
// транслит
if ($user['translit'] == 1) {
$msg = trun_to_rus($msg);
}
// антимат
$ant = mysql_fetch_array(mysql_query("SELECT `antimat` FROM `setting` WHERE `ids` = '1'"));
$msg = ($ant[0] == 1) ? mat($msg) : $msg;
// запись в базу
mysql_query("INSERT INTO `f_message` SET
`tid` = '$t',
`podforum` = '$i_pdf[id]',
`user` = '$user[id]',
`msg` = '$msg',
`path` = '$name',
`time` = '" . time() . "'");
// апдейт времени последней темы
mysql_query("UPDATE `f_them` SET `last` = '" . time() . "' WHERE `id` = '$t' LIMIT 1");
// Лента
if (user_inf($i_th['author'], 'comm_forum') == 1 && $user['id'] != $i_th['author']) {
$message = cvetnik($user['id']) . ' оставил сообщение в Вашей <a href="forum/index.php?do=them&r='.$r.'&p='.$p.'&t='.$t.'">теме</a>!';
mysql_query("INSERT INTO `lenta` SET
`user` = '$i_th[author]',
`text` = '$message',
`type` = 'comments',
`date` = '" . time() . "',
`uid` = 'forum$t',
`read` = '1'");
}
$lst = mysql_fetch_assoc(mysql_query("SELECT `user` FROM `f_message` WHERE
`podforum` = '$i_th[rid]'
AND
`tid` = '$i_th[id]'
ORDER BY `id` DESC LIMIT 1"));
if (user_inf($lst['user'], 'comm_forum') == 1 && $user['id'] != $lst['user'] && !isset($_POST['adr'])) {
$message2 = 'В теме <a href="forum/index.php?do=them&r='.$r.'&p='.$p.'&t='.$t.'">'.$i_th['name'].'</a> оставили сообщение.';
mysql_query("INSERT INTO `lenta` SET
`user` = '$lst[user]',
`text` = '$message2',
`type` = 'comments',
`date` = '" . time() . "',
`uid` = 'forum$t',
`read` = '1'");
}
$num_post = mysql_result(mysql_query("SELECT COUNT(id) FROM `f_message` WHERE `tid` = '$t'"), 0);
if ($num_post > 10) {
$pg = ceil($num_post / 10);
$st = '&page=' . $pg;
} else {
$st = '';
}
header('Location: index.php?do=them&r='.$r.'&p='.$p.'&t=' . $t . $st . '#down');
}
} elseif ($upl == 2) {
$file = basename($url);
$format = strtolower(strrchr($file, '.'));
// если тема закрыта
if ($i_th['close'] == 1) {
header('Location: index.php?do=them&r='.$r.'&p='.$p.'&t=' . $t);
die();
}
$GetExt = array('.bmp',
'.gif',
'.jpeg',
'.jpg',
'.png',
'.amr',
'.mp3',
'.pdf',
'.swf',
'.txt',
'.zip',
'.txt',
'.rar',
'.tar',
'.gz',
'.gzip',
'.cab');
$f = @fopen($url, 'r');
while($c = @fread($f, 1024)) $filedata .= $c;
if (!$f) $err .= 'Ошибка импортирования файла!';
elseif (!in_array($format, $GetExt)) $err .= 'Запрещенный формат файла!';
elseif (strlen($filedata) > (1024 * 2 * 1024)) $err .= 'Размер файла более 2 Мб!';
if (!empty($err)) {
err($err);
} else {
$name = mt_rand(100000, 9999999) . $file;
copy($url, 'upload/' . $name);
// Антиреклама
$_ant = mysql_fetch_assoc(mysql_query("SELECT `on_rekl`, `text_rekl` FROM `setting` WHERE `ids` = '1'"));
if ($_ant['on_rekl'] == 1 && filesize($_SERVER['DOCUMENT_ROOT'] . '/domains.dat') > 0) {
$ex = explode(',', file_get_contents('../domains.dat'));
foreach($ex as $value) {
if ($user['level'] != 4 && $user['level'] != 5 && !preg_match('/[url=http://(.*)[/url]/si', $msg)) {
$msg = preg_replace("/(w)(s|,|.|*|_|-|+)+$value/si", $_ant['text_rekl'], $msg);
}
}
}
// транслит
if ($user['translit'] == 1) {
$msg = trun_to_rus($msg);
}
// антимат
$ant = mysql_fetch_array(mysql_query("SELECT `antimat` FROM `setting` WHERE `ids` = '1'"));
$msg = ($ant[0] == 1) ? mat($msg) : $msg;
// запись в базу
mysql_query("INSERT INTO `f_message` SET
`tid` = '$t',
`podforum` = '$i_pdf[id]',
`user` = '$user[id]',
`msg` = '$msg',
`path` = '$name',
`time` = '" . time() . "'");
// апдейт времени последней темы
mysql_query("UPDATE `f_them` SET `last` = '" . time() . "' WHERE `id` = '$t' LIMIT 1");
// Лента
if (user_inf($i_th['author'], 'comm_forum') == 1 && $user['id'] != $i_th['author']) {
$message = cvetnik($user['id']) . ' оставил сообщение в Вашей <a href="forum/index.php?do=them&r='.$r.'&p='.$p.'&t='.$t.'">теме</a>!';
mysql_query("INSERT INTO `lenta` SET
`user` = '$i_th[author]',
`text` = '$message',
`type` = 'comments',
`date` = '" . time() . "',
`uid` = 'forum$t',
`read` = '1'");
}
$lst = mysql_fetch_assoc(mysql_query("SELECT `user` FROM `f_message` WHERE
`podforum` = '$i_th[rid]'
AND
`tid` = '$i_th[id]'
ORDER BY `id` DESC LIMIT 1"));
if (user_inf($lst['user'], 'comm_forum') == 1 && $user['id'] != $lst['user'] && !isset($_POST['adr'])) {
$message2 = 'В теме <a href="forum/index.php?do=them&r='.$r.'&p='.$p.'&t='.$t.'">'.$i_th['name'].'</a> оставили сообщение.';
mysql_query("INSERT INTO `lenta` SET
`user` = '$lst[user]',
`text` = '$message2',
`type` = 'comments',
`date` = '" . time() . "',
`uid` = 'forum$t',
`read` = '1'");
}
$num_post = mysql_result(mysql_query("SELECT COUNT(id) FROM `f_message` WHERE `tid` = '$t'"), 0);
if ($num_post > 10) {
$pg = ceil($num_post / 10);
$st = '&page=' . $pg;
} else {
$st = '';
}
header('Location: index.php?do=them&r='.$r.'&p='.$p.'&t=' . $t . $st . '#down');
}
}
} else {
$num_post = mysql_result(mysql_query("SELECT COUNT(id) FROM `f_message` WHERE `tid` = '$t'"), 0);
if ($num_post > 10) {
$pg = ceil($num_post / 10);
$st = '&page=' . $pg;
} else {
$st = '';
}
// если тема закрыта
if ($i_th['close'] == 1) {
header('Location: index.php?do=them&r='.$r.'&p='.$p.'&t=' . $t . $st);
die();
}
// Антиреклама
$_ant = mysql_fetch_assoc(mysql_query("SELECT `on_rekl`, `text_rekl` FROM `setting` WHERE `ids` = '1'"));
if ($_ant['on_rekl'] == 1 && filesize($_SERVER['DOCUMENT_ROOT'] . '/domains.dat') > 0) {
$ex = explode(',', file_get_contents('../domains.dat'));
foreach($ex as $value) {
if ($user['level'] != 4 && $user['level'] != 5 && !preg_match('/[url=http://(.*)[/url]/si', $msg)) {
$msg = preg_replace("/(w)(s|,|.|*|_|-|+)+$value/si", $_ant['text_rekl'], $msg);
}
}
}
// транслит
if ($user['translit'] == 1) {
$msg = trun_to_rus($msg);
}
// антимат
$ant = mysql_fetch_array(mysql_query("SELECT `antimat` FROM `setting` WHERE `ids` = '1'"));
$msg = ($ant[0] == 1) ? mat($msg) : $msg;
// Оповещание последнему постеру
$lst = mysql_fetch_assoc(mysql_query("SELECT * FROM `f_message` WHERE
`podforum` = '$i_th[rid]'
AND
`tid` = '$i_th[id]'
ORDER BY `id` DESC LIMIT 1"));
// запись в базу
mysql_query("INSERT INTO `f_message` SET
`tid` = '$t',
`podforum` = '$i_pdf[id]',
`user` = '$user[id]',
`msg` = '$msg',
`time` = '" . time() . "'");
// апдейт времени последней темы
mysql_query("UPDATE `f_them` SET `last` = '" . time() . "' WHERE `id` = '$t' LIMIT 1");
if ($lst['user'] != $i_th['author'] && user_inf($lst['user'], 'comm_forum') == 1 && $user['id'] != $lst['user']) {
// Подфорум...
$lst2 = mysql_fetch_assoc(mysql_query("SELECT name, pid FROM `f_pod` WHERE `id` = '$i_th[rid]' LIMIT 1"));
// Раздел...
$lst3 = mysql_fetch_assoc(mysql_query("SELECT `name` FROM `f_razdel` WHERE `id` = '$lst2[pid]' LIMIT 1"));
// Отправка...
$message2 = 'В теме <a href="forum/index.php?do=them&r='.$r.'&p='.$p.'&t='.$t.'">' . $i_th['name'] . '</a> (' . $lst3['name'] . '/' . $lst2['name'] . ') оставили сообщение.';
mysql_query("INSERT INTO `lenta` SET
`user` = '$lst[user]',
`text` = '$message2',
`type` = 'comments',
`date` = '" . time() . "',
`uid` = 'forum$t',
`read` = '1'");
}
elseif (user_inf(my_int($_POST['adr']), 'comm_forum') == 1 && $user['id'] != my_int($_POST['adr'])) {
$message = cvetnik($user['id']) . ' ответил на Ваш комментарий в <a href="forum/index.php?do=them&r='.$r.'&p='.$p.'&t='.$t.'">теме</a>!';
mysql_query("INSERT INTO `lenta` SET
`user` = '" . my_int($_POST['adr']) . "',
`text` = '$message',
`type` = 'comments',
`date` = '" . time() . "',
`uid` = 'forum$t',
`read` = '1'");
}
// Лента
elseif (user_inf($i_th['author'], 'comm_forum') == 1 && $user['id'] != $i_th['author']) {
$message = cvetnik($user['id']) . ' оставил сообщение в Вашей <a href="forum/index.php?do=them&r='.$r.'&p='.$p.'&t='.$t.'">теме</a>!';
mysql_query("INSERT INTO `lenta` SET
`user` = '$i_th[author]',
`text` = '$message',
`type` = 'comments',
`date` = '" . time() . "',
`uid` = 'forum$t',
`read` = '1'");
}
$num_post = mysql_result(mysql_query("SELECT COUNT(id) FROM `f_message` WHERE `tid` = '$t'"), 0);
if ($num_post > 10) {
$pg = ceil($num_post / 10);
$st = '&page=' . $pg;
} else {
$st = '';
}
header('Location: index.php?do=them&r='.$r.'&p='.$p.'&t=' . $t . $st . '#down');
}
}
}
// удаление поста
if (isset($_GET['d'])) {
$num_post = mysql_result(mysql_query("SELECT COUNT(id) FROM `f_message` WHERE `tid` = '$t'"), 0);
if ($num_post > 10) {
$pg = ceil($num_post / 10);
$st = '&page=' . $pg;
} else {
$st = '';
}
$d = my_int($_GET['d']);
$pst = mysql_query("SELECT * FROM `f_message` WHERE `id` = '$d' LIMIT 1");
$i = mysql_fetch_assoc($pst);
if ($user['id'] != $i['user'] && $user['level'] < 3) {
header('Location: index.php?do=them&r='.$r.'&p='.$p.'&t=' . $t . $st);
die();
}
if ($i_th['close'] == 1) {
header('Location: index.php?do=them&r='.$r.'&p='.$p.'&t=' . $t . $st);
die();
}
if (mysql_num_rows($pst) == FALSE) {
err('Ошибка!');
} else {
// удаление файла из поста
if (file_exists('upload/' . $i['path'])) unlink('upload/' . $i['path']);
mysql_query("DELETE FROM `f_message` WHERE `id` = '$d' LIMIT 1");
header('Location: index.php?do=them&r='.$r.'&p='.$p.'&t=' . $t . $st);
}
}
// удаление файла
if (isset($_GET['df'])) {
$df = my_int($_GET['df']);
$num_post = mysql_result(mysql_query("SELECT COUNT(id) FROM `f_message` WHERE `tid` = '$t'"), 0);
if ($num_post > 10) {
$pg = ceil($num_post / 10);
$st = '&page=' . $pg;
} else {
$st = '';
}
$em = mysql_query("SELECT path, user FROM `f_message` WHERE `id` = '$df' LIMIT 1");
$i = mysql_fetch_assoc($em);
if ($user['id'] != $i['user'] && $user['level'] < 3) {
header('Location: index.php?do=them&r='.$r.'&p='.$p.'&t=' . $t . $st);
die();
}
if ($i_th['close'] == 1) {
header('Location: index.php?do=them&r='.$r.'&p='.$p.'&t=' . $t . $st);
die();
}
if (mysql_num_rows($em) != FALSE) {
if (file_exists('upload/' . $i['path'])) unlink('upload/' . $i['path']);
mysql_query("UPDATE `f_message` SET `path` = '' WHERE `id` = '$df' LIMIT 1");
header('Location: index.php?do=them&r='.$r.'&p='.$p.'&t=' . $t . $st);
} else {
err('Ошибка!');
}
}
// список тем
if ($mes != FALSE) {
$n = new navigator($mes, 10, '?do=them&r='.$r.'&p='.$p.'&t='.$t.'&');
$look = mysql_query("SELECT `f_message`.*,
(SELECT COUNT(id) FROM `f_message` WHERE `f_message`.`tid` = '$t') AS c
FROM `f_message` WHERE `tid` = '$t' ORDER BY `id` $ord {$n->limit}");
$dv = 0;
$cols = 0;
while($a = mysql_fetch_assoc($look)) {
++$cols;
###############################
if ($a['c'] > 10) {
$pg = ceil($a['c'] / 10);
$st = '&page=' . $pg;
} else {
$st = '';
}
###############################
######################################
if (user_inf($a['user'], 'onl') + 300 > time()) $online = ' <img src="/views/default/img/on.png" alt="on"/>';
else $online = ' <img src="/views/default/img/off.png" alt="off"/>';
if ($user['id'] != $a['user'] && $a['user'] != 0 && $i_th['close'] == 0 && !empty($_SESSION['us']))
{
$_ank = '<a href="index.php?do=them&r='.$r.'&p='.$p.'&t='.$t.$st.'&k='.$a['user'].'&#down">отв</a>';
} else $_ank = '';
######################################
//---------------------------//
if ($user['level'] >= 3 && $user['level'] <= 5 && $i_th['close'] == 0 && !empty($_SESSION['us'])) {
$upr = '<a href="index.php?do=them&r='.$r.'&p='.$p.'&t='.$t.'&d='.$a['id'].'">уд</a>
<a href="index.php?do=izm&r='.$r.'&p='.$p.'&t='.$t.'&e='.$a['id'].'">изм</a>';
if ($a['user'] != 0 && $user['id'] != $a['user']) $upr .= '
<a href="index.php?do=cit&r='.$r.'&p='.$p.'&t='.$t.'&c='.$a['id'].'">цит</a>';
}
//---------------------------//
elseif ($a['user'] != 0 && $user['level'] < 3 && $i_th['close'] == 0 && !empty($_SESSION['us'])) {
if ($a['user'] == $user['id']) $upr = '<a href="index.php?do=izm&r='.$r.'&p='.$p.'&t='.$t.'&e='.$a['id'].'">изм</a>';
if ($a['user'] == $user['id']) $upr .= '<a href="index.php?do=them&r='.$r.'&p='.$p.'&t='.$t.'&d='.$a['id'].'">уд</a>';
if ($user['id'] != $a['user']) $upr = '<a href="index.php?do=cit&r='.$r.'&p='.$p.'&t='.$t.'&c='.$a['id'].'">цит</a>';
}
//---------------------------//
elseif ($i_th['close'] == 1 && !empty($_SESSION['us'])) {
$upr = '';
}
//---------------------------//
// Определение лучшего / худшего ответа
$noBest = mysql_query("SELECT id FROM f_message WHERE best = '1' AND tid = '$t' LIMIT 1");
$noWorse = mysql_query("SELECT id FROM f_message WHERE worse = '1' AND tid = '$t' LIMIT 1");
if (isset($_GET['best']))
{
//----------------------------------//
if ($user['id'] == $i_th['author'] && $i_th['close'] == 0 && mysql_num_rows($noBest) == 0 && $a['user'] != $user['id'] && $a['best'] == 0 && $a['worse'] == 0 && $a['user'] != 0)
{
//----------------------------------//
$num_post = mysql_result(mysql_query("SELECT COUNT(id) FROM `f_message` WHERE `tid` = '$t'"), 0);
if ($num_post > 10) {
$pg = ceil($num_post / 10);
$st = '&page=' . $pg;
} else {
$st = '';
}
$best = my_int($_GET['best']);
$sqlP = mysql_query("SELECT id, user FROM f_message WHERE id = '$best' LIMIT 1");
$isP = mysql_fetch_assoc($sqlP);
if (mysql_num_rows($sqlP) == false)
{
header('Location: ?do=them&r='.$r.'&p='.$p.'&t=' . $t . $st);
}
elseif ($isP['user'] == $user['id'])
{
header('Location: ?do=them&r='.$r.'&p='.$p.'&t=' . $t . $st);
}
elseif ($a['best'] != 0)
{
header('Location: ?do=them&r='.$r.'&p='.$p.'&t=' . $t . $st);
}
else
{
mysql_query("UPDATE f_message SET best = '1' WHERE id = '$best' LIMIT 1");
header('Location: ?do=them&r='.$r.'&p='.$p.'&t=' . $t . $st);
}
} else {
header('Location: ?do=them&r='.$r.'&p='.$p.'&t=' . $t . $st);
}
}
if (isset($_GET['worse']))
{
//----------------------------------//
if ($user['id'] == $i_th['author'] && $i_th['close'] == 0 && mysql_num_rows($noWorse) == 0 && $a['user'] != $user['id'] && $a['best'] == 0 && $a['worse'] == 0 && $a['user'] != 0)
{
//----------------------------------//
$num_post = mysql_result(mysql_query("SELECT COUNT(id) FROM `f_message` WHERE `tid` = '$t'"), 0);
if ($num_post > 10) {
$pg = ceil($num_post / 10);
$st = '&page=' . $pg;
} else {
$st = '';
}
$worse = my_int($_GET['worse']);
$sqlP = mysql_query("SELECT id, user FROM f_message WHERE id = '$worse' LIMIT 1");
$isP = mysql_fetch_assoc($sqlP);
if (mysql_num_rows($sqlP) == false)
{
header('Location: ?do=them&r='.$r.'&p='.$p.'&t=' . $t . $st);
}
elseif ($isP['user'] == $user['id'])
{
header('Location: ?do=them&r='.$r.'&p='.$p.'&t=' . $t . $st);
}
elseif ($a['worse'] != 0)
{
header('Location: ?do=them&r='.$r.'&p='.$p.'&t=' . $t . $st);
}
else
{
mysql_query("UPDATE f_message SET worse = '1' WHERE id = '$worse' LIMIT 1");
header('Location: ?do=them&r='.$r.'&p='.$p.'&t=' . $t . $st);
}
} else {
header('Location: ?do=them&r='.$r.'&p='.$p.'&t=' . $t . $st);
}
}
if ($user['id'] == $i_th['author'] && $i_th['close'] == 0 && mysql_num_rows($noBest) == 0 && $a['user'] != $user['id'] && $a['best'] == 0 && $a['worse'] == 0 && $a['user'] != 0)
{
$answerB = '<a href="?do=them&r='.$r.'&p='.$p.'&t='.$t.'&best='.$a['id'].'"><span style="color:#00AA00;">[+]</span></a>';
}
else
{
$answerB = '';
}
if ($user['id'] == $i_th['author'] && $i_th['close'] == 0 && mysql_num_rows($noWorse) == 0 && $a['user'] != $user['id'] && $a['best'] == 0 && $a['worse'] == 0 && $a['user'] != 0)
{
$answerW = '<a href="?do=them&r='.$r.'&p='.$p.'&t='.$t.'&worse='.$a['id'].'"><span style="color:#FF3030;">[-]</span></a>';
}
else
{
$answerW = '';
}
if (!empty($a['path'])) {
$Size = filesize('upload/'.$a['path']);
$Size = get_size($Size);
}
$_path = (!empty($a['path']))
? '<span style="color: #0080A0;">Файл:</span>
<a href="upload/'.$a['path'].'">' .$a['path'] . '</a>
<span style="color: #0080A0;">(' . $Size . ')</span>'
: '';
$d_file = ($user['id'] == $a['user'] && $i_th['close'] == 0 && !empty($a['path']) || $user['level'] >= 3 && $user['level'] <= 5 && $i_th['close'] == 0 && !empty($a['path']))
? '<br/><a href="index.php?do=them&r='.$r.'&p='.$p.'&t='.$t.'&df='.$a['id'].'">[Удалить файл]</a>' . $block
: '';
// подсветка кода
$_edt = (!empty($a['whoedit']))
?
'<small><span style="color: #999999;">Изменено: ' . user_inf($a['whoedit'], 'user') . '</span></small><br/>'
:
'';
#################################
if ($a['best'] != 0) $selPost = ' <span style="color:#00AA00;">Лучший ответ</span>';
elseif ($a['worse'] != 0) $selPost = ' <span style="color:#FF0000;">Худший ответ</span>';
else $selPost = '';
#################################
echo '<div class="menu">';
echo ''.uus($a['user']).'<div class="auth2"><b>'.us($a['user']).'</b>'.$answerB.''.$answerW.''.$online.'</div>('.date('d.m.y в H:i', $a['time']).')</td></tr></table>'.$selPost.'<div class="auth2">'.$upr.''.$_ank.'</div>'.smiles(bb_code($a['msg'])).'</br></br>'.$_path.''.$d_file.''.$_edt.'';
echo '</td></tr></table></div>';
echo '</div>';
}
echo $n->navi();
}
else
{
echo '';
}
// ответ на пост
if ($i_th['close'] == 0) {
if (isset($_GET['k']) && user_inf($_GET['k'])) {
$k = my_int($_GET['k']);
$komu = htmlspecialchars('[b]Ответ: ' . user_inf($k, 'user') . '[/b], ');
}
if (isset($_SESSION['us']) && isset($_SESSION['ps']))
{
echo '<div class="menu"><a name="down"></a>Быстрый ответ:<br/>';
echo '<form enctype="multipart/form-data" action="index.php?do=them" method="post" name="form">
<textarea id="Site" name="msg" class="input" rows="5" cols="20">'.$komu.''.$cit_post.'</textarea>'.quickcode().'
<br/>
<input type="checkbox" name="up" value="1"/> Прикрепить файл<br/>
<input type="hidden" name="r" value="' . $r . '"/>
<input type="hidden" name="p" value="' . $p . '"/>
<input type="hidden" name="t" value="' . $t . '"/>
<input type="hidden" name="adr" value="' . my_int($k) . '"/>
<input type="submit" class="button" name="add" value="Написать"/>
</form></div>';
}
if (isset($_SESSION['us'])) echo '';
}
else
{
echo '<div class="title">Тема закрыта!</div>';
}
$CountInThem = mysql_result(mysql_query("SELECT COUNT(id) FROM inthem WHERE uid = '$t' AND time + '100' > '" . time() . "'"), 0);
echo '<div class="menu"><a class="ssyl2" href="index.php?do=who&r='.$r.'&p='.$p.'&t='.$t.'">Кто в теме (' . $CountInThem . ')</a></div>';
break;
/*
* Голосование
*/
case vote:
$p = my_int($_REQUEST['p']);
$r = my_int($_REQUEST['r']);
$x = my_int($_REQUEST['x']);
$empty_2 = mysql_query("SELECT * FROM `f_pod` WHERE `id` = '$p' LIMIT 1");
$empty_3 = mysql_query("SELECT * FROM `f_razdel` WHERE `id` = '$r' LIMIT 1");
$Ob = mysql_query("SELECT `f_razdel`.* FROM `f_razdel` WHERE `id` = '$r' AND `id` IN(SELECT `pid` FROM `f_pod` WHERE `id` = '$p')");
$emptyT = mysql_query("SELECT `f_pod`.* FROM `f_pod` WHERE `id` = '$p' AND `id` IN(SELECT `rid` FROM `f_them` WHERE `id` = '$x')");
if (mysql_num_rows($Ob) == FALSE) {
err('Ошибка!');
include '../system/foot.php';
exit();
}
if (mysql_num_rows($emptyT) == FALSE) {
err('Ошибка!');
include '../system/foot.php';
exit();
}
if (mysql_num_rows($empty_2) == FALSE) {
err('Подфорума не существует!');
include '../system/foot.php';
exit();
}
if (mysql_num_rows($empty_3) == FALSE) {
err('Раздела не существует!');
include '../system/foot.php';
exit();
}
$sql = mysql_query("SELECT `author` FROM `f_them` WHERE `id` = '$x' LIMIT 1");
$inf = mysql_fetch_assoc($sql);
if ($inf['author'] != $user['id'] && $user['level'] < 3) {
header('Location: index.php?do=them&r='.$r.'&p='.$p.'&t=' . $x);
die();
} elseif (!empty($inf['vote'])) {
err('Опрос уже создан!');
} else {
if (isset($_POST['create'])) {
$quest = trim(mysql_real_escape_string(check($_POST['quest'])));
$var1 = trim(mysql_real_escape_string(check($_POST['var1'])));
$var2 = trim(mysql_real_escape_string(check($_POST['var2'])));
$var3 = trim(mysql_real_escape_string(check($_POST['var3'])));
$var4 = trim(mysql_real_escape_string(check($_POST['var4'])));
if (empty($quest)) {
err('Вопрос не может быть пустым!');
} elseif (empty($var1) && empty($var2)) {
err('Должно быть хотя бы 2 первых варианта!');
} else {
mysql_query("UPDATE `f_them` SET
`quest` = '$quest',
`var1` = '$var1',
`var2` = '$var2',
`var3` = '$var3',
`var4` = '$var4'
WHERE `id` = '$x' LIMIT 1");
header('Location: index.php?do=them&r='.$r.'&p='.$p.'&t=' . $x);
}
}
echo $div_title . 'Добавить опрос' . $div_end;
echo '<FORM method="POST" action="index.php?do=vote&r='.$r.'&p='.$p.'&x='.$x.'">
<label>Вопрос:</label><br/>
<textarea name="quest" cols="50" rows="5" style="width: 99%;"></textarea>
<br/>
<label>Вариант #1:</label><br/>
<input type="text" name="var1"/>
<br/>
<label>Вариант #2:</label><br/>
<input type="text" name="var2"/>
<br/>
<label>Вариант #3:(необязательно)</label><br/>
<input type="text" name="var3"/>
<br/>
<label>Вариант #4:(необязательно)</label><br/>
<input type="text" name="var4"/>
<br/>
<input type="submit" name="create" value="Добавить"/>
</FORM>';
}
echo '« <a href="index.php?do=them&r='.$r.'&p='.$p.'&t='.$x.'">Назад</a>';
break;
/*
* Изменение голосования
*/
case edit_vote:
$p = my_int($_REQUEST['p']);
$r = my_int($_REQUEST['r']);
$x = my_int($_REQUEST['x']);
$empty_2 = mysql_query("SELECT * FROM `f_pod` WHERE `id` = '$p' LIMIT 1");
$empty_3 = mysql_query("SELECT * FROM `f_razdel` WHERE `id` = '$r' LIMIT 1");
$Ob = mysql_query("SELECT `f_razdel`.* FROM `f_razdel` WHERE `id` = '$r' AND `id` IN(SELECT `pid` FROM `f_pod` WHERE `id` = '$p')");
$emptyT = mysql_query("SELECT `f_pod`.* FROM `f_pod` WHERE `id` = '$p' AND `id` IN(SELECT `rid` FROM `f_them` WHERE `id` = '$x')");
$sql = mysql_query("SELECT * FROM `f_them` WHERE `id` = '$x' LIMIT 1");
$inf = mysql_fetch_assoc($sql);
if (mysql_num_rows($Ob) == FALSE) {
err('Ошибка!');
include '../system/foot.php';
exit();
}
if (mysql_num_rows($emptyT) == FALSE) {
err('Ошибка!');
include '../system/foot.php';
exit();
}
if (mysql_num_rows($empty_2) == FALSE) {
err('Подфорума не существует!');
include '../system/foot.php';
exit();
}
if (mysql_num_rows($empty_3) == FALSE) {
err('Раздела не существует!');
include '../system/foot.php';
exit();
}
if (empty($inf['quest'])) {
err('Опрос еще не создан чтобы его редактировать!');
include '../system/foot.php';
exit();
}
if ($inf['author'] != $user['id'] && $user['level'] < 3) {
header('Location: index.php?do=them&r='.$r.'&p='.$p.'&t=' . $x);
die();
} else {
if (isset($_POST['create'])) {
$quest = trim(mysql_real_escape_string(check($_POST['quest'])));
$var1 = trim(mysql_real_escape_string(check($_POST['var1'])));
$var2 = trim(mysql_real_escape_string(check($_POST['var2'])));
$var3 = trim(mysql_real_escape_string(check($_POST['var3'])));
$var4 = trim(mysql_real_escape_string(check($_POST['var4'])));
if (empty($quest)) {
err('Вопрос не может быть пустым!');
} elseif (empty($var1) && empty($var2)) {
err('Должно быть хотя бы 2 первых варианта!');
} else {
mysql_query("UPDATE `f_them` SET
`quest` = '$quest',
`var1` = '$var1',
`var2` = '$var2',
`var3` = '$var3',
`var4` = '$var4'
WHERE `id` = '$x' LIMIT 1");
header('Location: index.php?do=them&r='.$r.'&p='.$p.'&t=' . $x);
}
}
echo $div_title . 'Добавить опрос' . $div_end;
echo '<FORM method="POST" action="index.php?do=vote&r='.$r.'&p='.$p.'&x='.$x.'">
<label>Вопрос</label>:<br/>
<textarea name="quest" cols="50" rows="5" style="width: 99%;">' . $inf['quest'] . '</textarea>
<br/>
<label>Вариант #1:</label><br/>
<input type="text" name="var1" value="' . $inf['var'] . '"/>
<br/>
<label>Вариант #2:</label><br/>
<input type="text" name="var2" value="' . $inf['var2'] . '"/>
<br/>
<label>Вариант #3: (необязательно)</label><br/>
<input type="text" name="var3" value="' . $inf['var3'] . '"/>
<br/>
<label>Вариант #4: (необязательно)</label><br/>
<input type="text" name="var4" value="' . $inf['var4'] . '"/>
<br/>
<input type="submit" name="create" value="Добавить"/>
</FORM>';
}
echo '« <a href="index.php?do=them&r='.$r.'&p='.$p.'&t='.$x.'">Назад</a>';
break;
case whovote:
$p = my_int($_GET['p']);
$r = my_int($_GET['r']);
$t = my_int($_GET['t']);
$v = my_int($_GET['v']);
$empty_2 = mysql_query("SELECT * FROM `f_pod` WHERE `id` = '$p' LIMIT 1");
$empty_3 = mysql_query("SELECT * FROM `f_razdel` WHERE `id` = '$r' LIMIT 1");
$Ob = mysql_query("SELECT `f_razdel`.* FROM `f_razdel` WHERE `id` = '$r' AND `id` IN(SELECT `pid` FROM `f_pod` WHERE `id` = '$p')");
$emptyT = mysql_query("SELECT `f_pod`.* FROM `f_pod` WHERE `id` = '$p' AND `id` IN(SELECT `rid` FROM `f_them` WHERE `id` = '$t')");
$sql = mysql_query("SELECT quest FROM `f_them` WHERE `id` = '$t' LIMIT 1");
$inf = mysql_fetch_assoc($sql);
if (mysql_num_rows($Ob) == FALSE) {
err('Ошибка!');
include '../system/foot.php';
exit();
}
if (mysql_num_rows($emptyT) == FALSE) {
err('Ошибка!');
include '../system/foot.php';
exit();
}
if (mysql_num_rows($empty_2) == FALSE) {
err('Подфорума не существует!');
include '../system/foot.php';
exit();
}
if (mysql_num_rows($empty_3) == FALSE) {
err('Раздела не существует!');
include '../system/foot.php';
exit();
}
if (empty($inf['quest'])) {
err('В этой теме нет опроса!');
include '../system/foot.php';
exit();
}
if ($v < 1 || $v > 4)
{
header('Location: ?do=them&r='.$r.'&p='.$p.'&t=' . $t);
die();
}
$res = mysql_result(mysql_query("SELECT COUNT(id) FROM f_votes WHERE them = '$t' AND var = '$v'"), 0);
if ($res != 0)
{
$n = new navigator($res, 10, '?do=whovotes&r='.$r.'&p='.$p.'&t='.$t.'&v='.$v.'&');
$Res = mysql_query("SELECT * FROM f_votes WHERE them = '$t' AND var = '$v' ORDER BY id DESC {$n->limit}");
while($inRes = mysql_fetch_assoc($Res))
{
echo us($inRes['user']) . '<br/>';
}
echo $n->navi();
} else {
echo 'За этот вариант никто не голосовал.<br/>';
}
echo '« <a href="index.php?do=them&r='.$r.'&p='.$p.'&t='.$t.'">Назад</a>';
break;
/*
* Цитирование
*/
case cit:
if (empty($_SESSION['us'])) {
header('Location: /reg.php?');
die();
}
$p = my_int($_REQUEST['p']);
$r = my_int($_REQUEST['r']);
$t = my_int($_REQUEST['t']);
$c = my_int($_REQUEST['c']);
$empty_2 = mysql_query("SELECT id, name FROM `f_pod` WHERE `id` = '$p' LIMIT 1");
$empty_3 = mysql_query("SELECT id, name FROM `f_razdel` WHERE `id` = '$r' LIMIT 1");
if (mysql_num_rows($empty_2) == FALSE) {
err('Подфорума не существует!');
include '../system/foot.php';
exit();
}
if (mysql_num_rows($empty_3) == FALSE) {
err('Раздела не существует!');
include '../system/foot.php';
exit();
}
$em = mysql_query("SELECT msg, user FROM `f_message` WHERE `id` = '$c' AND `tid` = '$t' LIMIT 1");
$emt = mysql_query("SELECT close FROM `f_them` WHERE `id` = '$t' LIMIT 1");
$i = mysql_fetch_assoc($em);
$ii = mysql_fetch_assoc($emt);
if ($i['user'] == 0 && !isset($_POST['ok']) || $i['user'] == $user['id'] && !isset($_POST['ok'])) {
header('Location: index.php?do=them&r='.$r.'&p='.$p.'&t=' . $t);
die();
}
if ($ii['close'] == 1) {
err('Тема закрыта!');
include '../system/foot.php';
exit();
}
if (mysql_num_rows($em) == FALSE || mysql_num_rows($emt) == FALSE) {
err('Ошибка!');
include '../system/foot.php';
exit();
}
if (isset($_POST['ok'])) {
$date = date('d.m.y H:i');
$msg = trim(mysql_real_escape_string(check($_POST['msg'])));
$m = mysql_fetch_array(mysql_query("SELECT `user`, `msg`
FROM `f_message`
WHERE
`id` = '" . my_int($_POST['c']) . "'
AND
`tid` = '" . my_int($_POST['t']) . "'
LIMIT 1"));
// урезаем див цитаты
if (preg_match('/<div class="q">(.*?)</div>/si', $m[1], $rep)) {
$m[1] = str_replace($rep[0], '', $m[1]);
}
// Антиреклама
$_ant = mysql_fetch_assoc(mysql_query("SELECT `on_rekl`, `text_rekl` FROM `setting` WHERE `ids` = '1'"));
if ($_ant['on_rekl'] == 1 && filesize($_SERVER['DOCUMENT_ROOT'] . '/domains.dat') > 0) {
$ex = explode(',', file_get_contents('../domains.dat'));
foreach($ex as $value) {
if ($user['level'] != 4 && $user['level'] != 5 && !preg_match('/[url=http://(.*)[/url]/si', $msg)) {
$msg = preg_replace("/(w)(s|,|.|*|_|-|+)+$value/si", $_ant['text_rekl'], $msg);
}
}
}
// транслит
if ($user['translit'] == 1) {
$msg = trun_to_rus($msg);
}
// антимат
$ant = mysql_fetch_array(mysql_query("SELECT `antimat` FROM `setting` WHERE `ids` = '1'"));
$msg = ($ant[0] == 1) ? mat($msg) : $msg;
if (!empty($msg)) {
// Лента
if (user_inf($m['user'], 'comm_forum') == 1 && $user['id'] != $m['user']) {
$message = cvetnik($user['id']) . ' ответил на Ваш комментарий в <a href="forum/index.php?do=them&r='.$r.'&p='.$p.'&t='.$t.'">теме</a>!';
mysql_query("INSERT INTO `lenta` SET
`user` = '$m[user]',
`text` = '$message',
`type` = 'comments',
`date` = '" . time() . "',
`uid` = 'forum$t',
`read` = '1'");
}
// Обрезка длинного сообщения
$cont = (mb_strlen($m[1], 'UTF8') > 200)
? mb_substr($m[1], 0, 200, 'UTF8') . '...'
: $m[1];
$mess = '<div class="q">' . user_inf($m[0], 'user') . ': ' . $cont . '</div>' . $msg;
mysql_query("INSERT INTO `f_message` SET `tid` = '$t', `podforum` = '$p', `user` = '$user[id]', `msg` = '$mess', `time` = '" . time() . "'");
// апдейт времени последней темы
mysql_query("UPDATE `f_them` SET `last` = '" . time() . "' WHERE `id` = '$t' LIMIT 1");
###############################
$num_post = mysql_result(mysql_query("SELECT COUNT(id) FROM `f_message` WHERE `tid` = '$t'"), 0);
if ($num_post > 10) {
$pg = ceil($num_post / 10);
$st = '&page=' . $pg;
} else {
$st = '';
}
###############################
header('Location: index.php?do=them&r='.$r.'&p='.$p.'&t=' . $t . $st);
}
else
{
header('Location: index.php?do=them&r='.$r.'&p='.$p.'&t=' . $t . $st);
}
}
// урезаем див цитаты
if (preg_match('/<div class="q">(.*?)</div>/si', $i['msg'], $rep)) {
$i['msg'] = str_replace($rep[0], '', $i['msg']);
}
$i_rzd = mysql_fetch_assoc($empty_3);
$i_pdf = mysql_fetch_assoc($empty_2);
$cont = (mb_strlen($i['msg'], 'UTF8') > 200)
? mb_substr($i['msg'], 0, 200, 'UTF8') . '...'
: $i['msg'];
echo $div_title . 'Цитирование' . $div_end . $div_menu . '
<img src="img/up.gif" alt="*"/> <a href="index.php?">Форум</a> |
<a href="index.php?do=razdel&r='.$i_rzd['id'].'">' . $i_rzd['name'] . '</a> |
<a href="index.php?do=pod&r='.$i_rzd['id'].'&p='.$i_pdf['id'].'">' . $i_pdf['name'] . '</a>
' . $block . '
<a href="index.php?do=search">Поиск</a> |
<a href="index.php?do=act">Активные</a> |
<a href="index.php?do=newt">Новые</a> |
<a href="index.php?do=my">Мои темы</a>
' . $div_end . '
<FORM method="POST" action="index.php?do=cit">
<div class="q">' . user_inf($i['user'], 'user') . ': ' . bb_code($cont) . '</div>
<textarea name="msg" cols="50" rows="5" style="width: 99%;"></textarea>
<br/>
<input type="hidden" name="r" value="' . $r . '"/>
<input type="hidden" name="p" value="' . $p . '"/>
<input type="hidden" name="t" value="' . $t . '"/>
<input type="hidden" name="c" value="' . $c . '"/>
<input type="submit" name="ok" value="Цитировать"/>
</FORM>
« <a href="index.php?do=them&r='.$r.'&p='.$p.'&t='.$t.'">Назад</a>';
break;
/*
* Изменение поста
*/
case izm:
if (empty($_SESSION['us'])) {
header('Location: /reg.php?');
die();
}
$p = my_int($_REQUEST['p']);
$r = my_int($_REQUEST['r']);
$empty_2 = mysql_query("SELECT * FROM `f_pod` WHERE `id` = '$p' LIMIT 1");
$empty_3 = mysql_query("SELECT * FROM `f_razdel` WHERE `id` = '$r' LIMIT 1");
if (mysql_num_rows($empty_2) == FALSE) {
err('Подфорума не существует!');
include '../system/foot.php';
exit();
}
if (mysql_num_rows($empty_3) == FALSE) {
err('Раздела не существует!');
include '../system/foot.php';
exit();
}
$t = my_int($_REQUEST['t']);
$e = my_int($_GET['e']);
$em = mysql_query("SELECT * FROM `f_message` WHERE `id` = '$e' AND `tid` = '$t' LIMIT 1");
$emt = mysql_query("SELECT * FROM `f_them` WHERE `id` = '$t' LIMIT 1");
$i = mysql_fetch_assoc($em);
$ii = mysql_fetch_assoc($emt);
if ($i['user'] != $user['id'] && $user['level'] < 3 && !isset($_POST['ok']))
{
header('Location: index.php?do=them&r='.$r.'&p='.$p.'&t=' . $t);
die();
}
if ($ii['close'] == 1) {
err('Тема закрыта!');
include '../system/foot.php';
exit();
}
if (isset($_POST['ok'])) {
// Антиреклама
$_ant = mysql_fetch_assoc(mysql_query("SELECT `on_rekl`, `text_rekl` FROM `setting` WHERE `ids` = '1'"));
if ($_ant['on_rekl'] == 1 && filesize($_SERVER['DOCUMENT_ROOT'] . '/domains.dat') > 0) {
$ex = explode(',', file_get_contents('../domains.dat'));
foreach($ex as $value)
{
if ($user['level'] != 4 && $user['level'] != 5 && !preg_match('/[url=http://(.*)[/url]/si', $msg))
{
$msg = preg_replace("/(w)(s|,|.|*|_|-|+)+$value/si", $_ant['text_rekl'], $msg);
}
}
}
// транслит
if ($user['translit'] == 1) {
$msg = trun_to_rus($msg);
}
// антимат
$ant = mysql_fetch_array(mysql_query("SELECT `antimat` FROM `setting` WHERE `ids` = '1'"));
$msg = ($ant[0] == 1) ? mat($msg) : $msg;
$msg = trim(mysql_real_escape_string(check($_POST['msg'])));
$_em = mysql_query("SELECT * FROM `f_message` WHERE `id` = '".my_int($_POST['e'])."' AND `tid` = '".my_int($_POST['t'])."' LIMIT 1");
$_i = mysql_fetch_assoc($_em);
###############################
$num_post = mysql_result(mysql_query("SELECT COUNT(id) FROM `f_message` WHERE `tid` = '$t'"), 0);
if ($num_post > 10) {
$pg = ceil($num_post / 10);
$st = '&page=' . $pg;
} else {
$st = '';
}
###############################
mysql_query("UPDATE `f_message` SET `msg` = '$msg', `whoedit` = '$user[id]' WHERE `id` = '".my_int($_POST['e'])."' LIMIT 1");
header('Location: index.php?do=them&r='.$r.'&p='.$p.'&t=' . $t . $st);
}
if (mysql_num_rows($em) != FALSE && mysql_num_rows($emt) != FALSE) {
$i_rzd = mysql_fetch_assoc($empty_3);
$i_pdf = mysql_fetch_assoc($empty_2);
echo $div_title . 'Редактирование' . $div_end . $div_menu . '
<img src="img/up.gif" alt="*"/> <a href="index.php?">Форум</a> |
<a href="index.php?do=razdel&r='.$i_rzd['id'].'">' . $i_rzd['name'] . '</a> |
<a href="index.php?do=pod&r='.$i_rzd['id'].'&p='.$i_pdf['id'].'">' . $i_pdf['name'] . '</a>
' . $block . '
<a href="index.php?do=search">Поиск</a> |
<a href="index.php?do=act">Активные</a> |
<a href="index.php?do=newt">Новые</a> |
<a href="index.php?do=my">Мои темы</a>
' . $div_end . '
<FORM method="POST" action="index.php?do=izm">
<textarea name="msg" cols="50" rows="5" style="width: 99%;">' . back_bb($i['msg']) . '</textarea>
<br/>
<input type="hidden" name="r" value="' . $r . '"/>
<input type="hidden" name="p" value="' . $p . '"/>
<input type="hidden" name="t" value="' . $t . '"/>
<input type="hidden" name="e" value="' . $e . '"/>
<input type="submit" name="ok" value="Изменить"/>
</FORM>
« <a href="index.php?do=them&r='.$r.'&p='.$p.'&t='.$t.'">Назад</a>';
} else {
err('Ошибка!');
}
break;
/*
* Новая тема
*/
case add_them:
$p = my_int($_REQUEST['p']);
$r = my_int($_REQUEST['r']);
$empty_2 = mysql_query("SELECT * FROM `f_pod` WHERE `id` = '$p' LIMIT 1");
$empty_3 = mysql_query("SELECT * FROM `f_razdel` WHERE `id` = '$r' LIMIT 1");
$Ob = mysql_query("SELECT `f_razdel`.* FROM `f_razdel` WHERE `id` = '$r' AND `id` IN(SELECT `pid` FROM `f_pod` WHERE `id` = '$p')");
if (mysql_num_rows($empty_2) == FALSE) {
err('Подфорума не существует!');
include '../system/foot.php';
exit();
}
if (mysql_num_rows($empty_3) == FALSE) {
err('Раздела не существует!');
include '../system/foot.php';
exit();
}
if (mysql_num_rows($Ob) == FALSE) {
err('Ошибка!');
include '../system/foot.php';
exit();
}
if (empty($_SESSION['us'])) {
header('Location: /reg.php?');
exit();
}
$inf_1 = mysql_fetch_assoc($empty_2);
$inf_2 = mysql_fetch_assoc($empty_3);
echo $div_title . 'Новая тема' . $div_end . $div_menu . '
<img src="img/up.gif" alt="*"/> <a href="index.php?">Форум</a> |
<a href="index.php?do=razdel&r='.$inf_2['id'].'">' . $inf_1['name'] . '</a> |
<a href="index.php?do=pod&r='.$inf_2['id'].'&p='.$inf_1['id'].'">' . $inf_2['name'] . '</a>
' . $block . '
<a href="index.php?do=search">Поиск</a> |
<a href="index.php?do=act">Активные</a> |
<a href="index.php?do=newt">Новые</a> |
<a href="index.php?do=my">Мои темы</a>' . $div_end;
$t = my_int($_REQUEST['t']);
if (isset($_POST['ok'])) {
$title = trim(mysql_real_escape_string(check($_POST['title'])));
$content = trim(mysql_real_escape_string(check($_POST['content'])));
$pr = mysql_query("SELECT COUNT(id) FROM `f_them` WHERE `name` = '$title' AND `rid` = '$t' LIMIT 1");
if (empty($title)) {
err('Не заполнен заголовок!');
} elseif (empty($content)) {
err('Не заполнено содержание!');
} elseif (mysql_result($pr, 0) != 0) {
err('Такая тема уже существует в этом разделе!');
} else {
mysql_query("INSERT INTO `f_them` SET
`rid` = '$p',
`razdel_id` = '$r',
`name` = '$title',
`author` = '$user[id]',
`date` = '" . time() . "',
`last` = '" . time() . "',
`firstpost` = '$content'");
$lid = mysql_insert_id();
header('Location: index.php?do=them&r='.$r.'&p='.$p.'&t=' . $lid);
}
}
echo '<FORM method="POST" action="index.php?do=add_them">
<label>Заголовок:</label><br/>
<input type="text" name="title"/><br/>
<label>Содержание:</label><br/>
<textarea name="content" cols="50" rows="5" style="width: 99%;"></textarea>
<input type="hidden" name="r" value="' . $r . '"/>
<input type="hidden" name="p" value="' . $p . '"/>
<br/>
<input type="submit" name="ok" value="Создать"/>
</FORM>';
break;
/*
* Удаление темы
*/
case del_them:
$p = my_int($_GET['p']);
$r = my_int($_GET['r']);
$x = my_int($_GET['x']);
$empty_2 = mysql_query("SELECT * FROM `f_pod` WHERE `id` = '$p' LIMIT 1");
$empty_3 = mysql_query("SELECT id FROM `f_razdel` WHERE `id` = '$r' LIMIT 1");
$Ob = mysql_query("SELECT `f_razdel`.* FROM `f_razdel` WHERE `id` = '$r' AND `id` IN(SELECT `pid` FROM `f_pod` WHERE `id` = '$p')");
$emptyT = mysql_query("SELECT `f_pod`.* FROM `f_pod` WHERE `id` = '$p' AND `id` IN(SELECT `rid` FROM `f_them` WHERE `id` = '$x')");
if (mysql_num_rows($Ob) == FALSE) {
err('Ошибка!');
include '../system/foot.php';
exit();
}
if (mysql_num_rows($emptyT) == FALSE) {
err('Ошибка!');
include '../system/foot.php';
exit();
}
if (mysql_num_rows($empty_2) == FALSE) {
err('Подфорума не существует!');
include '../system/foot.php';
exit();
}
if (mysql_num_rows($empty_3) == FALSE) {
err('Раздела не существует!');
include '../system/foot.php';
exit();
}
$sql = mysql_query("SELECT `id` FROM `f_them` WHERE `id` = '$x' LIMIT 1");
// информация о разделе
$i_p = mysql_fetch_assoc($empty_2);
if ($user['level'] < 3) {
header('Location: index.php?do=razdel&t=' . $x);
die();
}
if (mysql_num_rows($sql) == FALSE) {
err('Тема не найдена, возможна она была удалена.');
} else {
$msgs = mysql_query("SELECT * FROM `f_message` WHERE `tid` = '$x'");
while($p = mysql_fetch_assoc($msgs)) {
if (file_exists('upload/' . $p['path'])) unlink('upload/' . $p['path']);
}
mysql_query("DELETE FROM `f_message` WHERE `tid` = '$x'");
mysql_query("DELETE FROM `f_them` WHERE `id` = '$x' LIMIT 1");
header('Location: index.php?do=razdel&r=' . $i_p['pid']);
}
break;
/*
* Перемещение темы
*/
case move_them:
$p = my_int($_REQUEST['p']);
$r = my_int($_REQUEST['r']);
$x = my_int($_REQUEST['x']);
$empty_2 = mysql_query("SELECT id, name FROM `f_pod` WHERE `id` = '$p' LIMIT 1");
$empty_3 = mysql_query("SELECT * FROM `f_razdel` WHERE `id` = '$r' LIMIT 1");
$Ob = mysql_query("SELECT `f_razdel`.* FROM `f_razdel` WHERE `id` = '$r' AND `id` IN(SELECT `pid` FROM `f_pod` WHERE `id` = '$p')");
$emptyT = mysql_query("SELECT `f_pod`.* FROM `f_pod` WHERE `id` = '$p' AND `id` IN(SELECT `rid` FROM `f_them` WHERE `id` = '$x')");
if (mysql_num_rows($Ob) == FALSE) {
err('Ошибка!');
include '../system/foot.php';
exit();
}
if (mysql_num_rows($emptyT) == FALSE) {
err('Ошибка!');
include '../system/foot.php';
exit();
}
if (mysql_num_rows($empty_2) == FALSE) {
err('Подфорума не существует!');
include '../system/foot.php';
exit();
}
if (mysql_num_rows($empty_3) == FALSE) {
err('Раздела не существует!');
include '../system/foot.php';
exit();
}
echo $div_title . 'Перемещение темы' . $div_end;
$sql = mysql_query("SELECT * FROM `f_them` WHERE `id` = '$x' LIMIT 1");
// информация о теме
$inf = mysql_fetch_assoc($sql);
// информация о подфоруме
$i_p = mysql_fetch_assoc($empty_2);
if ($user['level'] < 3) {
header('Location: index.php?do=razdel&t=' . $inf['rid']);
die();
}
if (mysql_num_rows($sql) == FALSE) {
err('Тема не найдена, возможна она была удалена.');
} else {
// Перемещение
if (isset($_POST['go_move'])) {
$razdel = my_int($_POST['razdel']);
$podforum = my_int($_POST['podforum']);
$no_r = mysql_query("SELECT * FROM `f_razdel` WHERE `id` = '$razdel' LIMIT 1");
$no_p = mysql_query("SELECT * FROM `f_pod` WHERE `id` = '$podforum' LIMIT 1");
$info_pod = mysql_fetch_assoc($no_p);
if (mysql_num_rows($no_r) == FALSE) {
err('Ошибка при выборе раздела!');
} elseif (mysql_num_rows($no_p) == FALSE) {
err('Ошибка при выборе подфорума!');
} else {
// Перемещаем саму тему
mysql_query("UPDATE `f_them` SET
`rid` = '$podforum',
`razdel_id` = '$razdel'
WHERE `id` = '$x' LIMIT 1");
// сообщение системы
if ($user['level'] == 3) $mylev = 'Ст.Модератор';
elseif ($user['level'] == 4) $mylev = 'Администратор';
elseif ($user['level'] == 5) $mylev = 'Ст.Администратор';
$systxt = 'Тему переместил ' . $mylev . ' ' . $user['user'] . ' из раздела ' . $i_p['name'] . ' в раздел ' . $info_pod['name'];
mysql_query("INSERT INTO `f_message` SET
`tid` = '$x',
`podforum` = '$podforum',
`user` = '0',
`msg` = '$systxt',
`time` = '" . time() . "'");
// Перемещаем сообщения из темы
$in_them = mysql_query("SELECT `id`, `rid` FROM `f_them` WHERE `rid` = '$podforum' AND `razdel_id` = '$razdel' LIMIT 1");
while($isin = mysql_fetch_assoc($in_them)) {
mysql_query("UPDATE `f_message` SET `podforum` = '$isin[rid]' WHERE `tid` = '$isin[id]'");
}
// Редирект в перемещенную тему
header('Location: index.php?do=them&r='.$razdel.'&p='.$podforum.'&t=' . $x);
}
}
// Если уже выбран раздел
if (isset($_POST['move'])) {
$razdel = my_int($_POST['razdel']);
$no_r = mysql_query("SELECT * FROM `f_razdel` WHERE `id` = '$razdel' LIMIT 1");
if (mysql_num_rows($no_r) == FALSE) {
err('Выбран неверный раздел!');
} else {
$Sql_2 = mysql_query("SELECT `id`, `name` FROM `f_pod` WHERE `pid` = '$razdel'");
if (mysql_num_rows($Sql_2) != FALSE) {
echo 'В какой подфорум:<br/>
<FORM method="POST" action="index.php?do=move_them">
<select name="podforum">';
//////////////////////////////
while($scan = mysql_fetch_assoc($Sql_2)) {
echo '<option value="'.$scan['id'].'">' . $scan['name'] . '</option>';
}
echo '</select>
<br/>
<input type="hidden" name="p" value="'.$p.'"/>
<input type="hidden" name="r" value="'.$r.'"/>
<input type="hidden" name="x" value="'.$x.'"/>
<input type="hidden" name="razdel" value="'.$razdel.'"/>
<input type="submit" name="go_move" value="Перенести"/>
</FORM>
' . $block . '
« <a href="index.php?do=them&r='.$r.'&p='.$p.'&t='.$x.'">Назад</a>';
//////////////////////////////
} else {
echo 'В этом разделе нет подфорумов!<br/>';
}
}
// Если уже выбран подфорум
} elseif (!isset($_POST['move'])) {
echo 'В какой раздел:<br/>';
$Sql_1 = mysql_query("SELECT `id`, `name` FROM `f_razdel`");
echo '<FORM method="POST" action="index.php?do=move_them">
<select name="razdel">';
//////////////////////////////
if (mysql_num_rows($Sql_1) != FALSE) {
while($_a = mysql_fetch_assoc($Sql_1)) {
echo '<option value="'.$_a['id'].'">' . $_a['name'] . '</option>';
}
//////////////////////////////
echo '</select>
<br/>
<input type="hidden" name="p" value="'.$p.'"/>
<input type="hidden" name="r" value="'.$r.'"/>
<input type="hidden" name="x" value="'.$x.'"/>
<input type="submit" name="move" value="Выбрать"/>
</FORM>
' . $block . '
« <a href="index.php?do=them&r='.$r.'&p='.$p.'&t='.$x.'">Назад</a>';
}
} else {
echo 'Разделов не найдено!<br/>';
}
}
break;
/*
* Изменение темы
*/
case edit_them:
$p = my_int($_REQUEST['p']);
$r = my_int($_REQUEST['r']);
$x = my_int($_REQUEST['x']);
$empty_2 = mysql_query("SELECT id FROM `f_pod` WHERE `id` = '$p' LIMIT 1");
$empty_3 = mysql_query("SELECT id FROM `f_razdel` WHERE `id` = '$r' LIMIT 1");
$Ob = mysql_query("SELECT `f_razdel`.* FROM `f_razdel` WHERE `id` = '$r' AND `id` IN(SELECT `pid` FROM `f_pod` WHERE `id` = '$p')");
$emptyT = mysql_query("SELECT `f_pod`.* FROM `f_pod` WHERE `id` = '$p' AND `id` IN(SELECT `rid` FROM `f_them` WHERE `id` = '$x')");
if (mysql_num_rows($Ob) == FALSE) {
err('Ошибка!');
include '../system/foot.php';
exit();
}
if (mysql_num_rows($emptyT) == FALSE) {
err('Ошибка!');
include '../system/foot.php';
exit();
}
if (mysql_num_rows($empty_2) == FALSE) {
err('Подфорума не существует!');
include '../system/foot.php';
exit();
}
if (mysql_num_rows($empty_3) == FALSE) {
err('Раздела не существует!');
include '../system/foot.php';
exit();
}
$sql = mysql_query("SELECT `name`, `firstpost`, `author` FROM `f_them` WHERE `id` = '$x' LIMIT 1");
$inf = mysql_fetch_assoc($sql);
if ($inf['author'] != $user['id'] && $user['level'] < 3) {
header('Location: index.php?do=them&r='.$r.'&p='.$p.'&t=' . $x);
die();
}
echo $div_title . $inf['name'] . $div_end . $div_menu . '
<img src="img/up.gif" alt="*"/> <a href="index.php?">Форум</a>
' . $block . '
<a href="index.php?do=search">Поиск</a> |
<a href="index.php?do=act">Активные</a> |
<a href="index.php?do=newt">Новые</a> |
<a href="index.php?do=my">Мои темы</a>' . $div_end;
if (isset($_POST['ok'])) {
$ed = trim(mysql_real_escape_string(check($_POST['ed'])));
$fp = trim(mysql_real_escape_string(check($_POST['fp'])));
if (empty($ed)) {
err('Не заполнен заголовок темы!');
} elseif (empty($fp)) {
err('Не заполнено содержание темы!');
} else {
mysql_query("UPDATE `f_them` SET `name` = '$ed', `firstpost` = '$fp', `whoedit` = '$user[id]' WHERE `id` = '$x' LIMIT 1");
header('Location: index.php?do=them&r='.$r.'&p='.$p.'&t=' . $x);
}
}
if (mysql_num_rows($sql) == FALSE) {
err('Тема не найдена, возможна она была удалена.');
} else {
echo '<FORM method="POST" action="index.php?do=edit_them">
<label>Заголовок:</label><br/>
<input type="text" name="ed" value="' . $inf['name'] . '"/>
<br/>
<label>Содержание:</label><br/>
<textarea name="fp" cols="50" rows="5" style="width: 99%;">' . back_bb($inf['firstpost']) . '</textarea>
<br/>
<input type="hidden" name="r" value="' . $r . '"/>
<input type="hidden" name="p" value="' . $p . '"/>
<input type="hidden" name="x" value="' . $x . '"/>
<input type="submit" name="ok" value="Изменить"/>
</FORM>
« <a href="index.php?do=them&r='.$r.'&p='.$p.'&t='.$x.'">Назад</a>';
}
break;
/*
* Закрытие темы
*/
case close_them:
$p = my_int($_GET['p']);
$r = my_int($_GET['r']);
$x = my_int($_GET['x']);
$empty_2 = mysql_query("SELECT id FROM `f_pod` WHERE `id` = '$p' LIMIT 1");
$empty_3 = mysql_query("SELECT id FROM `f_razdel` WHERE `id` = '$r' LIMIT 1");
$Ob = mysql_query("SELECT `f_razdel`.* FROM `f_razdel` WHERE `id` = '$r' AND `id` IN(SELECT `pid` FROM `f_pod` WHERE `id` = '$p')");
$emptyT = mysql_query("SELECT `f_pod`.* FROM `f_pod` WHERE `id` = '$p' AND `id` IN(SELECT `rid` FROM `f_them` WHERE `id` = '$x')");
if (mysql_num_rows($Ob) == FALSE) {
err('Ошибка!');
include '../system/foot.php';
exit();
}
if (mysql_num_rows($emptyT) == FALSE) {
err('Ошибка!');
include '../system/foot.php';
exit();
}
if (mysql_num_rows($empty_2) == FALSE) {
err('Подфорума не существует!');
include '../system/foot.php';
exit();
}
if (mysql_num_rows($empty_3) == FALSE) {
err('Раздела не существует!');
include '../system/foot.php';
exit();
}
$sql = mysql_query("SELECT `author`,id FROM `f_them` WHERE `id` = '$x' LIMIT 1");
$inf = mysql_fetch_assoc($sql);
if ($inf['author'] != $user['id'] && $user['level'] < 3) {
header('Location: index.php?do=them&r='.$r.'&p='.$p.'&t=' . $x);
}
{
###############################
$a = mysql_result(mysql_query("SELECT COUNT(id) FROM f_message WHERE tid = '$x'"), 0);
if ($a > 10) {
$pg = ceil($a / 10);
$st = '&page=' . $pg;
} else {
$st = '';
}
###############################
mysql_query("UPDATE `f_them` SET `close` = '1' WHERE `id` = '$x' LIMIT 1");
header('Location: index.php?do=them&r='.$r.'&p='.$p.'&t='.$x . $st . '#down');
}
break;
/*
* Открытие темы
*/
case open_them:
$p = my_int($_REQUEST['p']);
$r = my_int($_REQUEST['r']);
$x = my_int($_REQUEST['x']);
$empty_2 = mysql_query("SELECT id FROM `f_pod` WHERE `id` = '$p' LIMIT 1");
$empty_3 = mysql_query("SELECT id FROM `f_razdel` WHERE `id` = '$r' LIMIT 1");
$Ob = mysql_query("SELECT `f_razdel`.* FROM `f_razdel` WHERE `id` = '$r' AND `id` IN(SELECT `pid` FROM `f_pod` WHERE `id` = '$p')");
$emptyT = mysql_query("SELECT `f_pod`.* FROM `f_pod` WHERE `id` = '$p' AND `id` IN(SELECT `rid` FROM `f_them` WHERE `id` = '$x')");
if (mysql_num_rows($Ob) == FALSE) {
err('Ошибка!');
include '../system/foot.php';
exit();
}
if (mysql_num_rows($emptyT) == FALSE) {
err('Ошибка!');
include '../system/foot.php';
exit();
}
if (mysql_num_rows($empty_2) == FALSE) {
err('Подфорума не существует!');
include '../system/foot.php';
exit();
}
if (mysql_num_rows($empty_3) == FALSE) {
err('Раздела не существует!');
include '../system/foot.php';
exit();
}
{
###############################
$a = mysql_result(mysql_query("SELECT COUNT(id) FROM f_message WHERE tid = '$x'"), 0);
if ($a > 10) {
$pg = ceil($a / 10);
$st = '&page=' . $pg;
} else {
$st = '';
}
###############################
mysql_query("UPDATE `f_them` SET `close` = '0' WHERE `id` = '$x' LIMIT 1");
header('Location: index.php?do=them&r='.$r.'&p='.$p.'&t=' . $x . $st);
}
break;
/*
* Закрепление темы
*/
case fix_them:
$p = my_int($_REQUEST['p']);
$r = my_int($_REQUEST['r']);
$x = my_int($_REQUEST['x']);
$empty_2 = mysql_query("SELECT * FROM `f_pod` WHERE `id` = '$p' LIMIT 1");
$empty_3 = mysql_query("SELECT * FROM `f_razdel` WHERE `id` = '$r' LIMIT 1");
$Ob = mysql_query("SELECT `f_razdel`.* FROM `f_razdel` WHERE `id` = '$r' AND `id` IN(SELECT `pid` FROM `f_pod` WHERE `id` = '$p')");
$emptyT = mysql_query("SELECT `f_pod`.* FROM `f_pod` WHERE `id` = '$p' AND `id` IN(SELECT `rid` FROM `f_them` WHERE `id` = '$x')");
if (mysql_num_rows($Ob) == FALSE) {
err('Ошибка!');
include '../system/foot.php';
exit();
}
if (mysql_num_rows($emptyT) == FALSE) {
err('Ошибка!');
include '../system/foot.php';
exit();
}
if (mysql_num_rows($empty_2) == FALSE) {
err('Подфорума не существует!');
include '../system/foot.php';
exit();
}
if (mysql_num_rows($empty_3) == FALSE) {
err('Раздела не существует!');
include '../system/foot.php';
exit();
}
if ($user['level'] < 3) {
header('Location: index.php?do=them&r='.$r.'&p='.$p.'&t=' . $x);
die();
} else {
// сообщение системы
if ($user['level'] == 3) $mylev = 'Ст.Модератор';
elseif ($user['level'] == 4) $mylev = 'Администратор';
elseif ($user['level'] == 5) $mylev = 'Ст.Администратор';
$systxt = 'Тему закрепил ' . $mylev . ' ' . cvetnik($user['id']);
mysql_query("INSERT INTO `f_message` SET
`tid` = '$x',
`podforum` = '$p',
`user` = '0',
`msg` = '$systxt',
`time` = '" . time() . "'");
###############################
$a = mysql_result(mysql_query("SELECT COUNT(id) FROM f_message WHERE tid = '$x'"), 0);
if ($a > 10) {
$pg = ceil($a / 10);
$st = '&page=' . $pg;
} else {
$st = '';
}
###############################
mysql_query("UPDATE `f_them` SET `fix` = '1' WHERE `id` = '$x' LIMIT 1");
header('Location: index.php?do=them&r='.$r.'&p='.$p.'&t=' . $x . $st);
}
break;
/*
* Открепление темы
*/
case detach_them:
$p = my_int($_REQUEST['p']);
$r = my_int($_REQUEST['r']);
$x = my_int($_REQUEST['x']);
$empty_2 = mysql_query("SELECT * FROM `f_pod` WHERE `id` = '$p' LIMIT 1");
$empty_3 = mysql_query("SELECT * FROM `f_razdel` WHERE `id` = '$r' LIMIT 1");
$Ob = mysql_query("SELECT `f_razdel`.* FROM `f_razdel` WHERE `id` = '$r' AND `id` IN(SELECT `pid` FROM `f_pod` WHERE `id` = '$p')");
$emptyT = mysql_query("SELECT `f_pod`.* FROM `f_pod` WHERE `id` = '$p' AND `id` IN(SELECT `rid` FROM `f_them` WHERE `id` = '$x')");
if (mysql_num_rows($Ob) == FALSE) {
err('Ошибка!');
include '../system/foot.php';
exit();
}
if (mysql_num_rows($emptyT) == FALSE) {
err('Ошибка!');
include '../system/foot.php';
exit();
}
if (mysql_num_rows($empty_2) == FALSE) {
err('Подфорума не существует!');
include '../system/foot.php';
exit();
}
if (mysql_num_rows($empty_3) == FALSE) {
err('Раздела не существует!');
include '../system/foot.php';
exit();
}
if ($user['level'] < 3) {
header('Location: index.php?do=them&r='.$r.'&p='.$p.'&t=' . $x);
die();
} else {
// сообщение системы
if ($user['level'] == 3) $mylev = 'Ст.Модератор';
elseif ($user['level'] == 4) $mylev = 'Администратор';
elseif ($user['level'] == 5) $mylev = 'Ст.Администратор';
$systxt = 'Тему открепил ' . $mylev . ' ' . cvetnik($user['id']);
mysql_query("INSERT INTO `f_message` SET
`tid` = '$x',
`podforum` = '$p',
`user` = '0',
`msg` = '$systxt',
`time` = '" . time() . "'");
$a = mysql_result(mysql_query("SELECT COUNT(id) FROM f_message WHERE tid = '$x'"), 0);
if ($a > 10) {
$pg = ceil($a / 10);
$st = '&page=' . $pg;
} else {
$st = '';
}
###############################
mysql_query("UPDATE `f_them` SET `fix` = '0' WHERE `id` = '$x' LIMIT 1");
header('Location: index.php?do=them&r='.$r.'&p='.$p.'&t=' . $x . $st);
}
break;
/*
* Поиск
*/
case search:
echo $div_title . 'Поиск' . $div_end . $div_menu . '
<img src="img/up.gif" alt="*"/> <a href="index.php?">Форум</a>
' . $block . '
<b>Поиск</b></a> |
<a href="index.php?do=act">Активные</a> |
<a href="index.php?do=newt">Новые</a> |
<a href="index.php?do=my">Мои темы</a>' . $div_end;
unset($_SESSION['s']);
unset($_SESSION['where']);
echo '<FORM method="POST" action="index.php?do=search_result">
<label>Часть текста:</label><br/>
<input type="text" name="s"/>
<br/>
<label>Искать в:</label><br/>
<input type="radio" name="where" checked="checked" value="1"/> темах
<br/>
<input type="radio" name="where" value="2"/> сообщениях
<br/>
<input type="submit" name="ok" value="Найти"/>
</FORM>';
break;
case search_result:
echo $div_title . 'Поиск' . $div_end . $div_menu . '
<img src="img/up.gif" alt="*"/> <a href="index.php?">Форум</a>
' . $block . '
<b>Поиск</b></a> |
<a href="index.php?do=act">Активные</a> |
<a href="index.php?do=newt">Новые</a> |
<a href="index.php?do=my">Мои темы</a>' . $div_end;
if (isset($_SESSION['s'])) $s = my_check($_SESSION['s']);
if (isset($_POST['s'])) $s = my_check($_POST['s']);
$s = addcslashes($s, '_%');
if (isset($_SESSION['where'])) $where = my_int($_SESSION['where']);
if (isset($_POST['where'])) $where = my_int($_POST['where']);
$_SESSION['s'] = $s;
$_SESSION['where'] = $where;
if (empty($s)) {
err('Не введен поисковой запрос!');
} else {
// поиск в темах
if ($where == 1) {
$_res = mysql_result(mysql_query("SELECT COUNT(id) FROM `f_them` WHERE `name` LIKE '%$s%'"), 0);
if ($_res != FALSE) {
$n = new navigator($_res, 10, '?do=search_result&');
$_sr = mysql_query("SELECT `f_them`.*,
(SELECT COUNT(id) FROM `f_message` WHERE `f_message`.`tid` = `f_them`.`id`) AS c,
(SELECT `pid` FROM `f_pod` WHERE `f_pod`.`id` = `f_them`.`rid`) AS t
FROM `f_them` WHERE `f_them`.`name` LIKE '%$s%' ORDER BY `f_them`.`id` DESC {$n->limit}");
$dv = 0;
echo $block . '<b>Результаты:</b> ' . $_res . $block;
while($a = mysql_fetch_assoc($_sr)) {
###############################
if ($a['c'] > 10) {
$pg = ceil($a['c'] / 10);
$st = ' <a href="index.php?do=them&r='.$a['t'].'&t='.$a['id'].'&p='.$a['rid'].'&page='.$pg.'"><b>»»</b></a>';
} else {
$st = '';
}
###############################
echo ($dv ++ % 2) ? $div_tworazdel : $div_razdel;
echo '<a href="index.php?do=them&r='.$a['t'].'&p='.$a['rid'].'&t='.$a['id'].'">' . $a['name'] . '</a> (' . $a['c'] . ')' . $st . $div_end;
}
echo $n->navi();
} else {
err('По запросу ' . $s . ' ничего не найдено!');
}
// поиск в сообщениях
} elseif ($where == 2) {
$_res = mysql_result(mysql_query("SELECT COUNT(id) FROM `f_message` WHERE `msg` LIKE '%$s%'"), 0);
if ($_res != FALSE) {
$n = new navigator($_res, 10, '?do=search_result&');
$_sr = mysql_query("SELECT `f_message`.*,
(SELECT `name` FROM `f_them` WHERE `f_them`.`rid` = `f_message`.`podforum` LIMIT 1) AS c,
(SELECT `razdel_id` FROM `f_them` WHERE `f_them`.`rid` = `f_message`.`podforum` LIMIT 1) AS a,
(SELECT `id` FROM `f_them` WHERE `f_them`.`rid` = `f_message`.`podforum` LIMIT 1) AS t
FROM `f_message` WHERE `f_message`.`msg` LIKE '%$s%' ORDER BY `f_message`.`id` DESC {$n->limit}");
$dv = 0;
echo $block . '<b>Результаты:</b> ' . $_res . $block;
while($a = mysql_fetch_assoc($_sr)) {
$a['msg'] = bb_code($a['msg']);
$new_string = preg_replace('/('.$s.')/siu','<b style="color:#FF0000">\1</b>', $a['msg']);
echo ($dv ++ % 2) ? $div_tworazdel : $div_razdel;
echo $div_aut . $a['c'] . $div_end . '<a href="index.php?do=them&r='.$a['a'].'&p='.$a['podforum'].'&t='.$a['t'].'">' . $new_string . '</a>' . $div_end;
}
echo $n->navi();
} else {
err('По запросу ' . $s . ' ничего не найдено!');
}
} else {
err('Не выбран поисковой путь!');
}
}
break;
/*
* Новые темы
*/
case newt:
echo $div_title . 'Новые' . $div_end . $div_menu . '
<img src="img/up.gif" alt="*"/> <a href="index.php?">Форум</a>
' . $block . '
<a href="index.php?do=search">Поиск</a> |
<a href="index.php?do=act">Активные</a> |
<b>Новые</b> |
<a href="index.php?do=my">Мои темы</a>' . $div_end;
$_res = mysql_result(mysql_query("SELECT COUNT(id) FROM `f_them`"), 0);
if ($_res != FALSE) {
$n = new navigator($_res, 10, '?do=newt&');
$th = mysql_query("SELECT `f_them`.*,
(SELECT COUNT(id) FROM `f_message` WHERE `f_message`.`tid` = `f_them`.`id`) AS c,
(SELECT `pid` FROM `f_pod` WHERE `f_pod`.`id` = `f_them`.`rid`) AS t
FROM `f_them` ORDER BY `f_them`.`id` DESC {$n->limit}");
$i = 0;
while($a = mysql_fetch_assoc($th)) {
###############################
if ($a['c'] > 10) {
$pg = ceil($a['c'] / 10);
$st = ' <a href="index.php?do=them&r='.$a['t'].'&t='.$a['id'].'&p='.$a['rid'].'&page='.$pg.'"><b>»»</b></a>';
} else {
$st = '';
}
###############################
echo ($i ++ % 2) ? $div_tworazdel : $div_razdel;
echo '<a href="index.php?do=them&r='.$a['t'].'&t='.$a['id'].'&p='.$a['rid'].'">' .$a['name'] . '</a> (' . $a['c'] . ')' . $st . $div_end;
}
echo $n->navi();
} else {
echo 'Новыx тем не найдено!<br/>';
}
break;
/*
* Мои темы
*/
case my:
echo $div_title . 'Мои темы' . $div_end . $div_menu . '
<img src="img/up.gif" alt="*"/> <a href="index.php?">Форум</a>
' . $block . '
<a href="index.php?do=search">Поиск</a> |
<a href="index.php?do=act">Активные</a> |
<a href="index.php?do=newt">Новые</a> |
<b>Мои темы</b>' . $div_end;
$_res = mysql_result(mysql_query("SELECT COUNT(id) FROM `f_them` WHERE `author` = '$user[id]'"), 0);
if ($_res != FALSE) {
$n = new navigator($_res, 10, '?do=my&');
$th = mysql_query("SELECT `f_them`.*,
(SELECT COUNT(id) FROM `f_message` WHERE `f_message`.`tid` = `f_them`.`id`) AS c,
(SELECT `pid` FROM `f_pod` WHERE `f_pod`.`id` = `f_them`.`rid`) AS t
FROM `f_them` WHERE `author` = '$user[id]' ORDER BY `id` DESC {$n->limit}");
$i = 0;
while($a = mysql_fetch_assoc($th)) {
###############################
if ($a['c'] > 10) {
$pg = ceil($a['c'] / 10);
$st = ' <a href="index.php?do=them&r='.$a['t'].'&t='.$a['id'].'&p='.$a['rid'].'&page='.$pg.'"><b>»»</b></a>';
} else {
$st = '';
}
###############################
echo ($i ++ % 2) ? $div_tworazdel : $div_razdel;
echo '<a href="index.php?do=them&r='.$a['t'].'&t='.$a['id'].'&p='.$a['rid'].'">' .$a['name'] . '</a> (' . $a['c'] . ')' . $st . $div_end;
}
echo $n->navi();
} else {
echo 'Моих тем не найдено!<br/>';
}
break;
/*
* Активные темы
*/
case act:
echo $div_title . 'Активные' . $div_end . $div_menu . '
<img src="img/up.gif" alt="*"/> <a href="index.php?">Форум</a>
' . $block . '
<a href="index.php?do=search">Поиск</a> |
<b>Активные</b> |
<a href="index.php?do=newt">Новые</a> |
<a href="index.php?do=my">Мои темы</a>' . $div_end;
$_res = mysql_result(mysql_query("SELECT COUNT(id) FROM `f_them` WHERE `id` IN(SELECT tid FROM `f_message`)"), 0);
if ($_res != FALSE) {
$n = new navigator($_res, 10, '?do=act&');
$th = mysql_query("SELECT `f_them` .*,
(SELECT COUNT(id) FROM `f_message` WHERE `f_message`.`tid` = `f_them`.`id`) AS c,
(SELECT `pid` FROM `f_pod` WHERE `f_pod`.`id` = `f_them`.`rid`) AS t
FROM `f_them` ORDER BY last DESC {$n->limit}");
$i = 0;
while($a = mysql_fetch_assoc($th))
{
###############################
if ($a['c'] > 10) {
$pg = ceil($a['c'] / 10);
$st = ' <a href="index.php?do=them&r='.$a['t'].'&t='.$a['id'].'&p='.$a['rid'].'&page='.$pg.'"><b>»»</b></a>';
} else {
$st = '';
}
###############################
echo ($i ++ % 2) ? $div_tworazdel : $div_razdel;
echo '<a href="index.php?do=them&r='.$a['t'].'&t='.$a['id'].'&p='.$a['rid'].'">' .$a['name'] . '</a> (' . $a['c'] . ')' . $st . $div_end;
}
echo $n->navi();
} else {
echo 'Активных тем не найдено!<br/>';
}
break;
/*
* Кто онлайн
*/
case online:
echo $div_title . 'На форуме' . $div_end . $div_menu . '
<img src="img/up.gif" alt="*"/> <a href="index.php?">Форум</a>
' . $block . '
<a href="index.php?do=search">Поиск</a> |
<a href="index.php?do=act">Активные</a> |
<a href="index.php?do=newt">Новые</a> |
<a href="index.php?do=my">Мои темы</a>' . $div_end;
$_res = mysql_result(mysql_query("SELECT COUNT(id) FROM `users` WHERE `room` = 'forum' AND `onl` + '200' > '" . time() . "'"), 0);
if ($_res != FALSE) {
$n = new navigator($_res, 10, '?do=my&');
$th = mysql_query("SELECT * FROM `users` WHERE `room` = 'forum' AND `onl` + '200' > '" . time() . "' ORDER BY `id` DESC {$n->limit}");
$i = 0;
while($a = mysql_fetch_assoc($th)) {
echo ($i ++ % 2) ? $div_tworazdel : $div_razdel;
echo us($a['id']) . $div_end;
}
echo $n->navi();
} else {
echo 'Никого нету!<br/>';
}
break;
case save:
if (!isset($_SESSION['us']))
{
header('location: /reg.php?');
die();
}
$t = my_int($_REQUEST['t']);
$emptyT = mysql_query("SELECT `id`, `name`, `firstpost` FROM `f_them` WHERE `id` = '$t' AND `close` = '0' LIMIT 1");
if (mysql_num_rows($emptyT) == FALSE) {
err('Ошибка!');
include '../system/foot.php';
exit();
}
$delf = opendir('temp');
while ($tt = readdir($delf))
{
if ($tt != '.' and $tt != '..' and $tt != 'index.php')
{
$tm[] = $tt;
}
}
closedir($delf);
$totalt = sizeof($tm);
for ($it = 0; $it < $totalt; ++$it)
{
$filtime[$it] = filemtime('temp/' . $tm[$it]);
$tim = time();
$ftime1 = $tim - 100;
if ($filtime[$it] < $ftime1)
{
unlink('temp/' . $tm[$it]);
}
}
$tema = mysql_query("SELECT * FROM `f_message` WHERE tid = '$t' ORDER BY time ASC");
$ii = mysql_fetch_array($emptyT);
$i = 0;
while($query = mysql_fetch_assoc($tema))
{
$query['msg'] = preg_replace('/<div class="q">(.*)</div>/siu', '/Цитата: 1/ -> ', $query['msg']);
$code = strtr($query['msg'], array('$' => '$', ''' => "'", '\' => '\', '`' => '`', '%' => '%', '^' => '^'));
$code = preg_replace('/[color=#([a-z0-9]{6})](.*)[/color]/sui', '2', $code);
$code = str_replace('<span style="color: #FF0000;">[b][censored][/b]</span>', '[censored]', $code);
$code = preg_replace('/<img src="/smiles/(.*?)" alt="(.*?)"/>/si', '2', $code);
$code = notags(back_bb(nl2br($code)));
$string = $string;
}
file_put_contents('temp/' . time() . '.txt', '/' . notags($ii[1]) . "/n" . notags(str_replace('<br />', "n", $ii[2])) . "n---------------n" . $string . "n***************nСкачано с " . $site);
chmod('temp/' . time() . '.txt', 0666);
echo '<a href="temp/'.time().'.txt">Скачать (ссылка будет активной 5 минут)</a>';
break;
case who:
if (!isset($_SESSION['us']))
{
header('location: /reg.php?');
die();
}
$t = my_int($_REQUEST['t']);
$p = my_int($_REQUEST['p']);
$r = my_int($_REQUEST['r']);
$empty_1 = mysql_query("SELECT * FROM `f_them` WHERE `id` = '$t' AND `rid` = '$p' LIMIT 1");
$empty_2 = mysql_query("SELECT * FROM `f_pod` WHERE `id` = '$p' AND `pid` = '$r' LIMIT 1");
$empty_3 = mysql_query("SELECT * FROM `f_razdel` WHERE `id` = '$r' LIMIT 1");
if (mysql_num_rows($empty_1) == FALSE) {
err('Тема не найдена, возможна она была удалена.');
include '../system/foot.php';
exit();
}
if (mysql_num_rows($empty_2) == FALSE) {
err('Подфорума не существует!');
include '../system/foot.php';
exit();
}
if (mysql_num_rows($empty_3) == FALSE) {
err('Раздела не существует!');
include '../system/foot.php';
exit();
}
$num = mysql_result(mysql_query("SELECT COUNT(id) FROM inthem WHERE uid = '$t' AND time + '100' > '" . time() . "'"), 0);
if ($num != 0)
{
$n = new navigator($num, 10, '?do=who&r='.$r.'&p='.$p.'&t='.$t.'&');
$sel = mysql_query("SELECT * FROM inthem WHERE uid = '$t' AND time + '100' > '" . time() . "' ORDER BY time DESC {$n->limit}");
$cols = 0;
while($a = mysql_fetch_assoc($sel))
{
++$cols;
$nums = ($n->start + $cols);
echo $nums . '. ' . us($a['who']) . '<br/>';
}
echo $n->navi();
} else {
echo 'В теме нет никого.<br/>';
}
echo $block . '« <a href="index.php?do=them&r='.$r.'&p='.$p.'&t='.$t.'">Назад</a>';
break;
}
include '../system/foot.php';
?>