Beispiel #1
0
        Database::get()->query("DELETE FROM rating_cache WHERE rtype = ?s AND rid = ?d", 'forum_post', $r->id);
        Database::get()->query("DELETE FROM forum_post WHERE id = $r->id");
    }
    $post_authors = array_unique($post_authors);
    foreach ($post_authors as $author) {
        $forum_user_stats = Database::get()->querySingle("SELECT COUNT(*) as c FROM forum_post
                        INNER JOIN forum_topic ON forum_post.topic_id = forum_topic.id
                        INNER JOIN forum ON forum.id = forum_topic.forum_id
                        WHERE forum_post.poster_id = ?d AND forum.course_id = ?d", $author, $course_id);
        Database::get()->query("DELETE FROM forum_user_stats WHERE user_id = ?d AND course_id = ?d", $author, $course_id);
        if ($forum_user_stats->c != 0) {
            Database::get()->query("INSERT INTO forum_user_stats (user_id, num_posts, course_id) VALUES (?d,?d,?d)", $author, $forum_user_stats->c, $course_id);
        }
    }
    Indexer::queueAsync(Indexer::REQUEST_REMOVEBYTOPIC, Indexer::RESOURCE_FORUMPOST, $topic_id);
    $number_of_topics = get_total_topics($forum_id);
    $num_topics = $number_of_topics - 1;
    if ($number_of_topics < 0) {
        $num_topics = 0;
    }
    Database::get()->query("DELETE FROM forum_topic WHERE id = ?d AND forum_id = ?d", $topic_id, $forum_id);
    Indexer::queueAsync(Indexer::REQUEST_REMOVE, Indexer::RESOURCE_FORUMTOPIC, $topic_id);
    Database::get()->query("UPDATE forum SET num_topics = ?d,
                                num_posts = num_posts-$number_of_posts
                            WHERE id = ?d
                                AND course_id = ?d", $num_topics, $forum_id, $course_id);
    Database::get()->query("DELETE FROM forum_notify WHERE topic_id = ?d AND course_id = ?d", $topic_id, $course_id);
    Session::Messages($langDeletedMessage, 'alert-success');
    redirect_to_home_page("modules/forum/viewforum.php?course=$course_code&forum=$forum_id");   
}
Beispiel #2
0
 }
 echo "</div>";
 echo "<div style='padding: 8px;'>" . _AM_NEWBB_ATTACHPATH . ": ";
 $attach_path = XOOPS_ROOT_PATH . '/' . $xoopsModuleConfig['dir_attachments'] . '/';
 $path_status = newbb_admin_getPathStatus($attach_path);
 echo $attach_path . ' ( ' . $path_status . ' )';
 echo "<br />" . _AM_NEWBB_THUMBPATH . ": ";
 $thumb_path = $attach_path . 'thumbs/';
 // be careful
 $path_status = newbb_admin_getPathStatus($thumb_path);
 echo $thumb_path . ' ( ' . $path_status . ' )';
 echo "</div>";
 echo "</fieldset><br />";
 echo "<fieldset><legend style='font-weight: bold; color: #900;'>" . _AM_NEWBB_BOARDSUMMARY . "</legend>";
 echo "<div style='padding: 12px;'>";
 echo _AM_NEWBB_TOTALTOPICS . " <strong>" . get_total_topics() . "</strong> | ";
 echo _AM_NEWBB_TOTALPOSTS . " <strong>" . get_total_posts(0, 'all') . "</strong> | ";
 echo _AM_NEWBB_TOTALVIEWS . " <strong>" . get_total_views() . "</strong></div>";
 echo "</fieldset><br />";
 $report_handler =& xoops_getmodulehandler('report', 'newbb');
 echo "<fieldset><legend style='font-weight: bold; color: #900;'>" . _AM_NEWBB_REPORT . "</legend>";
 echo "<div style='padding: 12px;'><a href='admin_report.php'>" . _AM_NEWBB_REPORT_PENDING . "</a> <strong>" . $report_handler->getReportCount(0) . "</strong> | ";
 echo _AM_NEWBB_REPORT_PROCESSED . " <strong>" . $report_handler->getReportCount(1) . "</strong>";
 echo "</div>";
 echo "</fieldset><br />";
 if ($xoopsModuleConfig['email_digest'] > 0) {
     $digest_handler =& xoops_getmodulehandler('digest', 'newbb');
     echo "<fieldset><legend style='font-weight: bold; color: #900;'>" . _AM_NEWBB_DIGEST . "</legend>";
     $due = $digest_handler->checkStatus() / 60;
     // minutes
     $prompt = $due > 0 ? sprintf(_AM_NEWBB_DIGEST_PAST, $due) : sprintf(_AM_NEWBB_DIGEST_NEXT, abs($due));
Beispiel #3
0
     exit;
 }
 $message = purify($message);
 $poster_ip = $_SERVER['REMOTE_ADDR'];
 $time = date("Y-m-d H:i:s");
 $topic_id = Database::get()->query("INSERT INTO forum_topic (title, poster_id, forum_id, topic_time) VALUES (?s, ?d, ?d, ?t)", $subject, $uid, $forum_id, $time)->lastInsertID;
 Indexer::queueAsync(Indexer::REQUEST_STORE, Indexer::RESOURCE_FORUMTOPIC, $topic_id);
 $post_id = Database::get()->query("INSERT INTO forum_post (topic_id, post_text, poster_id, post_time, poster_ip) VALUES (?d, ?s, ?d, ?t, ?s)", $topic_id, $message, $uid, $time, $poster_ip)->lastInsertID;
 Indexer::queueAsync(Indexer::REQUEST_STORE, Indexer::RESOURCE_FORUMPOST, $post_id);
 $forum_user_stats = Database::get()->querySingle("SELECT COUNT(*) as c FROM forum_post \n                        INNER JOIN forum_topic ON forum_post.topic_id = forum_topic.id\n                        INNER JOIN forum ON forum.id = forum_topic.forum_id\n                        WHERE forum_post.poster_id = ?d AND forum.course_id = ?d", $uid, $course_id);
 Database::get()->query("DELETE FROM forum_user_stats WHERE user_id = ?d AND course_id = ?d", $uid, $course_id);
 Database::get()->query("INSERT INTO forum_user_stats (user_id, num_posts, course_id) VALUES (?d,?d,?d)", $uid, $forum_user_stats->c, $course_id);
 Database::get()->query("UPDATE forum_topic\n                    SET last_post_id = ?d\n                WHERE id = ?d\n                AND forum_id = ?d", $post_id, $topic_id, $forum_id);
 Database::get()->query("UPDATE forum\n                    SET num_topics = num_topics+1,\n                    num_posts = num_posts+1,\n                    last_post_id = ?d\n\t\tWHERE id = ?d", $post_id, $forum_id);
 $topic = $topic_id;
 $total_forum = get_total_topics($forum_id);
 $total_topic = get_total_posts($topic) - 1;
 // subtract 1 because we want the number of replies, not the number of posts.
 // --------------------------------
 // notify users
 // --------------------------------
 $subject_notify = "{$logo} - {$langNewForumNotify}";
 $category_id = forum_category($forum_id);
 $cat_name = category_name($category_id);
 $c = course_code_to_title($course_code);
 $name = uid_to_name($uid);
 $title = course_id_to_title($course_id);
 $forum_message = "-------- {$langBodyMessage} ({$langSender}: {$name})\n{$message}--------";
 $plain_forum_message = q(html2text($forum_message));
 $body_topic_notify = "{$langBodyForumNotify} {$langInForums} '" . q($forum_name) . "' \n                               {$langInCat} '" . q($cat_name) . "' {$langTo} {$langCourseS} '{$c}' <br /><br />" . q($forum_message) . "<br />\n                               <br />{$gunet}<br /><a href='{$urlServer}courses/{$course_code}'>{$urlServer}courses/{$course_code}</a>";
 $plain_body_topic_notify = "{$langBodyForumNotify} {$langInForums} '" . q($forum_name) . "' {$langInCat} '" . q($cat_name) . "' {$langTo} {$langCourseS} '{$c}' \n\n{$plain_forum_message} \n\n{$gunet}\n<a href='{$urlServer}courses/{$course_code}'>{$urlServer}courses/{$course_code}</a>";
