/***************************************************************************
Jupiter Content System @ Jupiterportal.com
Copyright (C) 2005 Cosmin Flavius (highstrike@gmail.com)
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
More Info About The Licence At http://www.gnu.org/copyleft/gpl.html
****************************************************************************/
function b_forum()
{
$name_function = "b_forum";
global $a, $db, $blocks_db, $template, $language, $config, $misc, $PHP_SELF, $is_loged_in, $is_moderator, $is_administrator, $is_webmaster, $months, $days, $m, $y, $OnlineGuestsCount, $OnlineMembersCount;
if(!file_exists("blocks/$name_function/language/{$config['language']}")) include "blocks/$name_function/language/en.php";
else include "blocks/$name_function/language/{$config['language']}";
$random_code = md5("$name_function");
$random_code = substr("$random_code", 0, 5);
if(!isset($content)) $content = NULL;
if(!isset($_GET["$random_code"])) $_GET["$random_code"] = NULL;
if($_GET["$random_code"] == "on") $_SESSION["$random_code"] = "on";
elseif($_GET["$random_code"] == "off") $_SESSION["$random_code"] = "off";
$query_string = "?{$_SERVER['QUERY_STRING']}";
foreach($blocks_db as $blocks)
{
$block_code = md5("{$blocks['name']}");
$block_code = substr("$block_code", 0, 5);
$query_string = str_replace("&$block_code=off","", $query_string);
$query_string = str_replace("&$block_code=on","", $query_string);
}
if($query_string == "?" || strpos($query_string, '=on') !== false || strpos($query_string, '=off') !== false) $code_query = "?";
else $code_query = "$query_string&";
if(!isset($_SESSION["$random_code"]) || $_SESSION["$random_code"] == "on") $links = " {$language_block['Forum title']}";
elseif($_SESSION["$random_code"] == "off") $links = "
{$language_block['Forum title']}";
$template_block = implode("", file("templates/$template/block.php"));
$template_block = str_replace("{template}", $template, $template_block);
$template_block = str_replace("{links}", $links, $template_block);
if(!isset($_SESSION["$random_code"]) || $_SESSION["$random_code"] == "on")
{
//-----------------------------------------------------------------
// Get Table + Restrictions
//-----------------------------------------------------------------
if(isset($is_moderator) || isset($is_administrator) || isset($is_webmaster)) $forum_topics = $db->getTable("SELECT f.id AS fid, f.type, f.cat, f.subcat, f.lastpost_date, f.name, f.lastpost_id, f.lastpost_user, f.lastpost_email, f.lastpost_location, u.id AS uid, u.username FROM forum_topics AS f LEFT JOIN users AS u ON f.lastpost_id = u.id ORDER BY lastpost_date DESC LIMIT {$language_block['Forum config']}");
else $forum_topics = $db->getTable("SELECT f.id AS fid, f.type, f.cat, f.subcat, f.lastpost_date, f.name, f.lastpost_id, f.lastpost_user, f.lastpost_email, f.lastpost_location, s.id AS sid, s.type, u.id AS uid, u.username FROM forum_topics AS f LEFT JOIN forum_subcat AS s ON (s.id = f.subcat AND s.type != 3) LEFT JOIN users AS u ON f.lastpost_id = u.id WHERE f.subcat = s.id ORDER BY lastpost_date DESC LIMIT {$language_block['Forum config']}");
//-----------------------------------------------------------------
// Make Foreach
//-----------------------------------------------------------------
foreach($forum_topics as $idx=>$forum_topic)
{
if($forum_topic['type'] != "3")
{
$content .= "