<?php
!function_exists('html') && exit('ERR');
unset($menu_partDB,$menudb,$menu_partDB);
$base_menuName=array('base'=>'系统功能','article'=>'文章功能','member'=>'会员管理','module'=>'模块中心','other'=>'插件管理');

$menu_partDB = array(
	'base'=>array('核心设置','微信功能设置','网站常用功能管理','数据库工具','菜单管理'),
	'article'=>array('内容/栏目/评论管理','静态页生成管理','更新标签内容','专题管理','辅栏目管理'),
	'member'=>array('用户管理','权限管理'),
);

$menudb=array(
	'核心设置'=>array(
		'全局参数设置' => array('power'=>'center_config','link'=>'index.php?lfj=center&job=config'),
		'首页设置' => array('power'=>'set_comsort_index','link'=>'index.php?lfj=channel&job=edit&id=1'),
		'会员注册与登录设置' => array('power'=>'user_reg','link'=>'index.php?lfj=center&job=user_reg'),
		'缓存设置' => array('power'=>'center_cache','link'=>'index.php?lfj=center&job=cache'),
		'内容模型基本设置' => array('power'=>'article_more_config','link'=>'index.php?lfj=article_more&job=config'),
		'更新缓存/数据修复' => array('power'=>'cache_cache','link'=>'index.php?lfj=cache&job=cache'),
		'内容评论设置' => array('power'=>'comment_set','link'=>'index.php?lfj=comment&job=set'),
		'全局静态页设置' => array('power'=>'setmakeALLhtml_set','link'=>'index.php?lfj=html&job=set'),
		'系统模块管理' => array('power'=>'module_list','link'=>'index.php?lfj=module&job=list'),
		'模型管理' => array('power'=>'article_module','link'=>'index.php?lfj=article_module&job=list'),		
		'插件管理' => array('power'=>'hack_list','link'=>'index.php?lfj=hack&job=list'),
		'整合外部系统设置' => array('power'=>'blend_set','link'=>'index.php?lfj=blend&job=set'),
	),
	'微信功能设置'=>array(		
		'微信接口设置' => array('power'=>'weixin_api','link'=>'index.php?lfj=center&job=weixin_api'),			
		'微信菜单设置' => array('power'=>'appmenu','link'=>'index.php?lfj=appmenu&job=list'),
		'用户关注时回复内容' => array('power'=>'weixin_FirstReply','link'=>'index.php?lfj=weixin_autoreply&job=FirstReply'),
		'用户提问自动回复' => array('power'=>'weixin_autoreply','link'=>'index.php?lfj=weixin_autoreply&job=list'),
		'微信客服设置' => array('power'=>'weixin_kefu','link'=>'index.php?lfj=weixin_kefu&job=list'),	
		'微信聊天记录' => array('power'=>'weixin_msg','link'=>'index.php?lfj=weixin_msg&job=list'),
	),
	'网站常用功能管理'=>array(
		'友情链接管理' => array('power'=>'friendlink_mod','link'=>'index.php?lfj=friendlink&job=list'),
		'单篇文章独立页面管理' => array('power'=>'alonepage_list','link'=>'index.php?lfj=alonepage&job=list'),
		'频道独立页管理' => array('power'=>'channel_list','link'=>'index.php?lfj=channel&job=list'),
	),
	'数据库工具'=>array(
		'备份数据库' => array('power'=>'mysql_out','link'=>'index.php?lfj=mysql&job=out'),
		'数据库还原' => array('power'=>'mysql_into','link'=>'index.php?lfj=mysql&job=into'),
		'删除备份数据' => array('power'=>'mysql_del','link'=>'index.php?lfj=mysql&job=del'),
		'数据库工具' => array('power'=>'mysql_sql','link'=>'index.php?lfj=mysql&job=sql'),
	),
	'菜单管理'=>array(
		'网站头部导航菜单设置' => array('power'=>'menu_list','link'=>'index.php?lfj=guidemenu&job=list'),
		'管理员后台菜单设置' => array('power'=>'adminmenu_list','link'=>'index.php?lfj=adminguidemenu&job=list'),
		'会员中心菜单设置' => array('power'=>'membermenu_list','link'=>'index.php?lfj=memberguidemenu&job=list'),
	),
	'内容/栏目/评论管理'=>array(
		'</a><A HREF=\'index.php?lfj=sort&job=listsort&only=&mid=\' target=main>栏目管理</A> | <A HREF=\'index.php?lfj=sort&job=addsort&only=&mid=\' target=main>创建栏目</A> <a>' => array('power'=>'sort_listsort','link'=>' '),
		'内容管理<font color=#959595>(修改、删除等)</font>' => array('power'=>'artic_listartic','link'=>'index.php?lfj=artic&job=listartic&only=1&mid='),
		'评论管理' => array('power'=>'comment_list','link'=>'index.php?lfj=comment&job=list'),
		'发表<font color=#959595>(文章、图片等)</font>' => array('power'=>'artic_postnew','link'=>'index.php?lfj=post&job=postnew&only=1&mid='),
		'快速发图' => array('power'=>'artic_addpic','link'=>'index.php?lfj=artic&job=addpic'),
	),
	'静态页生成管理'=>array(
		'</a><a href=\'../do/index.php?&ch=1&MakeIndex=1\' target=\'_blank\' onclick=\"return confirm(\'你确实要把首页生成静态吗?生成静态后,如有更改其它相关设置,需要重新点击生成一次静态.才可以看到效果.\')\");\">主页静态</a> | <A HREF=\'index.php?lfj=center&job=delindex\' target=main>删除</A><a>' => array('power'=>'makeindexhtml_make','link'=>' '),
		'栏目内容静态页管理' => array('power'=>'makehtml_make','link'=>'index.php?lfj=html&job=list'),
		'专题静态页管理' => array('power'=>'spmakehtml_make','link'=>'index.php?lfj=html&job=listsp'),
		'静态网页样式设置' => array('power'=>'setmakehtml_set','link'=>'index.php?lfj=html&job=set'),
	),
	'更新标签内容'=>array(
		'首页标签设置' => array('power'=>'index_label','link'=>'../do/index.php?&ch=1&chtype=0&jobs=show'),
		'栏目/内容页标签设置' => array('power'=>'s_list_fid','link'=>'index.php?lfj=channel&job=list_fid'),
		'专题页标签设置' => array('power'=>'up_splist_fid','link'=>'index.php?lfj=special&job=list&onlyshow=label'),
	),
	'专题管理'=>array(
		'专题管理' => array('power'=>'special_list','link'=>'index.php?lfj=special&job=list'),
		'专题分类管理' => array('power'=>'spsort_listsort','link'=>'index.php?lfj=spsort&job=listsort'),
	),
	'辅栏目管理'=>array(
		'辅栏目管理' => array('power'=>'fu_sort_power','link'=>'index.php?lfj=fu_sort&job=listsort'),
		'辅栏目内容管理' => array('power'=>'fu_artic_power','link'=>'index.php?lfj=fu_artic&job=listartic'),
	),
	'用户管理'=>array(
		'用户资料管理' => array('power'=>'member_list','link'=>'index.php?lfj=member&job=list'),
		//'企业资料管理' => array('power'=>'company_list','link'=>'index.php?lfj=company&job=list'),
		'用户资料字段管理' => array('power'=>'regfield','link'=>'index.php?lfj=regfield&job=editsort'),
		'添加新用户' => array('power'=>'member_addmember','link'=>'index.php?lfj=member&job=addmember'),
	),
	'权限管理'=>array(
		'内容模型权限设置' => array('power'=>'article_group_config','link'=>'index.php?lfj=article_group&job=list'),
		'前台权限管理' => array('power'=>'group_list','link'=>'index.php?lfj=group&job=list'),
		'后台权限管理' => array('power'=>'group_list_admin','link'=>'index.php?lfj=group&job=list_admin'),
		'添加用户组' => array('power'=>'group_add','link'=>'index.php?lfj=group&job=add'),
	),

);

