Location: PHPKode > projects > Mandarin CCDS > index.php
<?

define( "MMCMS_DEFAULT_LANG", 1 );
define( "MMCMS_DEFAULT_LANG_CODE", "de" );

if (1 == $_SESSION['CMS']['preview']) 
{
	define( "CMS_PREVIEW_MODE", true );
} else {
	define( "CMS_PREVIEW_MODE", false );
}

class ccdsFrontend
{


	private $config;
	private $ccdSQL;
	private $smarty;

	private $xajax;

	private $ordervar;
	private $ordertype;

	private $page;
	private $page_language_id;
	private $page_language_code;

	static function &getInstance()
	{
		static $obj;
		if (!$obj) {
			$obj = new ccdsFrontend();    
		}
		return $obj;
	}


	function __construct()
	{

		require_once( "ccds/base/ccdsConfigParser.inc.php" );
		require_once( "ccds/base/ccdsConfig.inc.php" );
		require_once( "ccds/base/ccdSQL.inc.php" );
		require_once( "ccds/base/ccdsXajax.inc.php" );

		require_once( "ccds/base/ccdsSmarty.inc.php" );
		require_once( "ccds/base/ccdsSmartyFunctions.inc.php" );

		require_once( "ccds/base/ccdsTools.inc.php" );

		require_once( "ccds/base/ccdsImageCache.inc.php" );

		require_once( "ccds/base/ccdsObjectConfig.inc.php" );
		require_once( "ccds/base/ccdsObjectHandler.inc.php" );

		require_once( "ccds/base/ccdsObject.inc.php" );
		require_once( "ccds/base/ccdsForms.inc.php" );

		$this->ObjectConfig = new ccdsObjectConfig();

		$this->ccdSQL = ccdSQL::getInstance();
		$this->config = ccdsConfig::getInstance();

		$this->smarty = ccdsSmarty::getInstance();
		$this->tools = ccdsTools::getInstance();

		$this->smarty->assign( "CMS_MEDIA_WEB", $this->config->get( 'MEDIA_WEB' ) );




		$this->smarty->default_template_handler_func = array
		(
			$this,
			'make_template'
		);

		$this->smarty->use_sub_dirs = 0;


		$this->smarty->cache_lifetime = $this->project['project_cache_lifetime'];
		$this->smarty->force_compile = $this->project['project_force_compile'];
		$this->smarty->compile_check = true;

		$this->request_uri = split( "\?", $_SERVER['REQUEST_URI'] );
		$this->query_string = split( "/", $this->request_uri[0] );

		$this->parse_request_uri();
	
	
		if ( $_GET['tpl'] != "" )
		{

			$query = "SELECT * FROM templates 
		
							WHERE tpl_id='".$_GET['tpl']."'";
			$res = $this->ccdSQL->query( $query );
			$page_tpl = $this->ccdSQL->fetch_assoc( $res );
		}else
		{
			$query = "SELECT * FROM templates 
								WHERE tpl_id='".$this->page['obj_key_tpl_id']."'";
			$res = $this->ccdSQL->query( $query );
			$page_tpl = $this->ccdSQL->fetch_assoc( $res );
		}

		$template_file = $page_tpl['tpl_dir'].$page_tpl['tpl_file'];

		$this->smarty->use_sub_dirs = 0;
		$this->smarty->compile_dir = $this->config->get( 'SMARTY_COMPILE_DIR' ).$this->project['project_dir']."/";
		$this->smarty->template_dir = $this->config->get( 'EXTENSION_DIR' );
		$this->smarty->cache_dir = $this->config->get( 'SMARTY_CACHE_DIR' ).$this->project['project_dir']."/";
		;
		$this->smarty->config_dir = $this->config->get( 'EXTENSION_DIR' );

		$this->load_class_configs();


		if ( !$_POST AND ( $this->project['project_caching'] == 1 ) AND ( ( $_SESSION['CMS']['user_id'] != "" ) AND ( $_SESSION['CMS']['user_id'] != 0 ) ) AND !CMS_PREVIEW_MODE )
		{

			$this->smarty->caching = $this->smarty->caching = $this->page['obj_cacheable'];
		}
		else
		{
			$this->smarty->caching = 0;
		}

			$this->smarty->caching = 1;

		$cache_id = serialize( $_SERVER['REQUEST_URI'] );
		$this->page['CODE'] = $this->tools->load_plugin_frontend_function( $this->page['obj_id'], $this->page );
		$current_path = array ();

		if ( ($preview_mode) OR ( !$this->smarty->is_cached( $template_file, serialize( $cache_id ) )) )
		{

			$ext_file = $this->config->get( 'EXTENSION_DIR' ).$this->project['project_dir']."/noncache.inc.php";

			if ( file_exists( $ext_file ) )
			{
				include_once( $ext_file );
			}

			$structure = $this->getStructure( $this->root['obj_id'], $this->page_language_id );

			$this->page['SUBPAGES'] = $this->getStructure( $this->page['obj_id'], $this->page_language_id );
			$this->page['ELEMENTS'] = $this->tools->getObjectElements($this->page['obj_id'],$this->page_language_id);
				
				
			$this->smarty->assign_by_ref( "page", $this->page );
			$this->smarty->assign_by_ref( "structure", $structure );
			$this->smarty->assign_by_ref( "page_language_code", $this->page_language_code );
			$this->smarty->assign_by_ref( "page_language_id", $this->page_language_id );

		}

		$this->template_file = $template_file;
		$this->cache_id = $cache_id;
		$smartyFunctions = ccdsSmartyFunctions::getInstance();
		$smartyFunctions->setPage($this->page,$this->page_language_code,$this->page_language_id);

	}

