Файл: element_forum/element_topic_town.php
Строк: 203
<?php
// Городской форум
$my_town_id = ($subforum['lost_town'] == $user['lost_town']) ? true : false; // Проверяем, мой город или нет
$cache_town = cache_town($subforum['lost_town']); // Кэш города
$moders = (isset($_GET['moders'])) ? true : false;
$ban = BanUserCountActive($user['lost_id']);
if ($my_town_id) {
// Если мое звание меньше нужного, не впускаем
if ($town_other[0] > $subforum['lost_town_ready'] AND $user['lost_privilege'] != 3) {
$title = 'Доступ закрыт';
$error1 = 'Вы не можете читать этот топик. Руководство города ограничило к нему доступ<br/><br/><a class="button w50 white" href="/forum?go=town&id='.$id.'">К списку разделов</a>';
require_once 'element_error_page.php';
exit;
}
} else {
// Если раздел настроен для чтение выше гостей, не впускаем
if ($subforum['lost_town_ready'] != 8 AND $user['lost_privilege'] != 3) {
$title = 'Доступ закрыт';
$error1 = 'Вы не можете читать этот топик. Руководство города ограничило к нему доступ<br/><br/><a class="button w50 white" href="/forum?go=town&id='.$id.'">К списку разделов</a>';
require_once 'element_error_page.php';
exit;
}
}
require_once './element_function/element_function_forum.php';
$page = (isset($_GET['page']) AND is_numeric($_GET['page'])) ? (int)$_GET['page'] : 1;
$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;
}
}
// Обработка комментария. Создаем
if ($go == 'add') {
$text = (isset($_POST['text']) AND !empty($_POST['text'])) ? htmlspecialchars(addslashes(trim($_POST['text']))) : false;
if (!$text) $error = 'error';
if ($my_town_id AND $town_other[0] > $subforum['lost_town_comment'] AND $user['lost_privilege'] != 3 OR !$my_town_id AND $subforum['lost_town_comment'] != 8 AND $user['lost_privilege'] != 3) $error = 'error';
if ($topic['lost_close'] > 0) $error = 'error';
if ($ban > 0 AND !$my_town_id) $error = '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);
$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?id='.$subforum['lost_town'].'">Форум "'.$cache_town['lost_name'].'"</a><span class="white"> / <a href="/forum/subforum?id='.$subforum['lost_id'].'">'.$subforum['lost_name'].'</a></span>';
if ($my_town_id AND $town_other[0] <= $subforum['lost_town_topic'] OR $user['lost_privilege'] == 3) {
$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 ($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';
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">'.nl2br(Color_Privilege($topic_user['lost_privilege'], $topic['lost_text'])).'</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';
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">'.nl2br(Color_Privilege($comment_user['lost_privilege'], $myrrow['lost_text'])).'';
echo '<div class=""><a class="ccc" href="">[Ответить]</a>';
//if ($my_moder and $moders or $user['lost_privilege'] >= 2 and $moders) echo ' <a class="red" href="">[Удалить]</a> <a class="red" href="">[Модерировать]</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);
$reply = (isset($_GET['reply']) AND !empty($_GET['reply'])) ? $_GET['reply'].', ' : '';
// Форма отправки комментария
if ($topic['lost_close'] > 0) {
echo '<div class="cntr red">Вы не можете комментировать эту тему, потому что она закрыта</div>';
} else if ($ban > 0 AND !$my_town_id) {
echo '<div class="cntr small mb5"><a class="error1" href="/ban/list?id='.$user['lost_id'].'">Вы не можете комментировать эту темы, потому что находитесь в бане</a></div>';
} else if ($my_town_id AND $town_other[0] <= $subforum['lost_town_comment']
OR !$my_town_id AND $subforum['lost_town_comment'] == 8 OR $user['lost_privilege'] == 3) {
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 ccc">Вы не можете комментировать этот топик</div>';
echo '</div>';
?>