/**
 * Get the average number of topics per day
 *
 * @since 0.7.2
 *
 * @return int|float
 */
function get_topics_per_day()
{
    return get_total_topics() / ceil((time() - bb_get_inception('timestamp')) / 3600 / 24);
}
Beispiel #5
0
<?php

// Get started
require_once 'admin.php';
require_once BB_PATH . BB_INC . 'functions.bb-statistics.php';
// Get counts and format numbers
$rn_forums = number_format(get_total_forums());
$rn_forums = sprintf(__ngettext('<span>%s</span> forum', '<span>%s</span> forums', $rn_forums), $rn_forums);
$rn_topics = number_format(get_total_topics());
$rn_topics = sprintf(__ngettext('<span>%s</span> topic', '<span>%s</span> topics', $rn_topics), $rn_topics);
$rn_posts = number_format(get_total_posts());
$rn_posts = sprintf(__ngettext('<span>%s</span> post', '<span>%s</span> posts', $rn_posts), $rn_posts);
$rn_users = number_format(bb_get_total_users());
$rn_users = sprintf(__ngettext('<span>%s</span> user', '<span>%s</span> users', $rn_users), $rn_users);
$rn_topic_tags = number_format(bb_get_total_topic_tags());
$rn_topic_tags = sprintf(__ngettext('<span>%s</span> tag', '<span>%s</span> tags', $rn_topic_tags), $rn_topic_tags);
$rn_topics_average = number_format(get_topics_per_day());
$rn_topics_average = sprintf(__ngettext('<span>%s</span> topic', '<span>%s</span> topics', $rn_topics_average), $rn_topics_average);
$rn_posts_average = number_format(get_posts_per_day());
$rn_posts_average = sprintf(__ngettext('<span>%s</span> post', '<span>%s</span> posts', $rn_posts_average), $rn_posts_average);
$rn_users_average = number_format(get_registrations_per_day());
$rn_users_average = sprintf(__ngettext('<span>%s</span> user', '<span>%s</span> users', $rn_users_average), $rn_users_average);
$rn_topic_tags_average = number_format(bb_get_topic_tags_per_day());
$rn_topic_tags_average = sprintf(__ngettext('<span>%s</span> tag', '<span>%s</span> tags', $rn_topic_tags_average), $rn_topic_tags_average);
// Filter the numbers
$rn = apply_filters('bb_admin_right_now', array('forums' => array($rn_forums, '-'), 'topics' => array($rn_topics, $rn_topics_average), 'posts' => array($rn_posts, $rn_posts_average), 'topic_tags' => array($rn_topic_tags, $rn_topic_tags_average), 'users' => array($rn_users, $rn_users_average)));
$bb_admin_body_class = ' bb-admin-dashboard';
bb_get_admin_header();
?>