	function getPage() {
		
		return $this->page;
	}

	function getLanguageId() {
		return $this->page_language_id;
	}

	function getLanguageCode() {
		return $this->page_language_code;
	}

	function parse_request_uri()
	{

		$return = array ();
		$page_path = array ();
		$page_structure = array ();

		$request_uri = split( "\?", $_SERVER['REQUEST_URI'] );

		$query_string = split( "/", $request_uri[0] );

		$dump = array_shift( $query_string );

		list( $request_host, $port ) = split( ":", $_SERVER['HTTP_HOST'] );
		$query = "SELECT * FROM projects LEFT JOIN project_domains ON project_id = project_domain_key_project_id WHERE project_domain_name='".$request_host."'";
		$res = $this->ccdSQL->query( $query );
		$project = $this->ccdSQL->fetch_assoc( $res );

		if ( $query_string[0] != "" )
		{
			$page_language_code = array_shift( $query_string );
			$query = "SELECT * FROM languages WHERE lang_code='".$page_language_code."' AND lang_active=1";
			$res = $this->ccdSQL->query( $query );
			if ($row = $this->ccdSQL->fetch_assoc( $res )) {
				$page_language_id = $row['lang_id'];
			} else {
				
      			header('Status: 404 not found', true, 404);
						die(0);				
			}
		}

		if ( ( $page_language_code == "" ) OR ( $page_language_id == "" ) )
		{

			$query = "SELECT * FROM languages WHERE lang_id='".$project['project_domain_key_lang_id']."' AND lang_active=1";
			$res = $this->ccdSQL->query( $query );
			$row = $this->ccdSQL->fetch_assoc( $res );
			$page_language_code = $row['lang_code'];
			$page_language_id = $row['lang_id'];
		}

		if ( $query_string[0] == "" )
		{
			$query = "
										SELECT 
											* 
										FROM 
											obj_index 
										LEFT JOIN 
											obj_names 
											ON 
											(obj_name_key_obj_id=obj_id AND obj_name_key_lang_id='".$page_language_id."')
											LEFT JOIN classes ON
												obj_key_class_id = class_id
											LEFT JOIN extensions ON
												class_key_ext_id = ext_id	
										WHERE 1
										AND obj_id='".$project['project_domain_key_obj_id']."'
								";

			$res = $this->ccdSQL->query( $query );
			$page = $this->ccdSQL->fetch_assoc( $res );


			$foo = new ccdsObject($page['obj_id']);
			$page = $foo->getObject($page_language_id);			
			
			$query = "
									SELECT 
										* 
									FROM 
										obj_index 
									LEFT JOIN 
										obj_names 
										ON 
										(obj_name_key_obj_id=obj_id AND obj_name_key_lang_id='".$page_language_id."')
										LEFT JOIN classes ON
											obj_key_class_id = class_id
										LEFT JOIN extensions ON
											class_key_ext_id = ext_id	
									WHERE
										obj_id='".$this->tools->getRoot( $page['obj_id'] )."'
				";
			$res = $this->ccdSQL->query( $query );
			$root = $this->ccdSQL->fetch_assoc( $res );

			$foo = new ccdsObject($root['obj_id']);
			$obj = $foo->getObject($page_language_id);			
			$root = $obj;
			$page_path[] = $obj;

			$path = $this->tools->getRecursivePathID( $page['obj_id'] );
			foreach (($path) as $id) {
				
				$foo = new ccdsObject($id);
				$obj = $foo->getObject($page_language_id);
				$page_path[] = $obj;
			}

		}else
		{

			$query = "
									SELECT 
										* 
									FROM 
										obj_index 
									LEFT JOIN 
										obj_names 
										ON 
										(obj_name_key_obj_id=obj_id AND obj_name_key_lang_id='".$page_language_id."')
										LEFT JOIN classes ON
											obj_key_class_id = class_id
										LEFT JOIN extensions ON
											class_key_ext_id = ext_id	
									WHERE
										obj_id='".$this->tools->getRoot( $project['project_domain_key_obj_id'] )."'
				";
			$res = $this->ccdSQL->query( $query );
			$root = $this->ccdSQL->fetch_assoc( $res );

			$last_parent_obj = $root['obj_id'];

			$foo = new ccdsObject($root['obj_id']);
			$root = $foo->getObject($page_language_id);

			for ( $i = 0; $i < count( $query_string ); $i++ )
			{
				if ( $query_string[$i] != "" )
				{
					$query = "
			
			
											SELECT 
												obj1.* ,classes.*,extensions.*,objn1.*
											FROM 
												obj_index as obj1
											LEFT JOIN 
												obj_names as objn1
												ON 
												(objn1.obj_name_key_obj_id=obj1.obj_id AND objn1.obj_name_key_lang_id='".$page_language_id."')
												LEFT JOIN classes ON
													obj1.obj_key_class_id = class_id
												LEFT JOIN extensions ON
													class_key_ext_id = ext_id	
											
											
											WHERE 1
											AND ( objn1.obj_name_serialized = '".$query_string[$i]."' OR obj1.obj_link_obj_id = 
												(
											
											
											SELECT obj2.obj_id
											FROM obj_index AS obj2
											LEFT JOIN obj_names AS objn2 ON ( objn2.obj_name_key_obj_id = obj2.obj_id
											AND objn2.obj_name_key_lang_id = '".$page_language_id."' )
											LEFT JOIN classes ON obj2.obj_key_class_id = class_id
											LEFT JOIN extensions ON class_key_ext_id = ext_id
											WHERE 1
											AND (
											objn2.obj_name_serialized = '".$query_string[$i]."'
											AND obj2.obj_id=obj1.obj_link_obj_id
											)
											
												)
											) 
											
											AND obj1.obj_parent_obj_id='".$last_parent_obj."'
											
			
										";

					if ( $i == 0 )
						$query .= " AND obj1.obj_parent_obj_id='".$root['obj_id']."'";

					$res = $this->ccdSQL->query( $query );

					if ( $row = $this->ccdSQL->fetch_assoc( $res ) )
					{
						$obj = new ccdsObject($row['obj_id'],$row['obj_key_class_id'],$row['obj_key_project_id']);
						$row = $obj->getObject($page_language_id);
						$page_path[] = $row;
						
						$page = $row;
						$last_parent_obj = $row['obj_id'];
					}else
					{
      			
						header("HTTP/1.0 404 Not Found");
						die(0);
	
					}
				}
			}
		} // END IF querystring[0] == ""
		
		$page['PATH'] = $page_path;
		$this->page = $page;
		$this->root = $root;
		$this->page_path = $page_path;
		$this->project = $project;
		$this->page_language_id = $page_language_id;
		$this->page_language_code = $page_language_code;
	}

