<?php
/* 
YUI Forum Home Tab v4.0.5
Originally created by bobster65 of http://www.vbulletin.org/forum/member.php?u=134768 and King Kovifor http://www.vbulletin.org/forum/member.php?u=70023 till version 4.0.2 beta 2a
Continued by ZeroHour http://www.vbulletin.org/forum/member.php?u=221305
*/
// ####################### SET PHP ENVIRONMENT ###########################
error_reporting(E_ALL & ~E_NOTICE);

// #################### DEFINE IMPORTANT CONSTANTS #######################
define('THIS_SCRIPT', 'indexTFH');
define('CSRF_PROTECTION', true);
define('CSRF_SKIP_LIST', '');
define('VB_ENTRY', 'tabindex.php');

// ################### PRE-CACHE TEMPLATES AND DATA ######################
// get special phrase groups

// get special data templates from the datastore
$specialtemplates = array(
	'iconcache',
	'mailqueue',
);

// pre-cache templates used by all actions
$globaltemplates = array(
	'ad_forumhome_afterforums',
	'ad_board_below_whats_going_on',
	'block_blogentries',
	'block_cmsarticles',
	'block_newposts',
	'block_sgdiscussions',
	'block_tagcloud',
	'block_threads',	
	'FORUMHOMETAB',	
	'FORUMHOME',
	'forumhome_event',
	'forumhome_forumbit_level1_nopost',
	'forumhome_forumbit_level1_post',
	'forumhome_forumbit_level2_nopost',
	'forumhome_forumbit_level2_post',
	'forumhome_lastpostby',
	'forumhome_loggedinuser',
	'forumhome_moderator',
	'forumhome_subforumbit_nopost',
	'forumhome_subforumbit_post',
	'forumhome_subforumseparator_nopost',
	'forumhome_subforumseparator_post',
	'forumhome_markread_script',
	'forumhome_birthdaybit',
	'tag_cloud_link',
);

// pre-cache templates used by specific actions
$actiontemplates = array();

// ######################### REQUIRE BACK-END ############################
require_once('./global.php');
require_once(DIR . '/includes/functions_bigthree.php');
require_once(DIR . '/includes/functions_forumlist.php');
require_once(DIR . '/includes/class_block.php');

// #######################################################################
// ######################## START MAIN SCRIPT ############################
// #######################################################################

($hook = vBulletinHook::fetch_hook('forumhome_start')) ? eval($hook) : false;

// get permissions to view forumhome
if (!($permissions['forumpermissions'] & $vbulletin->bf_ugp_forumpermissions['canview']))
{
	print_no_permission();
}

$navbits = array();

if (empty($foruminfo['forumid']))
{
	// show all forums
	$forumid = -1;

	$navbits[''] = $vbphrase['forum'];
}
else
{
	// check forum permissions
	$_permsgetter_ = 'index';
	$forumperms = fetch_permissions($foruminfo['forumid']);

	if (!($forumperms & $vbulletin->bf_ugp_forumpermissions['canview']))
	{
		print_no_permission();
	}

	// check if there is a forum password and if so, ensure the user has it set
	verify_forum_password($foruminfo['forumid'], $foruminfo['password']);

	// draw nav bar
	$navbits[$vbulletin->options['forumhome'] . '.php' . $vbulletin->session->vars['sessionurl_q']] = $vbphrase['forum'];
	$parentlist = array_reverse(explode(',', substr($foruminfo['parentlist'], 0, -3)));
	foreach ($parentlist AS $forumID)
	{
		$forumTitle =& $vbulletin->forumcache["$forumID"]['title'];
		$navbits[fetch_seo_url('forum', array('forumid' => $forumID, 'title' => $forumTitle))] = $forumTitle;
	}

	// pop the last element off the end of the $nav array so that we can show it without a link
	array_pop($navbits);

	$navbits[''] = $foruminfo['title'];
}

$today = vbdate('Y-m-d', TIMENOW, false, false);

$show['birthdays'] = false;

$show['upcomingevents'] = false;
$show['loggedinusers'] = false;

// ### GET FORUMS & MODERATOR iCACHES ########################
cache_ordered_forums(1, 1);
if ($vbulletin->options['showmoderatorcolumn'])
{
	cache_moderators();
}
else if ($vbulletin->userinfo['userid'])
{
	cache_moderators($vbulletin->userinfo['userid']);
}

// define max depth for forums display based on $vbulletin->options[forumhomedepth]
define('MAXFORUMDEPTH', $vbulletin->options['forumhomedepth']);

$tabID = $_REQUEST['tID'];
$tabcats = $_REQUEST['tabcat'];
$forumbits = construct_forum_bit(-1);

//$forumbits = construct_forum_bit($forumid);
$forumhome_markread_script = vB_Template::create('forumhome_markread_script')->render();

$show['sidebar'] = false;
// disable blocks for ie6

// ### ALL DONE! SPIT OUT THE HTML AND LET'S GET OUTTA HERE... ###
($hook = vBulletinHook::fetch_hook('forumhome_complete')) ? eval($hook) : false;

$navbar = render_navbar_template(construct_navbits($navbits));
$templater = vB_Template::create('FORUMHOMETAB');
	$templater->register_page_templates();
//	$templater->register('activemembers', $activemembers);
//	$templater->register('activeusers', $activeusers);
//	$templater->register('ad_location', $ad_location);
//	$templater->register('birthdays', $birthdays);
	$templater->register('forumbits', $forumbits);
	$templater->register('forumhome_markread_script', $forumhome_markread_script);
//	$templater->register('navbar', $navbar);
//	$templater->register('newuserinfo', $newuserinfo);
//	$templater->register('numberguest', $numberguest);
//	$templater->register('numbermembers', $numbermembers);
//	$templater->register('numberregistered', $numberregistered);
//	$templater->register('recorddate', $recorddate);
//	$templater->register('recordtime', $recordtime);
//	$templater->register('recordusers', $recordusers);
	$templater->register('template_hook', $template_hook);
//	$templater->register('today', $today);
//	$templater->register('totalonline', $totalonline);
//	$templater->register('totalposts', $totalposts);
//	$templater->register('totalthreads', $totalthreads);
//	$templater->register('upcomingevents', $upcomingevents);
//	$templater->register('sidebar', $sidebar);	
print_output($templater->render());
?>