<?php
$startTime = microtime(true);
error_reporting(E_ALL ^ E_NOTICE ^ E_STRICT);
session_start();

include 'functions.php';


$CONFIG = array(
'website-title' => 'Creyz | Gaming',
'template' 		=> 'main',
'webAddress' => 'http://91.121.0.30:83/gas/',
'reCAPTCHA_publicKey' => '6LcKuO8SAAAAANBaSttrYwCAF9dIa2AzwMjnuKgt',
'reCAPTCHA_privateKey' => '6LcKuO8SAAAAACdxzPHc8okhqe7DLg5--rmBG3Jm',

'db_conn' => null,
'db_host' => 'WIN-MO721C2QTPM\SQLSERVER',
'db_user' => 'sa',
'db_pass' => 'KaitoHKServer2016',
'db_accountDB' => 'Account',
'db_itemmallDB' => 'ItemMall',
'db_characterDB' => 'World00_Character',

'inactiveTimeBeforeLogout' => 600 /*43200 seconds = 12 hours*/,
'registerEnabled' => true
);
setSESSIONifnotyet();
if(isset($_GET['RaF']) && strlen($_GET['RaF'])>=32 && strlen($_GET['RaF']) <=40 && preg_match("/[a-f0-9]+/", $_GET['RaF']))
{
	$_SESSION['USER']['RaF'] = $_GET['RaF'];
	header('Location: '.$CONFIG['webAddress']);
}

$ERRORS = array('login' => array(), 'register' => array());

initDB() or die('Failed to connect to database.');
if(strpos(strtolower($_GET['page']),'logout')!==false)
{
	cleanLogin();
	header('Location: '.$CONFIG['webAddress']);
}
initUSER();


//switch(strtolower((substr($_GET['page'], -1) == '/')?substr($_GET['page'],0,strlen($_GET['page'])-1):$_GET['page']))
$switchPage = linkActive_forSwitch($_GET['page']);
include loadTpl(str_replace('/','.',$switchPage));

/*switch($switchPage)
{
	case 'account':
		loadTpl('account');
		break;
	case 'account/redeem':
		loadTpl('account.redeem');
		break;
	case 'account/purchasehistory':
		loadTpl('account.purchasehistory');
		break;
	case 'account/donationhistory':
		loadTpl('account.donationhistory');
		break;
	case 'account/settings':
		loadTpl('account.settings');
		break;
	case 'store':
		loadTpl('store');
		break;
	default:
		loadTpl('index');
		//include '_index.php';
		break;
}*/

closeDB();
?>