	//****************************************************************************************************************************

	function load_class_configs()
	{

		$query = "SELECT * FROM classes 
							LEFT JOIN extensions 
							ON class_key_ext_id=ext_id
							LEFT JOIN projects ON
							ext_key_project_id = project_id
		
		
		";
		$res = $this->ccdSQL->query( $query );

		while ( $row = $this->ccdSQL->fetch_assoc( $res ) )
		{
			$file = $this->config->get( 'EXTENSION_DIR' ).$row['project_dir']."/".$row['ext_dir']."/".$row['class_dir']."/lang/".$this->page_language_code.".conf";

			if ( file_exists( $file ) )
			{
				$this->smarty->config_load( $file );
			}
		}
	}
	//****************************************************************************************************************************


	//****************************************************************************************************************************

	function getTemplate( $tpl_name )
	{

		$query = "SELECT * FROM templates WHERE tpl_name='".$tpl_name."' AND tpl_key_project_id='".$this->project['project_id']."'";
		$res = $this->ccdSQL->query( $query );
		$tpl = $this->ccdSQL->fetch_assoc( $res );

		$tpl_content = file_get_contents( $this->config->get( 'EXTENSION_DIR' ).$tpl['tpl_dir'].$tpl['tpl_file'] );

		$tpl_date = filectime( $this->config->get( 'EXTENSION_DIR' ).$tpl['tpl_dir'].$tpl['tpl_file'] );

		if ( $tpl_date == false )
			$tpl_date = time();

		return array
		(
			$tpl_content,
			$tpl_date
		);
	}

