<?php
	!defined('DIRCMS_MANAGE') && exit('Access Denied!');
	header("Cache-Control: no-cache, must-revalidate");
	$module=trim($module)?trim($module):'index';
	$module=in_array($module,array('link','ads','form','plus','notice','other','guestbook'))?'other':$module;
	$module=in_array($module,array('database','system'))?'system':$module;
	$channel_r=$mymenu=$menu=array();
	$r=cache_read('module.cache.php',DIRCMS_ROOT.'data/cache_module/');
	$syspriv=$r['system']['roleid']; 
	foreach($r as $_r)
	{
		if(!$_r['disabled'] && in_array($roleid,$_r['roleid']))$mymenu[]=$_r['modulemurl'];
		if($_r['istop'] && !$_r['disabled'] && in_array($roleid,$_r['roleid']))$menu[]=$_r['modulemurl'];
	}
	
	if(!in_array($module,$mymenu) && $module!='index' && $module!='html')exit('<script language="javascript">{self.top.location.href="'.ADMIN_FILE.'?file=login";}</script>');

	$category=array();
	$r=cache_read('parent.cache.php',DIRCMS_ROOT.'data/cache_category/');
	foreach($r as $_r)
	{
		if($_r['isshow'] && (in_array($_r['id'],$_categorypriv) || $_roleid==1))$category[]=$_r;
	}
	if($module=='content')
	{
		$finalcatid=cache_read('finalcatid.cache.php',DIRCMS_ROOT.'data/cache_category/');
		function menutree($catid)
		{
			global $finalcatid,$_roleid,$_categorypriv;
			//$_categorypriv=cache_read('admin'.$_userid.'_categorypriv.inc.php',DIRCMS_ROOT.'data/cache_admin/');
			$r=cache_read('parent'.$catid.'.cache.php',DIRCMS_ROOT.'data/cache_category/');
			if($r)
			{
				echo '<span id="cat_span_'.$catid.'" style="display:none">';
				foreach($r as $_r)
				{
					if(in_array($_r['id'],$_categorypriv) || $_roleid==1)
					{
						if($_r['ispage'])
						{
							$url='?file=content&action=page_edit&id='.$_r['id'];
							$target=" target='main'";
						}
						else if(in_array($_r['id'],$finalcatid))
						{
							$url='?file=content&action=manage&catid='.$_r['id'];
							$target=" target='main'";
						}
						else
						{
							$url='javascript:show_small_catmenu('.$_r['id'].');';
							$target="";
						}
						echo '<li id="cat_li_'.$_r['id'].'" class="'.($_r['ispage']?'page_li':'minus_li').'" style="margin-left:'.($_r['grade']*8).'px"><a href="'.$url.'"'.$target.'>'.$_r['categoryname'].'</a></li>';
						menutree($_r['id']);
					}
				}
				echo '</span>';
			}
			else
			{
				return false;
			}
		}
	}
	
	include admin_tlp('left_'.$module);
?>