if(!$ModuleDB['hy_']){	//没装黄页，就没有企业功能
	unset($menudb['用户管理']['企业资料管理']);
}

@include(ROOT_PATH."data/hack.php");

if($ForceEnter||$GLOBALS[ForceEnter]){

	//强制进后台
	foreach( $menu_partDB AS $key1=>$value1){
		if($key1=='base'){
			continue;
		}
		foreach( $value1 AS $key2=>$value2){
			$menu_partDB['base'][]=$value2;
		}
	}
}else{

	if(!table_field("{$pre}module",'ifsys')){
		$db->query("ALTER TABLE `{$pre}module` ADD `ifsys` TINYINT( 1 ) NOT NULL");
	}
	//模块
	$query = $db->query("SELECT * FROM {$pre}module WHERE type=2 AND ifclose=0 ORDER BY list DESC");
	while($rs = $db->fetch_array($query)){
		if(!$rs['dirname']){
			continue;
		}
		if($rs['ifsys']){	//独立的顶部菜单
			$base_menuName[$rs['pre']]=$rs['name'];
			$menu_partDB[$rs['pre']][]=$rs['name'];
		}else{
			$menu_partDB['module'][]=$rs['name'];
		}		
		$menudb[$rs['name']]=@include(ROOT_PATH."$rs[dirname]/admin/menu.php");
		foreach($menudb[$rs['name']] AS $key=>$value){
			if(eregi('^file=',$menudb[$rs['name']][$key]['link'])){
				$menudb[$rs['name']][$key]['link']="index.php?lfj=module_admin&dirname=$rs[dirname]&".$menudb[$rs['name']][$key]['link'];

				if($menudb[$rs['name']][$key]['power']!=1){
					$menudb[$rs['name']][$key]['power']="Module_".$rs[pre].$menudb[$rs['name']][$key]['power'];					
				}
			}
			if($rs['ifsys']&&$value['sort']){
				$keyname=get_word($rs['name'],4,0).">{$value['sort']}";
				$menu_partDB[$rs['pre']][$keyname]=$keyname;
				$menudb[$keyname][$key]=$menudb[$rs['name']][$key];
				unset($menudb[$rs['name']][$key]);
				
			}
		}
	}
}


?>