Просмотр файла modules/forum/forum.php

Размер файла: 4.01Kb
<?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_f_id']) || mysql_result(mysql_query("SELECT COUNT(*) FROM `forum_f` WHERE `id` = '". num($_GET['forum_f_id']) ."' LIMIT 1"), 0) == 0)
{
    # Перенаправляем на главную
    header('Location: /');
}

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

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

error($err);

# Массив раздела
$forum_f = mysql_fetch_assoc(mysql_query("SELECT * FROM `forum_f` WHERE `id` = '". num($_GET['forum_f_id']) ."' LIMIT 1"));

echo '<div class="title">'. $forum_f['name'] .'</div>';

# Кол-во тем
$k_forum_t = mysql_result(mysql_query("SELECT COUNT(*) FROM `forum_t` WHERE `f_id` = '". num($_GET['forum_f_id']) ."'"), 0);

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

if ($k_forum_t == 0)
{
    echo '<div class="menu">Тем нет.</div>';
}
else
{
    $sql_forum_t = mysql_query("SELECT * FROM `forum_t` WHERE `f_id` = '". num($_GET['forum_f_id']) ."' ORDER BY attach DESC, time_last_post DESC LIMIT $start, 10");

    while ($forum_t = mysql_fetch_assoc($sql_forum_t))
    {
        $c = mysql_result(mysql_query("SELECT COUNT(*) FROM `forum_p` WHERE `t_id` = '". $forum_t['id'] ."'"), 0) - 1;

        $new_posts = mysql_result(mysql_query("SELECT COUNT(*) FROM `forum_p` WHERE `t_id` = '$forum_t[id]' AND `time` > '". (time()-3600*12) ."'". (isset($user)?" AND `user_id` != '". $user['id'] ."'":NULL) .""),0);

        if (isset($user) && $settings['new_posts'] == 2) $new_posts = 0;

        echo '<div class="menu">';

        if ($forum_t['attach']) echo (isset($user) && $settings['img_site'] == 2?'[!]':'<img src="/design/icons/forum_tz.png" alt="!" /> ');
        else if ($forum_t['closed'] == 1) echo (isset($user) && $settings['img_site'] == 2?'[#]':'<img src="/design/icons/forum_tc.png" alt="#" /> ');
        else echo (isset($user) && $settings['img_site'] == 2?'[t]':'<img src="/design/icons/forum_t.png" alt="t" /> ');

        $author_id = mysql_result(mysql_query("SELECT `user_id` FROM `forum_p` WHERE `t_id` = '$forum_t[id]' ORDER BY theme_id DESC LIMIT 1"), 0);

        echo '<a href="/forum/topic.php?forum_t_id='. $forum_t['id'] .'">'. mysql_result(mysql_query("SELECT `theme` FROM `forum_p` WHERE `t_id` = '". $forum_t['id'] ."' AND `theme_id` = '1'"), 0) .'</a> ('. $c .')'. ($new_posts > 0?' <span class="green">+'. $new_posts .'</span>':NULL) .' '. mysql_result(mysql_query("SELECT `nick` FROM `users` WHERE `id` = '$author_id'"), 0) .' <a href="/forum/topic.php?forum_t_id='. $forum_t['id'] .'&page=end">&raquo;</a>
        </div>';
    }

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

$r_id = mysql_result(mysql_query("SELECT `r_id` FROM `forum_f` WHERE `id` = '". num($_GET['forum_f_id']) ."'"),0);

echo (isset($user)?'<div class="block">&raquo; <a href="/forum/posting.php?forum_f_id='. num($_GET['forum_f_id']) .'&amp;create_t">Создать тему</a></div>':NULL) .'
<div class="block">
&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');

?>