$totalpages) {
$startpage = ($totalpages-$maxpages) < 1 ? 1 : $totalpages-$maxpages;
$endpage = $totalpages;
}
$output = ''._PAGE;
if (($startpage) > 1)
{
if ($endpage < $totalpages) $endpage--;
$output .= CKunenaLink::GetCategoryPageLink('showcat', $catid, 1, 1, $rel='follow');
if (($startpage) > 2)
{
$output .= "...";
}
}
for ($i = $startpage; $i <= $endpage && $i <= $totalpages; $i++)
{
if ($page == $i) {
$output .= "$i";
}
else {
$output .= CKunenaLink::GetCategoryPageLink('showcat', $catid, $i, $i, $rel='follow');
}
}
if ($endpage < $totalpages)
{
if ($endpage < $totalpages-1)
{
$output .= "...";
}
$output .= CKunenaLink::GetCategoryPageLink('showcat', $catid, $totalpages, $totalpages, $rel='follow');
}
$output .= '';
return $output;
}
require_once(KUNENA_PATH_LIB .DS. 'kunena.authentication.php');
//Security basics begin
//Securing passed form elements:
$catid = (int)$catid;
//resetting some things:
$moderatedForum = 0;
$forumLocked = 0;
$topicLocked = 0;
$topicSticky = 0;
unset($allow_forum);
//get the allowed forums and turn it into an array
$allow_forum = ($fbSession->allowed <> '')?explode(',', $fbSession->allowed):array();
if (in_array($catid, $allow_forum))
{
$threads_per_page = $fbConfig->threads_per_page;
if ($catid <= 0) {
//make sure we got a valid category id
$catid = 1;
}
$view = $view == "" ? $settings[current_view] : $view;
setcookie("fboard_settings[current_view]", $view, time() + 31536000, '/');
/*//////////////// Start selecting messages, prepare them for threading, etc... /////////////////*/
$page = (int)$page;
$page = $page < 1 ? 1 : $page;
$offset = ($page - 1) * $threads_per_page;
$row_count = $page * $threads_per_page;
$kunena_db->setQuery("SELECT COUNT(*) FROM #__fb_messages WHERE parent='0' AND catid='{$catid}' AND hold='0'");
$total = (int)$kunena_db->loadResult();
check_dberror('Unable to get message count.');
$totalpages = ceil($total / $threads_per_page);
$query = "SELECT t.id, MAX(m.id) AS lastid FROM #__fb_messages AS t
INNER JOIN #__fb_messages AS m ON t.id = m.thread
WHERE t.parent='0' AND t.hold='0' AND t.catid='{$catid}' AND m.hold='0' AND m.catid='{$catid}'
GROUP BY m.thread ORDER BY t.ordering DESC, lastid DESC";
$kunena_db->setQuery($query, $offset, $threads_per_page);
$threadids = $kunena_db->loadResultArray();
check_dberror("Unable to load thread list.");
$idstr = @join(",", $threadids);
$favthread = array();
$thread_counts = array();
$messages = array();
$messages[0] = array();
if (count($threadids) > 0)
{
$query = "SELECT a.*, j.id AS userid, t.message AS messagetext, l.myfavorite, l.favcount, l.attachmesid, l.msgcount, l.lastid, u.avatar, c.id AS catid, c.name AS catname
FROM (
SELECT m.thread, (f.userid='{$kunena_my->id}') AS myfavorite, COUNT(DISTINCT f.userid) AS favcount, COUNT(a.mesid) AS attachmesid,
COUNT(DISTINCT m.id) AS msgcount, MAX(m.id) AS lastid, MAX(m.time) AS lasttime
FROM #__fb_messages AS m
LEFT JOIN #__fb_favorites AS f ON f.thread = m.thread
LEFT JOIN #__fb_attachments AS a ON a.mesid = m.thread
WHERE m.hold='0' AND m.thread IN ({$idstr})
GROUP BY thread
) AS l
INNER JOIN #__fb_messages AS a ON a.thread = l.thread
INNER JOIN #__fb_messages_text AS t ON a.thread = t.mesid
LEFT JOIN #__users AS j ON j.id = a.userid
LEFT JOIN #__fb_users AS u ON u.userid = j.id
LEFT JOIN #__fb_categories AS c ON c.id = a.catid
WHERE (a.parent='0' OR a.id=l.lastid)
ORDER BY ordering DESC, lastid DESC";
$kunena_db->setQuery($query);
$messagelist = $kunena_db->loadObjectList();
check_dberror("Unable to load messages.");
foreach ($messagelist as $message)
{
$messages[$message->parent][] = $message;
$messagetext[$message->id] = substr(smile::purify($message->messagetext), 0, 500);
if ($message->parent==0)
{
$hits[$message->id] = $message->hits;
$thread_counts[$message->id] = $message->msgcount-1;
$last_read[$message->id]->unread = 0;
if ($message->favcount) $favthread[$message->id] = $message->favcount;
if ($message->id == $message->lastid) $last_read[$message->id]->lastread = $last_reply[$message->id] = $message;
}
else
{
$last_read[$message->thread]->lastread = $last_reply[$message->thread] = $message;
}
}
$kunena_db->setQuery("SELECT thread, MIN(id) AS lastread, SUM(1) AS unread FROM #__fb_messages "
."WHERE hold='0' AND moved='0' AND thread IN ({$idstr}) AND time>'{$prevCheck}' GROUP BY thread");
$msgidlist = $kunena_db->loadObjectList();
check_dberror("Unable to get unread messages count and first id.");
foreach ($msgidlist as $msgid)
{
if (!in_array($msgid->thread, $read_topics)) $last_read[$msgid->thread] = $msgid;
}
}
//get number of pending messages
$kunena_db->setQuery("SELECT COUNT(*) FROM #__fb_messages WHERE catid='{$catid}' AND hold='1'");
$numPending = $kunena_db->loadResult();
check_dberror('Unable to get number of pending messages.');
//@rsort($messages[0]);
?>
setQuery("SELECT * FROM #__fb_categories WHERE id='{$catid}'");
$objCatInfo = $kunena_db->loadObject();
check_dberror('Unable to get categories.');
//Get the Category's parent category name for breadcrumb
$kunena_db->setQuery("SELECT name, id FROM #__fb_categories WHERE id='{$objCatInfo->parent}'");
$objCatParentInfo = $kunena_db->loadObject();
check_dberror('Unable to get parent category.');;
//check if this forum is locked
$forumLocked = $objCatInfo->locked;
//check if this forum is subject to review
$forumReviewed = $objCatInfo->review;
//meta description and keywords
$metaKeys=kunena_htmlspecialchars(stripslashes(_KUNENA_CATEGORIES . ", {$objCatParentInfo->name}, {$objCatInfo->name}, {$fbConfig->board_title}, " . $app->getCfg('sitename')));
$metaDesc=kunena_htmlspecialchars(stripslashes("{$objCatParentInfo->name} ({$page}/{$totalpages}) - {$objCatInfo->name} - {$fbConfig->board_title}"));
$document =& JFactory::getDocument();
$cur = $document->get( 'description' );
$metaDesc = $cur .'. ' . $metaDesc;
$document =& JFactory::getDocument();
$document->setMetadata( 'keywords', $metaKeys );
$document->setDescription($metaDesc);
?>
headerdesc) { ?>
';
if (isset($forum_new)) echo $forum_new;
if (isset($forum_markread)) echo ' '.$forum_markread;
echo '';
}
?>
0)
{
echo $pagination;
}
?>
';
echo $pathway1;
echo '';
?>
setQuery("SELECT * FROM #__fb_moderation AS m LEFT JOIN #__users AS u ON u.id=m.userid WHERE m.catid='{$catid}'");
$modslist = $kunena_db->loadObjectList();
check_dberror("Unable to load moderators.");
if (count($modslist) > 0):
?>
setQuery("SELECT id, name, parent FROM #__fb_categories WHERE parent='{$category}' AND published='1' ORDER BY ordering");
$forums = $kunena_db->loadObjectList();
check_dberror("Unable to load categories.");
foreach ($forums as $forum)
{
if (in_array($forum->id, $allow_forum)) {
echo("");
}
showChildren($forum->id, $prefix . "---", $allow_forum);
}
}
?>