	//****************************************************************************************************************************

	function is_in_tree( $obj_id )
	{
		
		foreach ($this->page_path as $obj) 
			if ($obj['obj_id'] == $obj_id) return true;

		return false;
	}


	//****************************************************************************************************************************



	// -------------------------------------------------------------------------------------------------------------------

	function is_in_tree_recursive( $obj_id, $destination )
	{

		$path = $this->tools->getRecursivePath( $destination );

		foreach ( $path as $obj )
		{
			if ( $obj['obj_id'] == $obj_id )
				return true;
		}

		return false;
	}

	//****************************************************************************************************************************

	function getContent( $obj_id, $language_id )
	{

		$elements = array ();
		$query = "
								SELECT 
									* 
								FROM 
									obj_index 
		";

		if ( !CMS_PREVIEW_MODE )
		{
			$query .= "
									STRAIGHT_JOIN
										obj_index_public ON
										(
											objp_key_obj_id=obj_id
											AND
											objp_key_lang_id='".$language_id."'
										)
			";
		}
		$query .= "
								LEFT JOIN 
									obj_names 
									ON 
									(obj_name_key_obj_id=obj_id AND obj_name_key_lang_id='".$language_id."')
								LEFT JOIN
									classes ON 
									(obj_key_class_id=class_id)
								LEFT JOIN templates ON
									(obj_key_tpl_id=tpl_id)
								WHERE 1
								AND obj_parent_obj_id='".$obj_id."'
								AND obj_deleted=0
								AND (
									(obj_expire=0) 
										OR  (
											obj_expire=1 
											AND obj_expire_start <= '".time()."'
											AND obj_expire_end >= '".time()."'
										)
								)							
								ORDER BY obj_position
							";

		$res = $this->ccdSQL->query( $query );

		while ( $row = $this->ccdSQL->fetch_assoc( $res ) )
		{
			$object = new ccdsObject( $row['obj_id'] );
			$details = $object->getObject( $language_id );
			$elements[] = $details;
		}
		$this->ccdSQL->free_result( $res );

		return $elements;
	}

	//*************************************************************************************************************************


	//****************************************************************************************************************************
	//** Auslesen des Menübaums ab dem ROOT Objekt
	//****************************************************************************************************************************

	//****************************************************************************************************************************

	function serialize_structure_backend( $obj_id, $language_id, $last_obj = "/" )
	{
		$pages = array ();
		$query = "SELECT * FROM obj_index 
							 LEFT JOIN obj_names ON
							 (obj_name_key_obj_id = obj_id AND obj_name_key_lang_id='".$language_id."')
								LEFT JOIN classes ON obj_key_class_id = class_id
						WHERE obj_id='".$obj_id."'  AND class_name<>'ROOT'
						
						order by obj_position";
		$res = $this->ccdSQL->query( $query );

		if ( $this->ccdSQL->num_rows( $res ) > 0 )
		{
			while ( $row = $this->ccdSQL->fetch_assoc( $res ) )
			{

				$return = $this->serialize_structure_backend( $row['obj_parent_obj_id'], $language_id, $last_obj.$row['obj_name_serialized']."/" );

				if ( $return != false )
				{
					$pages += $return;
				}
				$row['obj_path'] = $last_obj.$row['obj_name_serialized'];
				$pages[$row['obj_id']] = $row;
			}
			return $pages;
		}else
		{
			return false;
		}
	}


	/* ----------------------------------------------------------------------------------------- */

