<?php

/**
* @version 2.6.7
* @package Joomla 1.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
*/

session_start();
error_reporting(0);
define( '_JEXEC', 1 );

$_SESSION['old_path'] = getcwd();

chdir('../../');

define('JPATH_BASE', getcwd() );

define( 'DS', DIRECTORY_SEPARATOR );

require_once("configuration.php");

require_once ( JPATH_BASE .DS.'includes'.DS.'defines.php' );

require_once ( JPATH_BASE .DS.'includes'.DS.'framework.php' );

$mainframe =& JFactory::getApplication('site');
$mainframe->initialise();
JPluginHelper::importPlugin('system');

$mainframe->triggerEvent('onAfterInitialise');

$mainframe->triggerEvent('onAfterRoute');
$mainframe->triggerEvent('onAfterDispatch');
 $lang =& JFactory::getLanguage();
$lang->load('com_dtregister');
		
		jimport( 'joomla.database.table' );
		$database = &JFactory::getDBO();
        require_once ( JPATH_BASE .DS.'components'.DS.'com_dtregister'.DS.'common.php' );

		
		//chdir($_SESSION['old_path']);

		global $mainframe;

		$mosConfig_live_site = JURI::base( true );

    $eventId = JRequest::getInt('id');

		$locale	= isset($conf->language)?$conf->language:'en_GB';

		$lang	=& JLanguage::getInstance($locale);

		$lang->load('com_dtregister');

// look for the selected language file - default is english

          

                       $absolute_path=JPATH_SITE . '/components/com_dtregister';

		//Check if class exists or not

		

		//Connect to database

		

		// get the message if it is enabled

		$sql = "SELECT slabId, terms_conditions_msg,terms_conditions_set FROM #__dtregister_group_event WHERE eventId='$eventId'";

		$database->setQuery($sql);

	 	$database->query();

		$row = $database->loadObjectList();

		$row = $row[0];

		if ($row->terms_conditions_set == '1'){

			$showTerms=$row->terms_conditions_msg;

		} else {

			// message not set... get the default message from config

			$sql2 = "SELECT config_value FROM #__dtregister_config WHERE config_key='terms_conditions_msg'";

			$database->setQuery($sql2);

	 		$row2 = $database->loadObjectList();

			$row2 = $row2[0];

			$showTerms=$row2->config_value;

		}
		
		$url = str_replace('/components/com_dtregister','', Juri::base()) ;
		$showTerms = preg_replace('/(?<=src=")([^"]*)(?=")/', $url."$1",$showTerms);
		$showTerms = preg_replace('/(?<=href=")([^"]*)(?=")/', $url."$1",$showTerms);
	
?>

	<table class="lbWindow">

		  <tr><td>

          	<p class="lbText"><?php echo wordwrap(str_replace('-','&ndash;',stripslashes($showTerms)),80, "\n"); ?></p>

          </td></tr>

	</table>