Файл: 4mast/profmas.ru/data/forum/forum.thema.php
Строк: 79
<?php
require_once('../../includes/Headers.php');
require_once('../../includes/PDO_func.php');
if($us['id'] == false){
header('location: /login/auth');
exit;
}
$thema = DB::$dbs->queryFetch("SELECT `id`,`name`,`type`,`id_pr`,`id_r`,`us` FROM `forum_t` where `id` = ? limit 1",array($id));
if($thema['name'] == null)
{
header('location:/forum/index');}
if($thema['type']==2 AND $us['level']<=2)
{
H (' Ошибка! ', ' <a href="/forum/index" style="color:white;"> Форум </a> ');
echo'<div class="error">Эта тема была удалена!</div>';
require_once('../../includes/Footers.php');
exit;
}
$podrazd = DB::$dbs->queryFetch("SELECT `id`,`name` FROM `forum_pr` where `id` = ? limit 1",array(abs(intval($thema['id_pr']))));
$razd = DB::$dbs->queryFetch("SELECT id FROM `forum_r` where `id` = ? limit 1",array(abs(intval($thema['id_r']))));
if($us == true) {
if(DB::$dbs->querySingle("SELECT count(id) from `forum_visit` where `id_t` = ? and `us` = ?",array($thema['id'],$us['id'])) == 0)
{
DB::$dbs->query("INSERT INTO `forum_visit` (`id_t`,`us`,`time`) VALUES (?,?,?)",array($thema['id'],$us['id'],time()));
}
else
{
DB::$dbs->query("UPDATE `forum_visit` set `time` = ? where `id_t` = ? and `us` = ? limit 1",array(time(),$thema['id'],$us['id']));
}
}
$at = DB::$dbs->query("SELECT `id`,`level` FROM `us` where `id` = ? order by `id` limit 1",array($thema['us']))->fetch();
H ($thema['name'], ' <a href="/forums/' . $razd['id'] . '/' . $podrazd['id'] . '" style="color:white;">' . $podrazd['name'] . '</a> | ' .$thema['name']);
if($thema['type'] == 2)
{
echo'<div class="error"><b>Тема удалена!</b></div>';
}
elseif($thema['type'] == 0)
{
echo'<div class="error"> <b>Тема закрыта!</b></div>';
}
$num = 10;
$posts = DB::$dbs->querySingle("SELECT count(id) from `forum_p` where `id_t` = ?",array($thema['id']));
$pages = intval(($posts - 1) / $num) + 1;
if(empty($page) or $page < 0) $page = 1;
if($page > $pages) $page = $pages;
$start = $page * $num - $num;
if ($page == 1)
@$i = $page;
else if ($page == 2) @$i = $page + 9;
else @$i = ($page * 10) - 9;
/* Открыть/Закрыть тему */
if ($us['level']>0) {
echo '<div class="block">';
if ($thema['type'] == 1) {
if ($us['level']>0) {
if (isset ($_GET['close'])) {
DB :: $dbs -> query ("UPDATE `forum_t` SET `type`='0', `time`='" . time () . "',`last`='" . $us['id'] . "' WHERE (`id`='" . $t['id'] . "')");
DB :: $dbs -> query ("INSERT INTO `forum_p` (`id_r`,`id_pr`,`id_t`,`us`,`text`,`time`) VALUES ('" . $r['id'] . "','" . $pr['id'] . "','" . $t['id'] . "','" . $us['id'] . "','[b]Тема закрыта для обсуждения![/b] :-)','" . time () . "')");
header ('location: /forums/thema' . $thema['id'] . '/page' . $page);
exit;
}
echo '<a href="/forums/thema' . $thema['id'] . '=close">[Закрываем]</a> | ';
}
}
else {
if ($us['level']>0) {
if (isset($_GET['open'])) {
DB :: $dbs -> query ("UPDATE `forum_t` SET `type`='1', `time`='" . time () . "',`last`='" . $us['id'] . "' WHERE (`id`='" . $t['id'] . "')");
DB :: $dbs -> query ("INSERT INTO `forum_p` (`id_r`,`id_pr`,`id_t`,`us`,`text`,`time`) VALUES ('" . $r['id'] . "','" . $pr['id'] . "','" . $t['id'] . "','" . $us['id'] . "','[b]Тема открыта для обсуждения![/b] :-)','" . time () . "')");
header ('location: /forums/thema' . $thema['id'] . '/page' . $page);
exit;
}
echo '<a href="/forums/thema' . $thema['id'] . '=open">[Открываем]</a> | ';
}
}
/* Открепить/Закрепить тему */
if (isset ($_GET['top'])) {
DB :: $dbs -> query ("UPDATE `forum_t` SET `top`='" . ($thema['top']==0?1:0) . "' WHERE (`id`='" . $thema['id'] . "')");
header ('location: /forums/thema' . $thema['id'] . '/page' . $page);
exit;
}
echo '<a href="/forums/thema' . $thema['id'] . '=top">' . ($thema['top']==0?'[Закрепить]' : '[Открепить]') . '</a> | ';
echo ' <a href="/forums/index.php?mod=thm&id=' . $thema['id'] . '">[Переместить]</a> | <a href="/forums/index.php?mod=thn&id=' . $thema['id'].'">[Переименовать]</a>';
echo '</div>';
}
//////////////////////////////////////////////
if(DB::$dbs->querySingle("SELECT count(id) from `forum_p` where `id_t` = ?",array($thema['id']))==0)
{
echo '<div class="error">Сообщений пока что нет...</div>';
}
else
{
$post = DB::$dbs->query("SELECT * FROM `forum_p` where `id_t` = ? order by `id` limit $start,$num",array($thema['id']));
while($p = $post -> fetch()){
$pauthor = DB::$dbs->query("SELECT `id`,`level` FROM `us` where `id` = ? order by `id` limit 1",array($p['us']))->fetch();
echo '<div class="block" href="/us'.$p['us'].'"/>'.$i++.') ' .Nick($p['us'],1) .' <div class="flr">'.($p['us']==$thema['us']?'<font color="green">['.datef($p['time']).']</font>':'['.datef($p['time']).']').'</div></div></a>
<div class="lst">'.us_level($p['us'], '<br/>');
if($p['status'] == 1) {
echo '<del>Сообщение было удалено модератором!</del><br/>';
if ($pauthor['id'] == $us['id'] && $us['level']>3 || $pauthor['level']<$us['level']) echo '[<a href="/forums/thema' . $thema['id'] . '/post' . $p['id'] . '?do=status&page=' . $page . '"/> вос </a>] ';
}
else
{
if ($p['cit'] != 0) {
$cit = DB::$dbs->query("SELECT id,text,status,us FROM `forum_p` where `id` = ? order by `id` limit 1",array($p['cit']))->fetch();
if ($cit['status'] ==0 )
{
$cus = DB::$dbs->query("SELECT `id`,`nick` FROM `us` where `id` = ? order by `id` limit 1",array($cit['us']))->fetch();
echo 'Цитата:<div class="cit">';
echo '<b style="color:green;">'.$cus['nick'].'</b>: ';
echo ' <span style="word-wrap:break-word;">' . tag($cit['text']) . '</span></div>';
}
}
echo '<span style="word-wrap:break-word;">'.tag($p['text']).'</span><br>';
$files = DB::$dbs->querySingle("SELECT count(id) from `forum_f` where `id_p` = ?",array($p['id']));
if($files!=0)
{
$pfiles = DB::$dbs->query("SELECT * FROM `forum_f` where `id_p` = ? order by `id`",array($p['id']));
while($pfs = $pfiles -> fetch()){
$r = substr ($pfs['name'], strrpos ($pfs['name'], '.') + 1);
echo '<b><a href="/files/forum/'.$pfs['name'].'">' . $pfs['name'] . '</a> (' . sizef(filesize(FILES.'/forum/'.$pfs['name'].'')) . ') </b><br>';
}
}
$edit_post_user = DB::$dbs->queryFetch("SELECT * from `forum_reds` where `id_p` = ? order by `id` desc limit 1",array($p['id']));
if(!empty($edit_post_user['us'])){
echo '<small>Изменил '.DB::$dbs->querySingle("SELECT count(id) from `forum_reds` where `id_p` = ?",array($p['id'])).' раз</a>. '.Nick($edit_post_user['us']).' ('.datef($edit_post_user['time']).')</small><br/>';
}
if($thema['type'] == 1 && $us == true) {
if($p['us'] == $us['id'] OR $us['level'] > $pauthor['level']) echo '[<a href="/forums/thema' . $thema['id'] . '/post' . $p['id'] . '?do=edit&page=' . $page . '"/>ред</a>] ';
if($p['us'] != $us['id']) echo '[<a href="/forums/thema' . $thema['id'] . '/otv' . $p['us'] . '"/>отв</a>] ';
if($p['us'] != $us['id']) echo '[<a href="/forums/thema' . $thema['id'] . '/cit' . $p['id'] . '"/>цит</a>] ';
if ($pauthor['id'] == $us['id'] && $us['level']>3 || $pauthor['level']<$us['level']) echo '[<a href="/forums/thema' . $thema['id'] . '/post' . $p['id'] . '?do=status&page=' . $page . '"/>уд</a>] ';
}
}
echo '</div></div>';
}
}
If($thema['type'] == '1' && $us == true)
{
$post = (isset($_GET['save']) AND !empty($_GET['save'])) ? addslashes(htmlspecialchars($_GET['save'])) : false;
echo '<div class="lst"><form action="/forums/thema'.$thema['id'].'/msg?do=post" method="post"enctype="multipart/form-data">
Сообщение: <br><textarea rows="3" name="message">
</textarea>
<br>
Файл:<br><input type="file" name="filename"/><br>
<input type="submit" value="Написать" name="post" />
[<a href="/smiles">Смайлы</a> | <a href="/bbcode">BB</a>] </form></div>';
}
if($posts > 10) page('/forums/thema'.$thema['id']);
echo '<div class="menu2">В теме: <b><a href="/forums/who' . $thema['id'] . '"> ' . DB :: $dbs -> querySingle ("SELECT count(id) from `forum_visit` where `id_t` = ? and `time` > ?", array ($thema['id'],time()-120)).'</a></b> | Заходило: <b><a href="/forums/visit' . $thema['id'] . '">' . DB :: $dbs -> querySingle ("SELECT count(id) from `forum_visit` where `id_t` = ?", array($thema['id'])) . '</a></b> |
<b><a href="/forums/search.php">Поиск</a></b></div>';
require_once('../../includes/Footers.php');
?>