	function getStructureDB( $root_id, $language_id, $is_navi = true, $is_public = true )
	{

		$pages = array ();

		$query = "SELECT 
							obj1.obj_id,
							obj1.obj_parent_obj_id, 
							obj1.obj_link_obj_id,
							obj1.obj_key_class_id,
							obj1.obj_is_navi,
							clas1.*,
							tpl1.*,
							objn1.*,
		
							obj2.obj_id as obj_id2,
							obj2.obj_parent_obj_id as obj_parent_obj_id2, 
							clas2.class_id as class_id2,
							clas2.class_name as class_name2,
							tpl2.tpl_file as tpl_file2,
							tpl2.tpl_dir as tpl_dir2,
							tpl2.tpl_id as tpl_id2,


							objn2.obj_name_name AS obj_name_name2,
							obj2.obj_is_navi,
							count(obj3.obj_id) as anzahl							
			
						
								FROM obj_index as obj1
					";
					if ($is_public) {
						$query .="
								STRAIGHT_JOIN obj_index_public as objp1
								ON (
									objp1.objp_key_obj_id = obj1.obj_id
									AND
									objp1.objp_key_lang_id='".$language_id."'
								)
						";
					}
					$query .="
									 LEFT JOIN
										classes as clas1 ON 
										(obj1.obj_key_class_id=clas1.class_id)
									LEFT JOIN templates tpl1 ON
										(obj1.obj_key_tpl_id=tpl1.tpl_id)
									LEFT JOIN obj_names objn1 ON (
										objn1.obj_name_key_obj_id = obj1.obj_id AND
										objn1.obj_name_key_lang_id='".$language_id."'
									)


								LEFT OUTER JOIN obj_index as obj3 ON (
									obj1.obj_id = obj3.obj_parent_obj_id
								)								


								LEFT OUTER JOIN obj_index as obj2 ON (
									obj1.obj_link_obj_id = obj2.obj_id
								)
								";
			if ($is_public) {
			$query .="		
								LEFT JOIN obj_index_public as objp2
								ON (
									objp2.objp_key_obj_id = obj2.obj_id
									AND
									objp2.objp_key_lang_id='".$language_id."'
								)
								";
			}
				$query .= " 
									LEFT JOIN
										classes as clas2 ON 
										(obj2.obj_key_class_id=clas2.class_id)
									LEFT JOIN templates tpl2 ON
										(obj2.obj_key_tpl_id=tpl2.tpl_id)
									LEFT OUTER JOIN obj_names objn2 ON (
										objn2.obj_name_key_obj_id = obj2.obj_id AND
										objn2.obj_name_key_lang_id='".$language_id."'
									)
		
		
							WHERE 1
							AND obj1.obj_no_structure=0 
							AND obj1.obj_parent_obj_id='".$root_id."' 
							AND 
							 obj1.obj_deleted=0
							";

		if ( $is_navi )
		{
			$query .= " AND obj1.obj_is_navi=1 ";
		}

		if ( $is_public )
			$query .= " 
										AND (
											(obj1.obj_expire=0) 
												OR  (
													obj1.obj_expire=1 
													AND obj1.obj_expire_start <= '".time()."'
													AND obj1.obj_expire_end >= '".time()."'
												)
										)								
				 ";
			$query .= "
						 		GROUP BY obj1.obj_id
			";

		$query .= " order by obj1.obj_position";
		$res = $this->ccdSQL->query( $query );

		if ( $this->ccdSQL->num_rows( $res ) > 0 )
		{
			while ( $row = $this->ccdSQL->fetch_assoc( $res ) )
			{
				$counter++;
				$tmp = array ();

				$tmp['obj_id'] = $row['obj_id'];
				$tmp['class_name'] = $row['class_name'];
				$tmp['class_id'] = $row['class_id'];
				$tmp['tpl_dir'] = $row['tpl_dir'];

				$tmp['tpl_name'] = $row['tpl_name'];
				$tmp['tpl_file'] = $row['tpl_file'];
				$tmp['tpl_dir'] = $row['tpl_dir'];
				$tmp['obj_name_name'] = $row['obj_name_name'];

				if ( $row['obj_link_obj_id'] > 0 )
				{
					if ( $tmp['obj_key_tpl_id'] == 0 )
					{
						$tmp['tpl_name'] = $row['tpl_name2'];
						$tmp['tpl_file'] = $row['tpl_file2'];
						$tmp['tpl_dir'] = $row['tpl_dir2'];
					}
					$tmp['obj_name_name'] = $row['obj_name_name2'];
					$tmp['obj_attributes'] = $row['obj_attributes2'];
				}
				if ($row['anzahl'] > 0)
				{
				 $return = $this->getStructureDB( $row['obj_id'], $language_id, $is_navi, $is_public );
					if ( $return != false )
					{
						$tmp['SUBPAGES'] = $return;
					}
				}
				$pages[] = $tmp;
			}
			$this->ccdSQL->free_result( $res );
			return $pages;
		}else
		{
			return false;
		}
	}

