<?php

class maintree {
	
	public function __construct(){
		global $err;
		
		$act=preg_replace('/[^a-z_]/','',$_GET['act']);
		if($act){
			call_user_func(array(&$this,$act));
		} 
	}	


	public function get(){
		global $DB;
		$arr=array();
		$k=0;
 		$main = opendir ('modules');
 		while ($one = readdir ($main))
 		{
		if($one != '.' && $one != '..')
			 {
			 	if($mod=opendir ("modules/".$one."/sub")) {
					$i=0;
			 		while ($two = readdir ($mod))
			 		{	
					if($two != '.' && $two != '..')	if(file_exists("./modules/".$one."/sub/".$two."/php/maintree.php"))require "./modules/".$one."/sub/".$two."/php/maintree.php";
			 		}
					closedir ($mod);
			 	} 
				if(file_exists("./modules/".$one."/php/maintree.php")) require "./modules/".$one."/php/maintree.php";			 		
			 }
		}
		closedir ($main);
		
		$arr[]=array(
				"id"=>"{object: 'main'}",
				"text"=>"Главное меню",
				"cls"=>"forum-ct",
				"expanded"=>true,
				"children"=>$arr_t
		);
		
		echo json_encode($arr);
	}	
}

?>