<div class="wrap">
Beispiel #6
0
<?php

require_once 'admin.php';
require_once BB_PATH . BB_INC . 'functions.bb-statistics.php';
$rn_forums = get_total_forums();
$rn_forums = sprintf(__ngettext('<span>%d</span> forum', '<span>%d</span> forums', $rn_forums), $rn_forums);
$rn_topics = get_total_topics();
$rn_topics = sprintf(__ngettext('<span>%d</span> topic', '<span>%d</span> topics', $rn_topics), $rn_topics);
$rn_posts = get_total_posts();
$rn_posts = sprintf(__ngettext('<span>%d</span> post', '<span>%d</span> posts', $rn_posts), $rn_posts);
$rn_users = bb_get_total_users();
$rn_users = sprintf(__ngettext('<span>%d</span> user', '<span>%d</span> users', $rn_users), $rn_users);
$rn_topic_tags = bb_get_total_topic_tags();
$rn_topic_tags = sprintf(__ngettext('<span>%d</span> tag', '<span>%d</span> tags', $rn_topic_tags), $rn_topic_tags);
$rn_topics_average = get_topics_per_day();
$rn_topics_average = sprintf(__ngettext('<span>%d</span> topic', '<span>%d</span> topics', $rn_topics_average), $rn_topics_average);
$rn_posts_average = get_posts_per_day();
$rn_posts_average = sprintf(__ngettext('<span>%d</span> post', '<span>%d</span> posts', $rn_posts_average), $rn_posts_average);
$rn_users_average = get_registrations_per_day();
$rn_users_average = sprintf(__ngettext('<span>%d</span> user', '<span>%d</span> users', $rn_users_average), $rn_users_average);
$rn_topic_tags_average = bb_get_topic_tags_per_day();
$rn_topic_tags_average = sprintf(__ngettext('<span>%d</span> tag', '<span>%d</span> tags', $rn_topic_tags_average), $rn_topic_tags_average);
$bb_admin_body_class = ' bb-admin-dashboard';
bb_get_admin_header();
?>

<div class="wrap">
	<h2><?php 
