<?php

/*$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$*\
<< ******************************************************************** >>
<< * ---------------------------------------------------------------- * >>
<< * Copyright ©2011-2012 Ozzy47                                      * >>
<< * All Rights Reserved. 											  * >>
<< * This file may not be redistributed in whole or significant part. * >>
<< * ---------------------------------------------------------------- * >>
<< * You are not allowed to use this on your server unless the files  * >>
<< * you downloaded were done so with permission.					  * >>
<< * ---------------------------------------------------------------- * >>
<< ******************************************************************** >>
\*$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$*/

// ####################### SET PHP ENVIRONMENT ###########################
error_reporting(E_ALL & ~E_NOTICE & ~8192);

// #################### DEFINE IMPORTANT CONSTANTS #######################
define('THIS_SCRIPT', 'vbnavtabs');

// ################### PRE-CACHE TEMPLATES AND DATA ######################
// get special phrase groups
$phrasegroups = array();

// get templates used by all actions
$globaltemplates = array(
	'dbtech_vbnavtabs',
	'dbtech_vbnavtabs.css',
	'dbtech_vbnavtabs_footer'
);

// pre-cache templates used by specific actions
$actiontemplates = array(
	'main' => array(
		'dbtech_vbnavtabs_main',
        'dbtech_vbnavtabs_main_links',
        'dbtech_vbnavtabs_main_links_bits',
	),
    
    'createlink' => array(
		'dbtech_vbnavtabs_add'
	),
    
);

// get special data templates from the datastore
$specialtemplates = array(
);

// ############################### default do value ######################
if (empty($_REQUEST['do']))
{
	$_REQUEST['do'] = $_GET['do'] = 'main';
}

// ######################### REQUIRE BACK-END ############################

//$forum_directory = 'C:/doc_root/www/domain/forums/';

if ($forum_directory)
{
chdir($forum_directory);
}

require_once('./global.php');
require_once(DIR . '/dbtech/vbnavtabs/includes/common_functions.php');

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

if (!empty($_POST['do']))
{
	// $_POST requests take priority
	$action = $_POST['do'];
}
else if (!empty($_GET['do']))
{
	// We had a GET request instead
	$action = $_GET['do'];
}
else
{
	// No request
	$action = 'main';
}

// Strip non-valid characters
$action = preg_replace('/[^\w-]/i', '', $action);

if ($_REQUEST['do'] == 'devinfo' AND $_REQUEST['devkey'] == 'dbtech')
{
	$_info = array(
		'version' 	=> '1.3.3',
		'versionnumber' => '133',
		'pro'		=> (is_dir(DIR . '/dbtech/vbnavtabs_pro')),
		'vbversion'		=> $vbulletin->versionnumber
	
	);
	$_content = array();
	foreach ($_info as $key => $val)
	{
		$_content[] = '"' . $key . '":"' . $val . '"';
	}
	echo '{' . implode(',', $_content) . '}';
	die();
}

if (!class_exists('vB_Template'))
{
	require_once(DIR . '/dbtech/vbnavtabs/includes/class_template.php');
}

$pagetitle = $vbphrase['dbtech_vbnavtabs_nav'];

if ($vbulletin->options['dbtech_vbnavtabsss_enabled'] == 1)
{
	if ($show['dbtech_vbnavtabs_view'] || $show['dbtech_vbnavtabs_admin'])
	{
		if (!file_exists(DIR . '/dbtech/vbnavtabs_pro/actions/' . $action . '.php'))
		{
			if (!file_exists(DIR . '/dbtech/vbnavtabs/actions/' . $action . '.php'))
			{
				eval(standard_error(fetch_error('dbtech_vbnavtabs_error_x', $vbphrase['dbtech_vbnavtabs_action_missing_file'])));
			} else {
				include_once(DIR . '/dbtech/vbnavtabs/actions/' . $action . '.php');	
			}
		} else {
			include_once(DIR . '/dbtech/vbnavtabs_pro/actions/' . $action . '.php');	
		}
		
		if ($action == 'main')
		{
			$show['java_delete'] = true;
		}

		$navbar = render_navbar_template(construct_navbits($navbits));	

        // Prepare copyright footer
        $templater = vB_Template::create('dbtech_vbnavtabs_footer');
        $templater->register('year', date('Y'));
        $HTML .= $templater->render();

		// Finish the main template
		$templater = vB_Template::create('dbtech_vbnavtabs');
			$templater->register_page_templates();
			$templater->register('HTML', 					$HTML);
			$templater->register('navbar', 					$navbar);
			$templater->register('pagetitle', 				$pagetitle);
			$templater->register('java_delete', 			$java_delete);
			$templater->register('template_hook', 			$template_hook);
			$templater->register('includecss', 				$includecss);
			$templater->register('headinclude_bottom',		$headinclude_bottom);
		print_output($templater->render());

	} else {
		// No permissions to view vbnavtabs
		eval(standard_error($vbphrase['dbtech_vbnavtabs_no_perm_view']));
	}

} else {
	// vbnavtabs is disabled, so let them know
	eval(standard_error($vbulletin->options['dbtech_vbnavtabs_closed_reason']));
}

/*$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$*\
<< ********************************************************************* >>
<< * Created: 19:30, Fri Nov 25th 2011                                 * >>
<< * VER: 1.0.0                                                        * >>
<< ********************************************************************* >>
\*$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$*/

?>