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

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

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

// Ensure this is correct
$vbulletin->userinfo['dbtech_vbsignatures_configuration'] = @unserialize($vbulletin->userinfo['dbtech_vbsignatures_configuration']);
$vbulletin->userinfo['dbtech_vbsignatures_configuration'] = (is_array($vbulletin->userinfo['dbtech_vbsignatures_configuration']) ? $vbulletin->userinfo['dbtech_vbsignatures_configuration'] : array());
foreach ((array)VBSIGNATURES::$cache['signaturestyle'] as $signaturestyleid => $signaturestyle)
{
	$vbulletin->userinfo['dbtech_vbsignatures_configuration'][$signaturestyleid]['parts'][''] = $vbulletin->userinfo['dbtech_vbsignatures_configuration'][$signaturestyleid]['parts'][0];
	unset($vbulletin->userinfo['dbtech_vbsignatures_configuration'][$signaturestyleid]['parts'][0]);
}

$vbulletin->options['dbtech_vbsignatures_pointstable'] = ($vbulletin->options['dbtech_vbsignatures_pointstable'] ? $vbulletin->options['dbtech_vbsignatures_pointstable'] : 'user');
$vbulletin->options['dbtech_vbsignatures_pointsfield'] = ($vbulletin->options['dbtech_vbsignatures_pointsfield'] ? $vbulletin->options['dbtech_vbsignatures_pointsfield'] : 'dbtech_vbsignatures_points');

if (THIS_SCRIPT != 'vbsignatures')
{
	// Show branding or not
	$show['vbsignatures_branding'] = $vbulletin->options['dbtech_vbsignatures_branding_free'] != '<(-=vBSignatures.Key.Branding.Free=-)>';
	$show['dbtech_vbsignatures_producttype'] = (VBSIGNATURES::$isPro ? ' (Pro)' : ' (Lite)');
	
	if ($show['vbsignatures_branding'])
	{
		$str = 'Customisable Signatures provided by <a href="http://www.dragonbyte-tech.com/product.php?dbtech_vbsignatures" target="_blank">vBSignatures' . ($vbulletin->options['dbtech_vbsignatures_displayversion'] ? ' v' . VBSIGNATURES::$version : '') . $show['dbtech_vbsignatures_producttype'] . '</a> - <a href="http://www.dragonbyte-tech.com" target="_blank">vBulletin Mods &amp; Addons</a> Copyright &copy; ' . date('Y') . ' DragonByte Technologies Ltd.' . (!VBSIGNATURES::$isPro AND !$vbulletin->options['dbtech_vbsignatures_nohivel'] ? ' Runs best on <a href="http://www.hivelocity.net/?utm_source=Iain%2BKidd&utm_medium=back%2Blink&utm_term=Dedicated%2BServer%2BSponsor&utm_campaign=Back%2BLinks%2Bfrom%2BIain%2BKidd" target="_blank">HiVelocity Hosting</a>.' : '');
		$vbulletin->options['copyrighttext'] = (trim($vbulletin->options['copyrighttext']) != '' ? $str . '<br />' . $vbulletin->options['copyrighttext'] : $str);
	}
}