<?php
	!defined('DIRCMS_MANAGE') && exit('Access Denied!');
	$r=cache_read('module.cache.php',DIRCMS_ROOT.'data/cache_module/');
	$r=$r['template']['roleid']; 
	if(!in_array($_roleid,$r) && $_userid!=ADMIN_FOUNDERS)showmsg_nourl('您没有该操作的权限!');
	$action=empty($action)?'manage':trim($action);

	$c=new cache();
	require_once(DIRCMS_ROOT.'include/select.class.php');
	$s=$select=new select();
	switch($action)
	{
		case 'category':
			$categoryselect=$select->getSelect('categoryid','按变量读取',DB_PRE.'category',true,'categoryname','isshow=1 AND ispage=0');
			include admin_tlp('tag_category');
			break;
		case 'edit':
			if(isset($do_submit) && $do_submit)
			{
				$content=str_replace(urldecode($content),stripslashes($mcontent),file_get_contents('template/'.TLP_NAME.'/'.$tlpname.'.html'));
				file_put_contents('template/'.TLP_NAME.'/'.$tlpname.'.html',$content);
				showmsg('操作成功!');
			}
			$content=stripslashes(stripslashes(trim(urldecode($content))));
			$tlp=trim($tlp);
			include admin_tlp('edit_tag_tlp');
			break;
		case 'edit_yp':
			if(isset($do_submit) && $do_submit)
			{
				$content=str_replace(urldecode($content),stripslashes($mcontent),file_get_contents('template/comtmp/'.$path.'/'.$tlpname.'.html'));
				file_put_contents('template/comtmp/'.$path.'/'.$tlpname.'.html',$content);
				showmsg('操作成功!');
			}
			$content=stripslashes(stripslashes(trim(urldecode($content))));
			$tlp=trim($tlp);
			include admin_tlp('edit_tag_tlp');
			break;
		case 'area':
			$r=cache_read('area.cache.php',DIRCMS_ROOT.'data/cache/');
			$areaselect=$select->getSelect('areaid','一级地区',DB_PRE.'area',true,'area');
			include admin_tlp('tag_area');
			break;
		case 'co_type':
			$r=cache_read('member_type.cache.php',DIRCMS_ROOT.'data/cache/');
			$typeselect=$select->getSelect('typeid','顶级类型',DB_PRE.'member_type',true,'type');
			include admin_tlp('tag_co_type');
			break;
		case 'content':
			$posid_select='<select name="tag[posid]" id="posid"><option value="0">不限推荐位</option>';
			$r=cache_read('posid.cache.php',DIRCMS_ROOT.'data/cache/');
			if($r)foreach($r as $__r)
			{
				$posid_select.='<option value="'.$__r['id'].'">'.$__r['posname'].'</option>';
			}
			$posid_select.='</select>';

			$s->getOption(0,DB_PRE.'category','categoryname','isshow=1 AND ispage=0');
			$catid_select='<select  name="tag[catid]" id="catid" style="width:150px"><option value="$catid">根据当前栏目读取</option><option value="all">不限栏目</option>';
			$catid_select.=$s->select;
			$catid_select.='</select>';
			include admin_tlp('tag_content');
			break;
		case 'member':
			$modelid_select='<select id="modelid"><option value="0">选择会员模型</option>';
			$r=cache_read('cache_membermodel.cache.php',DIRCMS_ROOT.'data/cache_model/');
			if($r)foreach($r as $_r)
			{
				$modelid_select.='<option value="'.$_r['name'].'">'.$_r['modelname'].'</option>';
			}
			$modelid_select.='</select>';

			include admin_tlp('tag_member');
			break;
		case 'link':
			include admin_tlp('tag_link');
			break;
		case 'notice':
			include admin_tlp('tag_notice');
			break;		
		case 'co_news':
			include admin_tlp('tag_co_news');
			break;
		case 'co_product':
			include admin_tlp('tag_co_product');
			break;
		case 'co_coupon':
			include admin_tlp('tag_co_coupon');
			break;
		case 'co_guestbook':
			include admin_tlp('tag_co_guestbook');
			break;	
		case 'comment':
			include admin_tlp('tag_comment');
			break;
		default:
			showmsg_nourl('错误的参数!');
			break;
	}
?>