<?php
/// Общий форум
if ($subforum['lost_dostype'] > 0) {
if ($user['lost_privilege'] != 3 AND !in_array($user['lost_id'],$moderation)) {
$title = 'Доступ закрыт';
$error1 = 'Вы не можете смотреть этот раздел, так как руководство ограничило к нему доступ<br/><br/><a class="white" href="/forum">К списку разделов</a>';
require_once 'element_error_page.php';
exit;
}
}
require_once './element_function/element_function_forum.php';
$moders = (isset($_GET['moders'])) ? true : false;
$page = (isset($_GET['page']) AND is_numeric($_GET['page'])) ? (int)$_GET['page'] : 1;
$delete = (isset($_GET['delete']) AND is_numeric($_GET['delete'])) ? (int)$_GET['delete'] : false;
$ban = BanUserCountActive($user['lost_id']);
$read_topic = Read_Topic_User($user['lost_id'], $id);
if ($read_topic and !isset($_GET['page'])) {
$cnt_to_time = mysql_result(mysql_query("SELECT COUNT(lost_id) FROM `element_forum_comment_2` WHERE `lost_time` <= '$read_topic' AND `lost_topic` = '$id'"), 0);
if ($cnt_to_time > 0) {
$qq = substr($cnt_to_time, -1);
$cnt_to_time = (($cnt_to_time - 1) / 10) + 1;
$cnt_to_time = intval($cnt_to_time);
if ($qq == 0) $page = $cnt_to_time + 1; else $page = $cnt_to_time;
}
}
$url_1 = '/forum/topic?id='.$id.((isset($_GET['page'])) ? '&page='.$page : '').((isset($_GET['moders'])) ? '&moders' : '');
// Удаляем комментарий
if ($delete) {
if ($my_moder or $user['lost_privilege'] > 1) {
mysql_query("DELETE FROM `element_forum_comment_2` WHERE `lost_topic` = '$id' AND `lost_id` = '$delete' LIMIT 1");
header('Location: '.$url_1);
}
}
//echo $page;
// Обработка комментария. Создаем
if ($go == 'add') {
$text = (isset($_POST['text']) AND !empty($_POST['text'])) ? htmlspecialchars(addslashes(trim($_POST['text']))) : false;
if (!$text) $error = 'error';
if ($user['lost_level'] < element_settings_game('lost_forum_create_comment')) $error = 'error';
if ($topic['lost_close'] > 0) $error = 'error';
if ($ban > 0) $error = '';
if (!isset($error)) {
$time = time();
if ($user['lost_privilege'] > 0) $text = AddBB($text);
mysql_query("INSERT INTO `element_forum_comment_2` SET `lost_user` = '$user[lost_id]',
`lost_topic` = '$id',
`lost_text` = '$text',
`lost_time` = '$time'");
mysql_query("UPDATE `element_forum_topic_2` SET `lost_time_comment` = '$time' WHERE `lost_id` = '$id' LIMIT 1");
if (!$read_topic) Create_Read_Topic($user['lost_id'], $id, $time);
header('Location: /forum/topic?id='.$id);
exit;
}
}
$count_comment = Count_Topic_Comment($id);
// element_forum_read_2
$title = $topic['lost_name'];
require_once './element_include/element_head.php';
require_once './element_include/element_header_user_true.php';
echo '<div class="nfl p5 mb5 mt5 small mlra">';
echo '<div><img width="13" height="13" alt="" src="/images/icons/forum_new.png"/> <a href="/forum">Форум</a><span class="white"> / <a href="/forum/subforum?id='.$subforum['lost_id'].'">'.$subforum['lost_name'].'</a></span>';
if ($my_moder or $user['lost_privilege'] > 0) {
$url = '/forum/topic?id='.$id.((isset($_GET['page'])) ? '&page='.$page : '').'';
echo '<br/><img src="/images/icons/1.gif"> <a class="lngreen" href="'.$url.(($moders) ? '' : '&moders').'">Модерировать</a>';
if ($user['lost_privilege'] == 1 and !$my_moder and $moders) {
echo '<br/><img src="/images/icons/1.gif"> <a class="lngreen" href="'.$url.'&moders">Переместить</a>';
}
if ($user['lost_privilege'] == 1 and $my_moder and $moders or $user['lost_privilege'] > 1 and $moders or $user['lost_privilege'] == 0 and $my_moder and $moders) {
if ($go == 'close') Open_Close_Topic($topic['lost_close'], $id, $url.'&moders');
if ($go == 'pricr') Pricrepit_Topic($topic['lost_pric'], $id, $url.'&moders');
if ($go == 'delete') Delete_Topic($id, $subforum['lost_id']);
echo '<br/><img src="/images/icons/1.gif"> <a class="lngreen" href="'.$url.'&moders">Переместить топик</a>';
echo '<br/><img src="/images/icons/1.gif"> <a class="lngreen" href="'.$url.'&moders&go=pricr">'.(($topic['lost_pric'] == 0) ? 'Прикрепить топик' : 'Открепить топик').'</a>';
echo '<br/><img src="/images/icons/1.gif"> <a class="lngreen" href="'.$url.'&moders&go=close">'.(($topic['lost_close'] == 0) ? 'Закрыть топик' : 'Открыть топик').'</a>';
echo '<br/><img src="/images/icons/1.gif"> <a class="lngreen" href="'.$url.'&moders&go=delete">Удалить топик</a>';
echo '<br/><img src="/images/icons/1.gif"> <a class="lngreen" href="'.$url.'&moders">Изменить топик</a>';
}
}
echo '</div>';
if ($page <= 1) { // Шапка топика
$topic_user = cache_user($topic['lost_user']);
$on_off = (!empty($online[$topic_user['lost_id']])) ? 'online' : 'offline';
$text = nl2br(Color_Privilege($topic_user['lost_privilege'], $topic['lost_text']));
$text = Smiles($text, true);
echo '<div class="mt5">';
echo '<a class="yellow1 sndr bl" href="/user?id='.$topic_user['lost_id'].'">';
echo '<span class="fr pt2 ccc">'.rdate("d M H:i", $topic['lost_time']).'</span>';
echo ikonka_user($topic_user['lost_race'], $on_off).' <span class="yellow1">'.$topic_user['lost_login'].'</span>';
echo '</a>';
echo '<div class="mt3 mb3">'.$text.'</div>';
echo '<div class=""><a class="ccc" href="/forum/topic?id='.$id.'&reply='.$topic_user['lost_login'].'">[Ответить]</a>';
if ($my_moder and $moders or $user['lost_privilege'] >= 2 and $moders) echo ' <a class="red" href="/ban/list?id='.$topic['lost_user'].'&go=ban&topic='.$id.'">[Модерировать]</a>';
echo '</div>';
echo '</div>';
$tt_ime = $topic['lost_time'];
} else $tt_ime = time(); // Конец шапки топика
echo '<div class="hr mt5 mb5"></div><div class=" mb5 ccc cntr">Комментарии: '.$count_comment.'';
echo ($topic['lost_close'] > 0) ? '<br/><span class="red">Топик закрыт</span>' : '';
echo '</div>';
// Вывод комментариев
if ($count_comment > 0) {
require_once './element_function/element_function_pagination.php';
$pagination = pagination(10, $page, $count_comment);
$query_comment = mysql_query("SELECT * FROM `element_forum_comment_2` WHERE `lost_topic` = '$id' ORDER BY `lost_time` LIMIT $pagination[start], $pagination[num]");
while ($myrrow = mysql_fetch_array($query_comment)) {
$comment_user = cache_user($myrrow['lost_user']);
$on_off = (!empty($online[$comment_user['lost_id']])) ? 'online' : 'offline';
$text = nl2br(Color_Privilege($comment_user['lost_privilege'], $myrrow['lost_text']));
$text = Smiles($text, true);
echo '<div class="mt5">';
echo '<a class="yellow1 sndr bl" href="/user?id='.$comment_user['lost_id'].'">';
echo '<span class="fr pt2 '.(($read_topic < $myrrow['lost_time']) ? 'lngreen' : 'ccc').'">'.rdate("d M H:i", $myrrow['lost_time']).'</span>';
echo ikonka_user($comment_user['lost_race'], $on_off).' <span class="yellow1">'.$comment_user['lost_login'].'</span>';
echo '</a>';
echo '<div class="mt3">'.$text.'';
echo '<div class=""><a class="ccc" href="/forum/topic?id='.$id.'&reply='.$comment_user['lost_login'].'">[Ответить]</a>';
if ($my_moder and $moders or $user['lost_privilege'] >= 2 and $moders) echo ' <a class="red" href="'.$url_1.'&delete='.$myrrow['lost_id'].'">[Удалить]</a> <a class="red" href="/ban/list?id='.$comment_user['lost_id'].'&go=ban&comment='.$myrrow['lost_id'].'">[Модерировать]</a>';
echo '</div>';
echo '</div>';
echo '</div>';
$tt_ime = $myrrow['lost_time'];
}
echo '<div>'.pagination_echo($pagination['page'],$pagination['total'], '/forum/topic?id='.$id.'&page=').'</div>';
echo '<div class="hr mt5 mb5"></div>';
} else echo '<div class="hr mt5 mb5"></div>';
// Заканчиваем вывод комментариев
if ($read_topic) {
if ($read_topic < $tt_ime) Update_Read_Topic($user['lost_id'], $id, $tt_ime);
} else Create_Read_Topic($user['lost_id'], $id, $tt_ime);
// Форма отправки комментария
if ($topic['lost_close'] > 0) {
echo '<div class="cntr red">Вы не можете комментировать эту тему, потому что она закрыта</div>';
} else {
if ($ban == 0) {
if ($user['lost_level'] < element_settings_game('lost_forum_create_comment')) {
echo '<div class="cntr red">Комметрировать темы можно начиная с '.element_settings_game('lost_forum_create_comment').' уровня</div>';
} else {
$reply = (isset($_GET['reply']) AND !empty($_GET['reply'])) ? $_GET['reply'].', ' : '';
echo '<div class="cntr">
<form method="post" action="/forum/topic?id='.$id.'&go=add">
<span class="small ccc">Сообщение</span><br/>
<textarea class="w96 mb5 fdark" rows="3" name="text">'.$reply.'</textarea><br/>
<span class="button w50 mt3"><input type="submit" class="ttl" name="submit" value="Отправить"/></span>
</form>
</div>';
}
} else echo '<div class="cntr small mb5"><a class="error1" href="/ban/list?id='.$user['lost_id'].'">Вы не можете комментировать эту темы, потому что находитесь в бане</a></div>';
}
// lost_forum_create_comment
echo '</div>';
?>