<?php

/**
* @version 2.8.17
* @package Joomla 2.5
* @subpackage DT Register
* @copyright Copyright (C) 2006 DTH Development
* @copyright contact dthdev@dthdevelopment.com
* @license http://www.gnu.org/copyleft/gpl.html GNU/GPL
*/
//set_error_handler("errorHandler1");
//register_shutdown_function("shutdownHandler1");
//$session = JFactory::getSession();
	//$session->destroy();
	
function errorHandler1($error_level, $error_message, $error_file, $error_line, $error_context)
{
$error = "lvl: " . $error_level . " | msg:" . $error_message . " | file:" . $error_file . " | ln:" . $error_line;
switch ($error_level) {
    case E_ERROR:
    case E_CORE_ERROR:
    case E_COMPILE_ERROR:
    case E_PARSE:
        log3($error, "fatal");
        break;
    case E_USER_ERROR:
    case E_RECOVERABLE_ERROR:
        log3($error, "error");
        break;
    case E_WARNING:
    case E_CORE_WARNING:
    case E_COMPILE_WARNING:
    case E_USER_WARNING:
        log3($error, "warn");
        break;
    case E_NOTICE:
    case E_USER_NOTICE:
        log3($error, "info");
        break;
    case E_STRICT:
        log3($error, "debug");
        break;
    default:
        log3($error, "warn");
}
}

function shutdownHandler1() //will be called when php script ends.
{
$lasterror = error_get_last();
switch ($lasterror['type'])
{
    case E_ERROR:
    case E_CORE_ERROR:
    case E_COMPILE_ERROR:
    case E_USER_ERROR:
    case E_RECOVERABLE_ERROR:
    case E_CORE_WARNING:
    case E_COMPILE_WARNING:
    case E_PARSE:
        $error = "[SHUTDOWN] lvl:" . $lasterror['type'] . " | msg:" . $lasterror['message'] . " | file:" . $lasterror['file'] . " | ln:" . $lasterror['line'];
        log3($error, "fatal");
}
}

function log3($error, $errlvl)
{
  echo "<br/>".$error;
}
header('Content-Type: text/html; charset=utf-8');
global $mainframe;
defined( 'JPATH_BASE' ) or die( 'Direct Access to this location is not allowed.' );
if (!defined("DT_COM_COMPONENT")){

	define("DT_COM_COMPONENT","com_dtregister");

	define("DT_COMPONENT",str_replace("com_","",DT_COM_COMPONENT));

}

if(isset($_REQUEST['cdcaptcha']) && $_REQUEST['cdcaptcha']== 'getScript'){
		
		exit;
}
$db = JFactory::getDbo();
$query = "SET session SQL_BIG_SELECTS = 1";
//$query = "FLUSH Tables;";
$db->setQuery($query);
$db->query();
include_once(JPATH_COMPONENT_ADMINISTRATOR.DS.'lib'.DS.'defines.php');

require_once JPATH_BASE.'/components/com_content/helpers/route.php';
require_once (JPATH_ADMINISTRATOR.DS.'includes'.DS.'toolbar.php'); 
// In Joomla 1.6 JComponentHelper::getParams(JEV_COM_COMPONENT) is a clone so the menu params do not propagate so we force this here!
if (JVersion::isCompatible("1.6.0")){
	$newparams	= JFactory::getApplication('site')->getParams();
	// Because the application sets a default page title,
	// we need to get it from the menu item itself
	$menu = JFactory::getApplication()->getMenu()->getActive();
	if ($menu) {
		$newparams->def('page_heading', $newparams->get('page_title', $menu->title));
	}
	else {
		$params = JComponentHelper::getParams("com_dtregister");
		$newparams->def('page_heading', $params->get('page_title'));
	}
	$component =& JComponentHelper::getComponent("com_dtregister");
	$component->params =& $newparams;	
	
}

if($controller = JRequest::getWord('controller','event')) {

	$path = JPATH_COMPONENT.DS.'controllers'.DS.$controller.'.php';

	if (file_exists($path)) {

		require_once $path;

	} else {

	    $controller = 'event';

	    $path = JPATH_COMPONENT.DS.'controllers'.DS.$controller.'.php';

		require_once $path;

	}

}
//DT_Session::clearAll();
$classname= ucfirst(DT_COMPONENT)."Controller".ucfirst($controller);
$task = JRequest::getVar( 'task' );
$cart = JRequest::getVar('cart','');
$controllerObj = new $classname();

global $registrant_list;
$registrant_list++;
// Perform the Request task
$controllerObj->execute( JRequest::getVar( 'task' ) );

// Redirect if set by the controller

$controllerObj->redirect();
if(isset($_REQUEST['clear'])) {
   DT_Session::clearAll();
  
}
if(!(isset($_REQUEST['tmpl']) || isset($_REQUEST['no_html']) || isset($_REQUEST['format']))){
	   // pr("count ==> ".count(DT_Session::get('register.User')));
	   // DT_Session::clearAll('');
 	   /* echo "<pre>";
		$session = JFactory::getSession();
		 $DTregister = $session->get('DTH',null,'dtregister');
	$data = $session->getData();
	 print_r($data);*/
	  // print_r(get_class_methods($data));
	    //print_r($_SESSION['__dtregister']['DTH']);
	   // echo "</pre>";
}
//die;
?>