View file modules/forum/topic.php

File size: 7.2Kb
<?php

// Уведомление о закрытии форума
if ($system['forum_module'] == '2' && !user_access('view_closed_modules')) {
  # Шапка модуля
  require_once(HOME .'/incfiles/header.php');
  
  echo '<div class="title">Технические работы</div>
  <div class="menu">
  '. output($system['forum_module_about']) .'
  </div>';
  
  echo '<div class="block">
  &raquo; <a href="/">На главную</a>
  </div>';
  
  # Ноги модуля
  require_once(HOME .'/incfiles/footer.php');
}

// проверяем корректность запроса
if (!isset($_GET['forum_t_id']) || mysql_result(mysql_query("SELECT COUNT(*) FROM `forum_t` WHERE `id` = '". num($_GET['forum_t_id']) ."'"), 0) == 0)
{
    # Перенаправляем на главную
    header('Location: /');
}

# Заголовок модуля
$system['page_title'] = 'Просмотр темы';

# Шапка модуля
require_once(HOME .'/incfiles/header.php');

error($err);

echo '<div class="title">'. mysql_result(mysql_query("SELECT `theme` FROM `forum_p` WHERE `t_id` = '". num($_GET['forum_t_id']) ."' AND `theme_id` = '1'"), 0) . (($user['id'] == mysql_result(mysql_query("SELECT `user_id` FROM `forum_p` WHERE `t_id` = '". num($_GET['forum_t_id']) ."' AND `theme_id` = '1' AND `theme` != ''"), 0) || $user['level'] == 11 || $user['level'] >= 13) && mysql_result(mysql_query("SELECT `closed` FROM `forum_t` WHERE `id` = '". num($_GET['forum_t_id']) ."'"), 0) == 0?' [<a href="/forum/posting.php?forum_f_id='. mysql_result(mysql_query("SELECT `f_id` FROM `forum_t` WHERE `id` = '". num($_GET['forum_t_id']) ."'"), 0) .'&amp;closed&amp;theme_id='. num($_GET['forum_t_id']) .'">закрыть</a>]':NULL) . (($user['level'] == 11 || $user['level'] >= 13) && mysql_result(mysql_query("SELECT `closed` FROM `forum_t` WHERE `id` = '". num($_GET['forum_t_id']) ."'"), 0) == 1?' [<a href="/forum/posting.php?forum_f_id='. mysql_result(mysql_query("SELECT `f_id` FROM `forum_t` WHERE `id` = '". num($_GET['forum_t_id']) ."'"), 0) .'&amp;open&amp;theme_id='. num($_GET['forum_t_id']) .'">открыть</a>]':NULL) .'</div>';

# Кол-во пользователей
$k_forum_p = mysql_result(mysql_query("SELECT COUNT(*) FROM `forum_p` WHERE `t_id` = '". num($_GET['forum_t_id']) ."'"), 0);

# Старт навигации
nav_start($k_forum_p, 10);

if ($k_forum_p == 0)
{
    echo '<div class="menu">Сообщений нет</div>';
}
else
{
    $sql_forum_p = mysql_query("SELECT * FROM `forum_p` WHERE `t_id` = '". num($_GET['forum_t_id']) ."' ORDER BY time LIMIT $start, 10");

    while ($forum_p = mysql_fetch_assoc($sql_forum_p))
    {
        echo '<div class="menu">
        '. $forum_p['theme_id'] .'. '. icon($forum_p['user_id']) .' <a href="/user/user.php?user_id='. $forum_p['user_id'] .'">'. nick($forum_p['user_id']) .'</a> '. online($forum_p['user_id']) .' ('. vtime($forum_p['time']) .')'. (isset($user)?' '. ($user['id'] == $forum_p['user_id'] || $user['level'] == 11 || $user['level'] >= 13?'<a href="/forum/posting.php?forum_t_id='. num($_GET['forum_t_id']) .'&amp;edit&amp;edit_post_id='. $forum_p['id'] .'">изм</a>':NULL) . (($user['id'] == $forum_p['user_id'] || $user['level'] == 11 || $user['level'] >= 13) && ($user['id'] != $forum_p['user_id'] || !preg_match('/Цитата: "/i', output($forum_p['text'])))?'|':NULL) . ($user['id'] != $forum_p['user_id']?'<a href="/forum/posting.php?forum_t_id='. num($_GET['forum_t_id']) .'&amp;reply&amp;reply_nick='. mysql_result(mysql_query("SELECT `nick` FROM `users` WHERE `id` = '$forum_p[user_id]'"), 0) .'">отв</a>':NULL) . ($user['id'] != $forum_p['user_id'] && !preg_match('/Цитата: "/i', output($forum_p['text']))?'|':NULL) . (!preg_match('/Цитата: "/i', output($forum_p['text']))?'<a href="/forum/posting.php?forum_t_id='. num($_GET['forum_t_id']) .'&amp;reply&amp;q_id_mess='. $forum_p['id'] .'">цит</a>':NULL):NULL) .'<br />
        '. output($forum_p['text']) .'
        '. ($forum_p['count_edit'] > 0?'<span class="small_info"><br />_______<br />Посл. изм. '. date('d.m.Y в H:i', $forum_p['edit_time']) .', изм. '. mysql_result(mysql_query("SELECT `nick` FROM `users` WHERE `id` = '$forum_p[edit_user_id]'"), 0) .', всего '. $forum_p['count_edit'] .' раз(а)</span>':NULL) .'
        </div>';
    }

    # Вывод навигации
    view_nav('?forum_t_id='. num($_GET['forum_t_id']) .'&amp;');
}

