2018-05-18 01:20:27 +00:00
|
|
|
<?php
|
|
|
|
require_once __DIR__ . '/../../misuzu.php';
|
|
|
|
|
2018-05-23 01:41:57 +00:00
|
|
|
$forumId = max((int)($_GET['f'] ?? 0), 0);
|
2018-05-21 16:37:17 +00:00
|
|
|
$topicsOffset = max((int)($_GET['o'] ?? 0), 0);
|
|
|
|
$topicsRange = max(min((int)($_GET['r'] ?? 20), 50), 10);
|
2018-05-18 01:20:27 +00:00
|
|
|
|
|
|
|
if ($forumId === 0) {
|
|
|
|
header('Location: /forum/');
|
|
|
|
exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
$templating = $app->getTemplating();
|
2018-05-24 00:38:42 +00:00
|
|
|
$forum = forum_fetch($forumId);
|
2018-05-18 01:20:27 +00:00
|
|
|
|
2018-05-23 01:41:57 +00:00
|
|
|
if (empty($forum) || ($forum['forum_type'] == MSZ_FORUM_TYPE_LINK && empty($forum['forum_link']))) {
|
2018-05-26 20:33:05 +00:00
|
|
|
echo render_error(404);
|
2018-05-18 01:20:27 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2018-05-23 01:41:57 +00:00
|
|
|
if ($forum['forum_type'] == MSZ_FORUM_TYPE_LINK) {
|
|
|
|
forum_increment_clicks($forum['forum_id']);
|
2018-05-18 01:20:27 +00:00
|
|
|
header('Location: ' . $forum['forum_link']);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2018-05-24 00:38:42 +00:00
|
|
|
$topics = forum_may_have_topics($forum['forum_type'])
|
|
|
|
? forum_topic_listing($forum['forum_id'], $app->getUserId(), $topicsOffset, $topicsRange)
|
|
|
|
: [];
|
2018-05-18 01:20:27 +00:00
|
|
|
|
2018-05-24 00:38:42 +00:00
|
|
|
$forum['forum_subforums'] = forum_get_children($forum['forum_id'], $app->getUserId());
|
2018-05-18 01:20:27 +00:00
|
|
|
|
2018-05-24 00:38:42 +00:00
|
|
|
foreach ($forum['forum_subforums'] as $skey => $subforum) {
|
|
|
|
$forum['forum_subforums'][$skey]['forum_subforums']
|
|
|
|
= forum_get_children($subforum['forum_id'], $app->getUserId(), true);
|
2018-05-18 01:20:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
echo $app->getTemplating()->render('forum.forum', [
|
2018-05-23 01:41:57 +00:00
|
|
|
'forum_breadcrumbs' => forum_get_breadcrumbs($forum['forum_id']),
|
2018-05-18 01:20:27 +00:00
|
|
|
'forum_info' => $forum,
|
|
|
|
'forum_topics' => $topics,
|
2018-05-21 16:37:17 +00:00
|
|
|
'forum_offset' => $topicsOffset,
|
|
|
|
'forum_range' => $topicsRange,
|
2018-05-18 01:20:27 +00:00
|
|
|
]);
|