_e('Dashboard');
?>
</h2>
Beispiel #7
0
 }
 echo "</div>";
 echo "<div style='padding: 8px;'>" . _AM_XFORUM_ATTACHPATH . ": ";
 $attach_path = XOOPS_ROOT_PATH . '/' . $xoopsModuleConfig['dir_attachments'] . '/';
 $path_status = forum_admin_getPathStatus($attach_path);
 echo $attach_path . ' ( ' . $path_status . ' )';
 echo "<br />" . _AM_XFORUM_THUMBPATH . ": ";
 $thumb_path = $attach_path . 'thumbs/';
 // be careful
 $path_status = forum_admin_getPathStatus($thumb_path);
 echo $thumb_path . ' ( ' . $path_status . ' )';
 echo "</div>";
 echo "</fieldset><br />";
 echo "<fieldset><legend style='font-weight: bold; color: #900;'>" . _AM_XFORUM_BOARDSUMMARY . "</legend>";
 echo "<div style='padding: 12px;'>";
 echo _AM_XFORUM_TOTALTOPICS . " <strong>" . get_total_topics() . "</strong> | ";
 echo _AM_XFORUM_TOTALPOSTS . " <strong>" . get_total_posts() . "</strong> | ";
 echo _AM_XFORUM_TOTALVIEWS . " <strong>" . get_total_views() . "</strong></div>";
 echo "</fieldset><br />";
 $report_handler =& xoops_getmodulehandler('report', 'xforum');
 echo "<fieldset><legend style='font-weight: bold; color: #900;'>" . _AM_XFORUM_REPORT . "</legend>";
 echo "<div style='padding: 12px;'><a href='admin_report.php'>" . _AM_XFORUM_REPORT_PENDING . "</a> <strong>" . $report_handler->getCount(new Criteria("report_result", 0)) . "</strong> | ";
 echo _AM_XFORUM_REPORT_PROCESSED . " <strong>" . $report_handler->getCount(new Criteria("report_result", 1)) . "</strong>";
 echo "</div>";
 echo "</fieldset><br />";
 if ($xoopsModuleConfig['email_digest'] > 0) {
     $digest_handler =& xoops_getmodulehandler('digest', 'xforum');
     echo "<fieldset><legend style='font-weight: bold; color: #900;'>" . _AM_XFORUM_DIGEST . "</legend>";
     $due = $digest_handler->checkStatus() / 60;
     // minutes
     $prompt = $due > 0 ? sprintf(_AM_XFORUM_DIGEST_PAST, $due) : sprintf(_AM_XFORUM_DIGEST_NEXT, abs($due));
Beispiel #8
0
    ?>
</div>
								</div>
							</div>
						</div>
						<div class="col-md-4 col-sm-6 col-xs-12 statistics">
							<div class="row">
								<div class="col-xs-6">
									<div class="statistic-item"><?php 
    total_topics();
    ?>
</div>
								</div>
								<div class="col-xs-6">
									<div class="statistic-item-stat"><?php 
    echo _n('Topic', 'Topics', get_total_topics(), 'luna');
    ?>
</div>
								</div>
							</div>
						</div>
						<div class="col-md-4 col-sm-6 col-xs-12 statistics">
							<div class="row">
								<div class="col-xs-6">
									<div class="statistic-item"><?php 
    total_posts();
    ?>
</div>
								</div>
								<div class="col-xs-6">
									<div class="statistic-item-stat"><?php 
Beispiel #9
0
    ?>
</div>
								</div>
							</div>
						</div>
						<div class="col-md-4 col-sm-6 col-xs-12 statistics">
							<div class="row">
								<div class="col-xs-6">
									<div class="statistic-item"><?php 
    total_topics();
    ?>
</div>
								</div>
								<div class="col-xs-6">
									<div class="statistic-item-stat"><?php 
    echo _n('Thread', 'Threads', get_total_topics(), 'luna');
    ?>
</div>
								</div>
							</div>
						</div>
						<div class="col-md-4 col-sm-6 col-xs-12 statistics">
							<div class="row">
								<div class="col-xs-6">
									<div class="statistic-item"><?php 
    total_posts();
    ?>
</div>
								</div>
								<div class="col-xs-6">
									<div class="statistic-item-stat"><?php 
Beispiel #10
0
    redirect_header($url, 2, _MD_ALL_FORUM_MARKED . ' ' . $markresult);
}
$xoopsOption['template_main'] = 'newbb_index.html';
include XOOPS_ROOT_PATH . "/header.php";
if (!empty($xoopsModuleConfig['rss_enable'])) {
    $xoops_module_header .= '<link rel="alternate" type="application/xml+rss" title="' . $xoopsModule->getVar('name') . '" href="' . XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . '/rss.php" />';
}
$xoopsTpl->assign('xoops_module_header', $xoops_module_header);
if ($xoopsModuleConfig['wol_enabled']) {
    $online_handler =& xoops_getmodulehandler('online', 'newbb');
    $online_handler->init();
    $xoopsTpl->assign('online', $online_handler->show_online());
    $xoopsTpl->assign('color_admin', $xoopsModuleConfig['wol_admin_col']);
    $xoopsTpl->assign('color_mod', $xoopsModuleConfig['wol_mod_col']);
}
$xoopsTpl->assign(array("lang_welcomemsg" => sprintf(_MD_WELCOME, htmlspecialchars($xoopsConfig['sitename'], ENT_QUOTES)), "total_topics" => get_total_topics(), "total_posts" => get_total_posts(0, 'all'), "lang_lastvisit" => sprintf(_MD_LASTVISIT, formatTimestamp($last_visit)), "lang_currenttime" => sprintf(_MD_TIMENOW, formatTimestamp(time(), "m"))));
$viewcat = !empty($_GET['cat']) ? intval($_GET['cat']) : 0;
$category_handler =& xoops_getmodulehandler('category', 'newbb');
if (!$viewcat) {
    $categories =& $category_handler->getAllCats("access");
    $xoopsTpl->assign('forum_index_title', '');
} else {
    $cat =& $category_handler->get($viewcat);
    if ($category_handler->getPermission($cat)) {
        $categories = array($cat);
    } else {
        $categories = array();
    }
    $xoopsTpl->assign('forum_index_title', sprintf(_MD_FORUMINDEX, htmlspecialchars($xoopsConfig['sitename'], ENT_QUOTES)));
}
if (count($categories) == 0) {
Beispiel #11
0
function total_topics()
{
    echo get_total_topics();
}
Beispiel #12
0
 echo "<th>" . translate("Posts") . "</th>";
 echo "<th>" . translate("Last Posts") . "</th></tr></thead>";
 $result = sql_query("SELECT * FROM " . $NPDS_Prefix . "catagories ORDER BY cat_id");
 $num_for = 0;
 while (list($cat_id, $cat_title) = sql_fetch_row($result)) {
     $sub_sql = "SELECT f.*, u.uname FROM " . $NPDS_Prefix . "forums f, " . $NPDS_Prefix . "users u WHERE f.cat_id = '{$cat_id}' AND f.forum_moderator = u.uid ORDER BY forum_index,forum_id";
     if (!($sub_result = sql_query($sub_sql))) {
         forumerror('0022');
     }
     if ($myrow = sql_fetch_assoc($sub_result)) {
         echo "<tbody><tr><td class=\"active\" colspan=\"7\">" . stripslashes($cat_title) . "</td></tr>";
         do {
             $num_for++;
             $last_post = get_last_post($myrow['forum_id'], "forum", "infos", true);
             echo "<tr>";
             $total_topics = get_total_topics($myrow['forum_id']);
             echo "<td><i class=\"fa fa-lg fa-file-text-o\"></i></td>";
             $name = stripslashes($myrow['forum_name']);
             $xfile .= "\$xforum[{$num_for}][1] = \"{$name}\";\n";
             $xfile .= "\$xforum[{$num_for}][2] = {$total_topics};\n";
             echo "<td><a href=\"viewforum.php?forum=" . $myrow['forum_id'] . "\" class=\"noir\"><span class=\"rouge\">" . $xforum[$num_for][1] . "</span> -/- {$name} </a>\n";
             $desc = stripslashes($myrow['forum_desc']);
             echo "<br />{$desc}</td>\n";
             echo "<td><span class=\"rouge\">" . $xforum[$num_for][2] . "</span> -/- {$total_topics}</td>\n";
             $total_posts = get_total_posts($myrow['forum_id'], "", "forum", false);
             $xfile .= "\$xforum[{$num_for}][3] = {$total_posts};\n";
             echo "<td><span class=\"rouge\">" . $xforum[$num_for][3] . "</span> -/- {$total_posts}</td>\n";
             echo "<td>{$last_post}</td>\n";
         } while ($myrow = sql_fetch_assoc($sub_result));
     }
 }
Beispiel #13
0
$xoopsOption['xoops_module_header']= $xoops_module_header;
include XOOPS_ROOT_PATH."/header.php";

$xoopsTpl->assign('xoops_pagetitle', $xoops_pagetitle);
$xoopsTpl->assign('xoops_module_header', $xoops_module_header);
$xoopsTpl->assign('forum_index_title', $xforum_index_title);
if ($xoopsModuleConfig['wol_enabled']){
	$online_handler =& xoops_getmodulehandler('online', 'xforum');
	$online_handler->init();
    $xoopsTpl->assign('online', $online_handler->show_online());
}

/* display forum stats */
$xoopsTpl->assign(array(
	"lang_welcomemsg" => sprintf(_MD_WELCOME, htmlspecialchars($xoopsConfig['sitename'], ENT_QUOTES)), 
	"total_topics" => get_total_topics(), 
	"total_posts" => get_total_posts(), 
	"lang_lastvisit" => sprintf(_MD_LASTVISIT,formatTimestamp($last_visit)), 
	"lang_currenttime" => sprintf(_MD_TIMENOW,formatTimestamp(time(),"m"))));

$xforum_handler =& xoops_getmodulehandler('forum', 'xforum');
$xforums_obj = $xforum_handler->getForumsByCategory(array_keys($categories), "access");
$xforums_array = $xforum_handler->display($xforums_obj);
unset($xforums_obj);

if(count($xforums_array)>0){
    foreach ($xforums_array[0] as $parent => $xforum) {
        if (isset($xforums_array[$xforum['forum_id']])) {
            $xforum['subforum'] =& $xforums_array[$xforum['forum_id']];
        }
        $xforumsByCat[$xforum['forum_cid']][] = $xforum;
Beispiel #14
0
// Author: Kazumi Ono (AKA onokazu)                                          //
// URL: http://www.myweb.ne.jp/, http://www.xoops.org/, http://jp.xoops.org/ //
// Project: The XOOPS Project                                                //
// ------------------------------------------------------------------------- //
include "header.php";
// this page uses smarty template
// this must be set before including main header.php
$xoopsOption['template_main'] = 'newbb_index.html';
include XOOPS_ROOT_PATH . "/header.php";
$myts =& MyTextSanitizer::getInstance();
$sql = 'SELECT c.* FROM ' . $xoopsDB->prefix('bb_categories') . ' c, ' . $xoopsDB->prefix("bb_forums") . ' f WHERE f.cat_id=c.cat_id GROUP BY c.cat_id, c.cat_title, c.cat_order ORDER BY c.cat_order';
if (!($result = $xoopsDB->query($sql))) {
    redirect_header(XOOPS_URL . '/', 1, _MD_ERROROCCURED);
    exit;
}
$xoopsTpl->assign(array("lang_welcomemsg" => sprintf(_MD_WELCOME, $xoopsConfig['sitename']), "lang_tostart" => _MD_TOSTART, "lang_totaltopics" => _MD_TOTALTOPICSC, "lang_totalposts" => _MD_TOTALPOSTSC, "total_topics" => get_total_topics(), "total_posts" => get_total_posts(0, 'all'), "lang_lastvisit" => sprintf(_MD_LASTVISIT, formatTimestamp($last_visit)), "lang_currenttime" => sprintf(_MD_TIMENOW, formatTimestamp(time(), "m")), "lang_forum" => _MD_FORUM, "lang_topics" => _MD_TOPICS, "lang_posts" => _MD_POSTS, "lang_lastpost" => _MD_LASTPOST, "lang_moderators" => _MD_MODERATOR));
$viewcat = !empty($HTTP_GET_VARS['cat']) ? intval($HTTP_GET_VARS['cat']) : 0;
$categories = array();
while ($cat_row = $xoopsDB->fetchArray($result)) {
    $categories[] = $cat_row;
}
$sql = 'SELECT f.*, u.uname, u.uid, p.topic_id, p.post_time, p.subject, p.icon FROM ' . $xoopsDB->prefix('bb_forums') . ' f LEFT JOIN ' . $xoopsDB->prefix('bb_posts') . ' p ON p.post_id = f.forum_last_post_id LEFT JOIN ' . $xoopsDB->prefix('users') . ' u ON u.uid = p.uid';
if ($viewcat != 0) {
    $sql .= ' WHERE f.cat_id = ' . $viewcat;
    $xoopsTpl->assign('forum_index_title', sprintf(_MD_FORUMINDEX, $xoopsConfig['sitename']));
} else {
    $xoopsTpl->assign('forum_index_title', '');
}
$sql .= ' ORDER BY f.cat_id, f.forum_id';
if (!($result = $xoopsDB->query($sql))) {
    exit("Error");