<?php
	define('ROOT_DIR', realpath(dirname(__FILE__)).DIRECTORY_SEPARATOR);
	define('DIR_BASE',ROOT_DIR.'base'.DIRECTORY_SEPARATOR); 
	define('DIR_DBA',ROOT_DIR.'dba'.DIRECTORY_SEPARATOR);
	define('DIR_UTILS',ROOT_DIR.'utils'.DIRECTORY_SEPARATOR);
	define('DIR_MODELS',DIR_MAIN.'models'.DIRECTORY_SEPARATOR); //model
	define('DIR_UNITS',APP_PATH.DIRECTORY_SEPARATOR); //units
	define('DIR_WIDGETS',ROOT_DIR.'components'.DIRECTORY_SEPARATOR); //widgets
	define('DIR_COMPONENTS',DIR_WIDGETS); //widgets
	define('BASEURL', BASE_URL.INDEX_PAGE);
	
	

	define('URL_ASSETS',URL_LOADER."assets/");
	define('URL_FONTS',URL_ASSETS."fonts/");
	
	define('URL_COMMON',URL_FACTORY."common/");
	define('URL_WIDGETS',URL_FACTORY."components/");
	define('URL_COMPONENTS',URL_WIDGETS);
	define('DEV_MODE',TRUE);
	
	require_once DIR_BASE."class.base.sys.php";
	require_once DIR_BASE."class.base.dbs.php";
	
	require_once DIR_BASE."class.base.utils.php";
	require_once DIR_BASE."class.base.models.php";
	require_once DIR_BASE."class.base.units.php";
	require_once DIR_BASE."class.base.skins.php";
	require_once DIR_BASE."class.base.workers.php";
	require_once DIR_BASE."class.base.components.php";
	require_once DIR_BASE."class.base.director.php";
	
	function &instantiate_class(&$class_object)
	{
		return $class_object;
	}
function fullescape($in)
	{
		$out = '';
		for ($i=0;$i<strlen($in);$i++)
		{
		$hex = dechex(ord($in[$i]));
		if ($hex=='')
			$out = $out.urlencode($in[$i]);
			else
			$out = $out .'%'.((strlen($hex)==1) ? ('0'.strtoupper($hex)):(strtoupper($hex)));
		}
		$out = str_replace('+','%20',$out);
		$out = str_replace('_','%5F',$out);
		$out = str_replace('.','%2E',$out);
		$out = str_replace('-','%2D',$out);
		return $out;
	}
	function getBetween($content,$start,$end){
		$r = explode($start, $content);
		if (isset($r[1])){
			$r = explode($end, $r[1]);
			return $r[0];
		}
		return '';
	}
	function minify_output($buffer)
	{
		
		if (!ENCRYPT_OUTPUT) return $buffer;
		if (preg_match("/\<html/i",$buffer) == 1 && preg_match("/\<\/html\>/i",$buffer) == 1) {
			$skrip= getBetween($buffer, "<!--startjs-->", "<!--endjs-->");
			if ($skrip != "") {
				$eskrip='<script language="JavaScript" type="text/javascript">document.write(unescape("'.fullescape($skrip).'"));</script>';
				$buffer=str_replace($skrip, $eskrip, $buffer);
				$buffer=str_replace("<!--startjs-->", "", $buffer);
				$buffer=str_replace("<!--endjs-->", "", $buffer);		
			}
			return $buffer;
		}
		return $buffer;
	}
?>