<?php
define('DIR',dirname( __FILE__ ) . '/');
define('JAVASCRIPT_PowerCode',false);
@error_reporting(0);
$page = empty($_GET['page']) ? 'index' : $_GET['page'];

//////////
if (!is_array($CALL_SYSTEM))
{
	$CALL_SYSTEM = array();
}
	$CALL_SYSTEM['INFO']               = 	true;
	$CALL_SYSTEM['ADS']                = 	true;
	$CALL_SYSTEM['ONLINE']             = 	true;
	$CALL_SYSTEM['BANNED']             = 	true;
	$CALL_SYSTEM['GROUP']              = 	true;
	$CALL_SYSTEM['MEMBER']             = 	true;
	$CALL_SYSTEM['PAGES']              = 	true;
	$CALL_SYSTEM['REPLY']              = 	true;
	$CALL_SYSTEM['SECTION']            = 	true;
	$CALL_SYSTEM['STYLE']              = 	true;
	$CALL_SYSTEM['SUBJECT']            = 	true;
	$CALL_SYSTEM['ICONS']              = 	true;
	$CALL_SYSTEM['LANG']               = 	true;
	$CALL_SYSTEM['CHAT']               = 	true;
	$CALL_SYSTEM['VISITOR']            = 	true;
	$CALL_SYSTEM['ADSENSE']            = 	true;
	$CALL_SYSTEM['MODERATORS']         = 	true;
	$CALL_SYSTEM['ADDONS']             = 	true;
	$CALL_SYSTEM['HOOKS']              = 	true;

	if ($page != 'index')
	{
	$CALL_SYSTEM['MISC']               = 	true;
	$CALL_SYSTEM['ATTACH']             = 	true;
	$CALL_SYSTEM['FILESEXTENSION']     = 	true;
	$CALL_SYSTEM['USERTITLE']          = 	true;
	$CALL_SYSTEM['REQUEST']            = 	true;
	$CALL_SYSTEM['WARNLOG']            = 	true;
	$CALL_SYSTEM['EXTRAFIELD']         = 	true;
	$CALL_SYSTEM['RATING']             = 	true;
	$CALL_SYSTEM['SUPERMEMBERLOGS']    = 	true;
	$CALL_SYSTEM['CACHE']              = 	true;
	$CALL_SYSTEM['MESSAGE']            = 	true;
	$CALL_SYSTEM['EMAILED']            = 	true;
	$CALL_SYSTEM['TAG']                = 	true;
	$CALL_SYSTEM['TAG_SUBJECT']        = 	true;
	$CALL_SYSTEM['PM']                 = 	true;
	$CALL_SYSTEM['FRIENDS']            = 	true;
	$CALL_SYSTEM['VISITORMESSAGE']     = 	true;
	}

	if ($page == 'forum')
	{
	$CALL_SYSTEM['ANNOUNCEMENT']       = 	true;
	$CALL_SYSTEM['SEARCH']             = 	true;
	}
	if ($page == 'search')
	{
	$CALL_SYSTEM['SEARCH']             = 	true;
	}

	if ($page == 'usercp')
	{
	$CALL_SYSTEM['REPUTATION']         = 	true;
	$CALL_SYSTEM['CUSTOM_BBCODE']      = 	true;
	}

	if ($page == 'new_topic'
	or $page == 'topic'
	or $page == 'new_reply'
	or $page == 'usercp'
	or $page == 'pm_show'
	or $page == 'pm_send'
	or $page == 'management'
	or $page == 'managementreply'
	or $page == 'profile')
	{
	$CALL_SYSTEM['TOOLBOX']            = 	true;
	$CALL_SYSTEM['TOPICMOD']           = 	true;
	$CALL_SYSTEM['POLL']               = 	true;
	$CALL_SYSTEM['VOTE']               = 	true;
	$CALL_SYSTEM['USERRATING']         = 	true;
	$CALL_SYSTEM['AVATAR']             = 	true;
	$CALL_SYSTEM['AWARD']              = 	true;
	$CALL_SYSTEM['CUSTOM_BBCODE']      = 	true;

	}


	if (defined('IN_ADMIN'))
	{
	$CALL_SYSTEM['TEMPLATESEDITS']     = 	true;
	$CALL_SYSTEM['FEEDS']              = 	true;
	$CALL_SYSTEM['EMAILMESSAGES']      = 	true;
	$CALL_SYSTEM['FIXUP']              = 	true;
	$CALL_SYSTEM['AWARD']              = 	true;
	$CALL_SYSTEM['CUSTOM_BBCODE']      = 	true;
	}
// Can't live without this file :)
include('./pbboard.class.php');
// The master object
$PowerBB = new PowerBB;
//////////
	if (defined('IN_ADMIN'))
	{
		require_once('modules/admin/common.module.php');
	}
	else
	{
		require_once('modules/common.module.php');
	}

//////////
class PowerBBLocalCommon
{
	function run()
	{
		@header('Content-Type: text/html; charset=utf-8'); // Viva utf ;)
		$this->_SetConfigArray();
	}

	/**
	 * Set the important variables for the system
	 */
	function _SetConfigArray()
	{
		global $PowerBB;
		// Important variables , all important variables should store in _CONF array
		$PowerBB->_CONF['member_permission']		=	false;
 		$PowerBB->_CONF['param']					=	array();
 		$PowerBB->_CONF['rows']					=	array();
        $PowerBB->_CONF['temp']['query_numbers'] =	0;
 		$PowerBB->_CONF['temp']['queries']		=	array();
 		$PowerBB->_CONF['template']				=	array();
 		$PowerBB->_CONF['template']['while']		=	array();
 		$PowerBB->_CONF['template']['foreach']	=	array();
 		//////////
 		// Make life easy for developers :)
 		$PowerBB->DB->SetDebug(true);
 		$PowerBB->DB->SetQueriesStore(true);
 		//////////
 		define('STOP_STYLE',$PowerBB->_POST['ajax'] ? true : false);
 		//////////
	}
}
//////////
$local_common = new PowerBBLocalCommon();
$local_common->run();
//////////
$common = new PowerBBCommon();
$common->run();
//////////
?>
