<?php

$mod=preg_replace('/[^a-z_]/','',$_GET['mod']);
$sub=preg_replace('/[^a-z_]/','',$_GET['sub']);
$act=preg_replace('/[^a-zA-Z_]/','',$_GET['act']);

if($act=='buttons'){
	if($sub&&$mod){
		echo"[";
		include "./modules/".$mod."/sub/".$sub."/php/buttons.php";
		echo"]";
	} elseif($mod&&!$sub){
		echo"[";
		include "./modules/".$mod."/php/buttons.php";
		 		
		if($sub=opendir ("modules/".$mod."/sub")) {
			while ($two = readdir ($sub))
			{
				if($two != '.' && $two != '..') if(file_exists("./modules/".$mod."/sub/".$two."/php/main_buttons.php")){echo ","; include "./modules/".$mod."/sub/".$two."/php/main_buttons.php";}
			}
			closedir ($sub);
		}
		echo"]";
	}
}
 elseif($act=='r_menu'){
	 if($sub&&$mod){
		echo"[";
		include "./modules/".$mod."/sub/".$sub."/php/rmenu.php";
		echo"]";
	} elseif($mod&&!$sub){
		echo"[";
		include "./modules/".$mod."/php/rmenu.php";	
		 		
		if($sub=opendir ("modules/".$mod."/sub")) {
			while ($two = readdir ($sub)) 
			{
				if($two != '.' && $two != '..') if(file_exists("./modules/".$mod."/sub/".$two."/php/main_rmenu.php")){echo ","; include "./modules/".$mod."/sub/".$two."/php/main_rmenu.php";}
			}
			closedir ($sub);
		}
		echo"]";
	}
} elseif($mod=='maintree'){
 	$main = opendir ('modules');
 	while ($one = readdir ($main))
 	{
 		if($one != '.' && $one != '..')
	 	{ 	
			if($sub=opendir ("modules/".$one."/sub")) {
				while ($two = readdir ($sub))
				{
					if($two != '.' && $two != '..') include "./modules/".$one."/sub/".$two."/php/maintree_js.php";
					
				}
				closedir ($sub);
			} 
			include "./modules/".$one."/php/maintree_js.php";	 		
		}
 	}
	closedir ($main);
} else {
	die();
}

?>
