<?php
// Fetch required classes
require_once(DIR . '/dbtech/vbmail/includes/class_core.php');
require_once(DIR . '/dbtech/vbmail/includes/class_cache.php');
if (intval($vbulletin->versionnumber) == 3 AND !class_exists('vB_Template'))
{
	// We need the template class
	require_once(DIR . '/dbtech/vbmail/includes/class_template.php');
}	

if (isset($this) AND is_object($this))
{
	// Loads the cache class
	VBMAIL_CACHE::init($vbulletin, $this->datastore_entries);
}
else
{
	// Loads the cache class
	VBMAIL_CACHE::init($vbulletin, $specialtemplates);
}

// Initialise forumon
VBMAIL::init($vbulletin);

//if (VBMAIL::$permissions['canview'])
//{
	$show['vbmail'] = $vbulletin->options['dbtech_vbmail_navbar'];
	$show['vbmail_ispro'] = VBMAIL::$isPro;
	if ($vbulletin->options['dbtech_vbmail_integration'] & 1)
	{
		$show['vbmail_ql'] = true;
	}
	if ($vbulletin->options['dbtech_vbmail_integration'] & 2)
	{
		$show['vbmail_com'] = true;
	}
//}

/*DBTECH_PRO_START*/
if ($vbulletin->userinfo['userid'] AND $vbulletin->userinfo['dbtech_vbmail_numreminders'])
{
	// Clear this out
	$vbulletin->db->query_write("UPDATE " . TABLE_PREFIX . "user SET dbtech_vbmail_numreminders = 0 WHERE userid = " . intval($vbulletin->userinfo['userid']));
	$vbulletin->userinfo['dbtech_vbmail_numreminders'] = 0;
}
/*DBTECH_PRO_END*/

// Show branding or not
$show['dbtech_vbmail_producttype'] = (VBMAIL::$isPro ? ' (Pro)' : ' (Lite)');
$show['vbmail_branding'] = $vbulletin->options['dbtech_vbmail_branding_free'] != base64_decode('dmJ3YXJlei5uZXQ=');

if (THIS_SCRIPT == 'vbmail' AND $show['vbmail_branding'] AND !$show['_dbtech_branding_override'])
{
	$brandingVariables = array(
		'flavour' 			=> 'Mailing Lists provided by ',
		'productid' 		=> 107,
		'utm_source' 		=> str_replace('www.', '', htmlspecialchars_uni($_SERVER['HTTP_HOST'])),		
		'utm_content' 		=> (VBMAIL::$isPro ? 'Pro' : 'Lite'),
		'referrerid' 		=> $vbulletin->options['dbtech_vbmail_referral'],
		'title' 			=> 'vBMail',
		'displayversion' 	=> $vbulletin->options['dbtech_vbmail_displayversion'],
		'version' 			=> '2.1.3 Patch Level 1',
		'producttype' 		=> $show['dbtech_vbmail_producttype']
	);

	$str = $brandingVariables['flavour'] . '
		<a rel="nofollow" href="http://www.dragonbyte-tech.com/vbecommerce.php' . ($brandingVariables['productid'] ? '?productid=' . $brandingVariables['productid'] . '&do=product&' : '?') . 'utm_source=' . $brandingVariables['utm_source'] . '&utm_campaign=product&utm_medium=' . urlencode(str_replace(' ', '+', $brandingVariables['title'])) . '&utm_content=' . $brandingVariables['utm_content'] . ($brandingVariables['referrerid'] ? '&referrerid=' . $brandingVariables['referrerid'] : '') . '" target="_blank">' . $brandingVariables['title'] . ($brandingVariables['displayversion'] ? ' v' . $brandingVariables['version'] : '') . $brandingVariables['producttype'] . '</a> - 
		<a rel="nofollow" href="http://www.dragonbyte-tech.com/?utm_source=' . $brandingVariables['utm_source'] . '&utm_campaign=site&utm_medium=' . urlencode(str_replace(' ', '+', $brandingVariables['title'])) . '&utm_content=' . $brandingVariables['utm_content'] . ($brandingVariables['referrerid'] ? '&referrerid=' . $brandingVariables['referrerid'] : '') . '" target="_blank">vBulletin Mods &amp; Addons</a> Copyright &copy; ' . date('Y') . ' DragonByte Technologies Ltd.';
	$vbulletin->options['copyrighttext'] = (trim($vbulletin->options['copyrighttext']) != '' ? $str . '<br />' . $vbulletin->options['copyrighttext'] : $str);
}