	/* ----------------------------------------------------------------------------------------- */

	function getArrCount( $arr, $depth = 1 )
	{
		if ( !is_array( $arr ) || !$depth )
			return 0;

		$res = count( $arr );

		foreach ( $arr as $in_ar )
			$res += $this->getArrCount( $in_ar, $depth - 1 );

		return $res;
	}

	/* ----------------------------------------------------------------------------------------- */

  function getSubStructure( $obj_id, $structure, $path ) 
  {
		foreach ($structure as $value) {
			if ($obj_id == $value['obj_id']) {
				return is_array($value['SUBPAGES']) ? $value['SUBPAGES'] : array();
			}
			elseif (in_array($value['obj_id'],$path) && is_array($value['subpages']) ) 
				return $this->getSubStructure($obj_id,$value['SUBPAGES'],$path);
		}
  	return array();
  }
	/* ----------------------------------------------------------------------------------------- */

	function getStructure( $root_id, $language_id, $is_navi = true, $is_public = true )
	{
		$cache_file = $this->smarty->cache_dir."structure".$language_id."_".$root_id.".cache";

		if ( file_exists( $cache_file ) AND ( $this->project['project_structurecache'] == 1 ) AND !CMS_PREVIEW_MODE )
		{
			$serialized = file_get_contents( $cache_file );
			$structure = unserialize( $serialized );
			unset($serialized);
		}else
		{
			$structure = &$this->getStructureDB( $root_id, $language_id, $is_navi, $is_public );

			if ( $this->project['project_structurecache'] == 1 )
			{
				$serialized = serialize( $structure );
				file_put_contents( $cache_file, $serialized );
			}
		}

		return $structure;
	}
	//****************************************************************************************************************************

	function make_template( $resource_type, $resource_name, &$template_source, &$template_timestamp, &$smarty_obj )
	{
		if ( $resource_type == 'file' )
		{
			if ( !is_readable( $resource_name ) )
			{
				list( $template_source, $template_timestamp ) = $this->getTemplate( $resource_name );

				if ( !$template_timestamp )
					$template_timestamp = time();
				return true;
			}else
			{
				return false;
			}
		}else
		{
			return false;
		}
	}


	// -------------------------------------------------------------------------------------------------------------------

	//------------------------------------------------------------------------------------------------------------------------------------


	function run()
	{
		if (CMS_PREVIEW_MODE) 
		{
			
			$CMS_FRONTEND_EDIT = "";
			$CMS_FRONTEND_EDIT .= "
			<script type='text/javascript' src='/ccds/js/hijack.js' charset='UTF-8'></script>
			<link href='/ccds/styles/frontend.css' rel='stylesheet' type='text/css' />

			";
	
			$CMS_FRONTEND_EDIT .= "
				<script type=\"text/javascript\">

					var CMS_PAGE_OBJ_ID = '".$page['obj_id']."';
					var CMS_PAGE_LANGUAGE_ID = '".$page_language_id."';

				</script>
			";
			
			$this->smarty->assign("CMS_FRONTEND_EDIT",$CMS_FRONTEND_EDIT);
		}

		$this->smarty->display( $this->template_file, serialize( $this->cache_id ) );
		

		$foo = $this->ccdSQL->getStats();
		if (1 == $_GET['debug']) {
			print "\n<br />\n Queries: ".$foo."\n<br />\n";
			
			$bytes = memory_get_peak_usage();
			$size = $this->tools->formatBytes($bytes);
			print "\n<br />\nMemory Usage: ".$size;
		}
	}
}

$ccds = ccdsFrontend::getInstance();

function is_in_tree( $obj_id )
{
	global $ccds;
	return $ccds->is_in_tree( $obj_id );
}

$ccds->run();
Return current item: Mandarin CCDS