Файл: modules/forum/include.php
Строк: 30
<?php
/* Мод "Форум"
* Версия v0.0.1
* Дата последнего редактирования 27.11.2014
* Двиг DCMS Special
* Модифицировал densnet
* Автор yadalay
* Файл include.php
* Описание: выводит последние темы форума
*/
$limit = 3; // Количество выводимых тем.
$k_post = mysql_result(mysql_query('SELECT COUNT(*) FROM `forum_themes`'), 0);
$k_page = k_page($k_post, $set['p_str']);
$page = page($k_page);
$start = $set['p_str'] * $page - $set['p_str'];
if ($k_post != 0) {
//echo "<div class = 'razdel'>Последние темы</div>";
$themes = mysql_query('SELECT * FROM `forum_themes` ORDER BY `time_post` DESC LIMIT ' . $limit);
while ($theme = mysql_fetch_object($themes)) {
$razdel = mysql_fetch_object(mysql_query('SELECT `id`, `id_forum` FROM `forum_razdels` WHERE `id` = ' . $theme->id_razdel));
$forum = mysql_fetch_object(mysql_query('SELECT `id` FROM `forum` WHERE `id` = ' . $razdel->id_forum));
$creater = mysql_fetch_object(mysql_query('SELECT `id`, `nick` FROM `user` WHERE `id` = ' . $theme->id_user));
$count_posts = mysql_result(mysql_query('SELECT COUNT(*) FROM `forum_posts` WHERE `id_theme` = ' . $theme->id), 0);
$hide = (user::access('forum_post_ed')) ? NULL : '`hide` = "0" AND';
$last_post = mysql_fetch_object(mysql_query('SELECT `id`, `hide`, `id_user`, `time` FROM `forum_posts` WHERE ' . $hide . ' `id_theme` = ' . $theme->id . ' ORDER BY `id` DESC'));
$who = ($last_post && $last_post->id_user != 0) ? mysql_fetch_object(mysql_query('SELECT `id`, `nick` FROM `user` WHERE `id` = ' . $last_post->id_user)) : array();
$who_id = ($last_post && $last_post->id_user != 0) ? $who->id : 0;
$who_nick = ($last_post && $last_post->id_user != 0) ? $who->nick : 'Система';
if ($theme->reason_close != NULL) {
$type = '_close';
} elseif ($theme->type == 1) {
$type = '_up';
} else {
$type = NULL;
}
echo "<table class = 'razd'><tr><td class = 'null'>";
echo "<span style = 'float:right;'>";
echo "<a class = 'count'>" . img('comment_white.png') . " $count_posts</a>";
echo "</span>";
echo "<img src = '/style/img/theme$type.png' />";
echo "<a href = '/modules/forum/$forum->id/$razdel->id/$theme->id.html'>" . text::toOutput($theme->name, 1, 1, 0, 0, 0) . "</a> (" . date::time($theme->time) . ")<br />";
if ($last_post) {
echo "<b>Автор: <a href = '/info.php?id=$theme->id_user'>$creater->nick</a> | Посл.:</b> <a href = '/info.php?id=$who_id'>$who_nick</a> ";
} else {
$continue = (mb_strlen($theme->description) > 150) ? '...' : NULL;
echo text::toOutput(mb_substr($theme->description, 0, 150), 1, 1, 0, 1, 1) . $continue;
}
echo "</td></tr></table>";
}
}