$f_id = mysql_result(mysql_query("SELECT `f_id` FROM `forum_t` WHERE `id` = '". num($_GET['forum_t_id']) ."'"), 0);

$r_id = mysql_result(mysql_query("SELECT `r_id` FROM `forum_f` WHERE `id` = '". $f_id ."'"),0);

// быстрый ответ
if (isset($user) && $settings['fast_form'] == 1) {
	echo '<form method="post" action="/forum/posting.php?forum_t_id='. num($_GET['forum_t_id']) .'&amp;reply">
	<div class="block">
	Быстрый ответ:<br />
	<textarea name="text" rows="4" cols="20"></textarea><br />
	<input type="submit" value="Ответить" />
	</div>
	</form>';
}

echo '<div class="block">
'. (isset($user) && (mysql_result(mysql_query("SELECT `closed` FROM `forum_t` WHERE `id` = '". num($_GET['forum_t_id']) ."'"), 0) == 0 || $user['level'] == 11 || $user['level'] >= 13)?'&raquo; <a href="/forum/posting.php?forum_t_id='. num($_GET['forum_t_id']) .'&amp;reply">Ответить</a><br />':NULL) . (isset($user) && mysql_result(mysql_query("SELECT `closed` FROM `forum_t` WHERE `id` = '". num($_GET['forum_t_id']) ."'"), 0) != 0 && $user['level'] != 11 && $user['level'] < 13?'&raquo; [Тема закрыта, вы не можете писать в ней сообщения]<br />':NULL) .'
'. ($user['level'] == 11 || $user['level'] >= 13 && mysql_result(mysql_query("SELECT `attach` FROM `forum_t` WHERE `id` = '". num($_GET['forum_t_id']) ."'"), 0) == 0?'&raquo; <a href="/forum/posting.php?forum_t_id='. num($_GET['forum_t_id']) .'&amp;attach_yes">Закрепить тему</a><br />&raquo; <a href="/forum/posting.php?forum_t_id='. num($_GET['forum_t_id']) .'&amp;change_f">Переместить</a><br />':NULL) . ($user['level'] == 11 || $user['level'] >= 13 && mysql_result(mysql_query("SELECT `attach` FROM `forum_t` WHERE `id` = '". num($_GET['forum_t_id']) ."'"), 0) != 0?'&raquo; <a href="/forum/posting.php?forum_t_id='. num($_GET['forum_t_id']) .'&amp;attach_no">Открепить тему</a><br />':NULL) . (!isset($user)?'<a href="/user/registration.php">Зарегистрируйтесь</a> или <a href="/user/entry.php">авторизируйтесь</a> на сайте, чтобы писать сообщения.':NULL) .'</div>
<div class="block">
&raquo; <a href="/forum/forum.php?forum_f_id='. $f_id .'">'. mysql_result(mysql_query("SELECT `name` FROM `forum_f` WHERE `id` = '". mysql_result(mysql_query("SELECT `f_id` FROM `forum_t` WHERE `id` = '". num($_GET['forum_t_id']) ."'"), 0) ."'"), 0) .'</a><br />
&raquo; <a href="/forum/forum_r.php?forum_r_id='. $r_id .'">'. mysql_result(mysql_query("SELECT `name` FROM `forum_r` WHERE `id` = '". $r_id ."'"),0) .'</a><br />
&raquo; <a href="/forum/">К списку разделов</a><br />
&raquo; <a href="/">На главную</a>
</div>';

# Ноги модуля
require_once(HOME .'/incfiles/footer.php');

?>