<?
//-- 함수. 분류 읽기 ----------------------------
function read_group($level, $uprecno){
	global $zmb, $g4;

	if($uprecno) $s_where	= "and db_up_recno='$uprecno'";
	$rs_group	= sql_query("select * from $zmb[table_builder_config] where db_level='$level' and db_menu_reg='1' $s_where order by db_rank asc, db_recno desc");

	$group_list	= array();
	$i		= 0;
	while($rd = sql_fetch_array($rs_group)) {
		$group_list[$i][recno]		= $rd[db_recno];
		$group_list[$i][level]		= $rd[db_level];
		$group_list[$i][uprecno]	= $rd[db_up_recno];
		$group_list[$i][rank]		= $rd[db_rank];
		$group_list[$i][groupname]	= $rd[db_group_name];
		$group_list[$i][groupexplain]	= $rd[db_group_explain];
		$group_list[$i][more]		= $rd[db_more];
		$group_list[$i][index_skin]	= $rd[db_index_skin];
		$group_list[$i][layout_skin]	= $rd[db_layout_skin];
		$group_list[$i][pagename]	= $rd[db_pagename];
		$group_list[$i][target]		= $rd[db_target];
		$group_list[$i][link_type]	= $rd[db_link_type];
		$group_list[$i][href]		= $rd[db_href];
		$group_list[$i][subdomain]	= $rd[db_subdomain];
		$group_list[$i][datetime]	= substr($rd[db_datetime], 5, 11);

		if($group_list[$i][link_type] == "1"){									//-- 게시판
			$group_list[$i][skin_url]	= $rd[db_layout_skin];
			$group_list[$i][board]		= $rd[db_board];
			$group_list[$i][skin_dir]	= "skin/zm.layout/";					//-- 스킨이 있는 위치
		}elseif($group_list[$i][link_type] == "2"){								//-- 페이지
			$group_list[$i][skin_url]	= $rd[db_layout_skin] . "/" . $group_list[$i][pagename];
			$group_list[$i][skin_dir]	= "skin/zm.layout/";
		}elseif($group_list[$i][link_type] == "3"){								//-- URL
			if(strlen($rd[db_href]) > 40)	$group_list[$i][skin_url]	= "...".substr($rd[db_href], strlen($rd[db_href])-40, 40);
			else							$group_list[$i][skin_url]	= $rd[db_href];
			$group_list[$i][skin_dir]	= "";
		}elseif($group_list[$i][link_type] == "0") {
			$group_list[$i][skin_dir]	= "skin/zm.index/";
		}

		$group_list[$i][go_href]		= zm_conv_url($rd[db_recno]);

		$sw		= 1;
		$group_list[$i][btnimage]	= "./img/btn_setup.gif";
		if(!$group_list[$i][href] ||  !$group_list[$i][groupname]) $sw = 0;
		//-- 인덱스
		if(($group_list[$i][link_type] == "0") && (!$group_list[$i][href] || !$group_list[$i][index_skin])) $sw = 0;
		//-- 게시판
		if($group_list[$i][link_type] == "1") {
			$table_info	= sql_fetch("select * from $g4[board_table] where bo_table='{$group_list[$i][board]}'");

			if(!$group_list[$i][href] || !$group_list[$i][layout_skin] || !$group_list[$i][board] || !$table_info[bo_include_head] || !$table_info[bo_include_tail]) $sw	= 0;
		}
		//-- 일반페이지
		if(($group_list[$i][link_type] == "2") && (!$group_list[$i][href] || !$group_list[$i][layout_skin])) $sw = 0;
		//-- URL
		if(($group_list[$i][link_type] == "3") && (!$group_list[$i][href])) $sw = 0;


		if(!$sw) $group_list[$i][btnimage]	= "./img/btn_setup_on.gif";
		
		//-- level이 99이면 회원가입
		if($group_list[$i][level] == "99") {
			if($group_list[$i][layout_skin]) {
				$group_list[$i][btnimage]	= "./img/btn_setup.gif";
			}else{
				$group_list[$i][btnimage]	= "./img/btn_setup_on.gif";
			}
		}

		$i++;
	}

	return $group_list;
}

//-- 리뉴얼용 스킨 정보 -----------------------------------------------------------------------------------
function read_skin_renewal(){
	global $zmb, $g4;

	$rs	= sql_query("select * from zm_builder_renewal_config");

	$skin_list	= array();
	while($rd = sql_fetch_array($rs)) {
		$skin_list[$rd[db_org_recno]][recno]		= $rd[db_recno];
		$skin_list[$rd[db_org_recno]][index_skin]	= $rd[db_index_skin];
		$skin_list[$rd[db_org_recno]][layout_skin]	= $rd[db_layout_skin];
		$skin_list[$rd[db_org_recno]][pagename]		= $rd[db_pagename];
		$skin_list[$rd[db_org_recno]][link_type]	= $rd[db_link_type];

		if($skin_list[$rd[db_org_recno]][link_type] == "1"){								//-- 게시판
			$skin_list[$rd[db_org_recno]][skin_url]	= $rd[db_layout_skin];
			$skin_list[$rd[db_org_recno]][skin_dir]	= "skin/zm.layout/";					//-- 스킨이 있는 위치
		}elseif($skin_list[$rd[db_org_recno]][link_type] == "2"){							//-- 페이지
			if($skin_list[$rd[db_org_recno]][pagename]) $skin_list[$rd[db_org_recno]][skin_url]	= $rd[db_layout_skin] . "/" . $skin_list[$rd[db_org_recno]][pagename];
			$skin_list[$rd[db_org_recno]][skin_dir]	= "skin/zm.layout/";
		}elseif($skin_list[$rd[db_org_recno]][link_type] == "0") {
			$skin_list[$rd[db_org_recno]][skin_dir]	= "skin/zm.index/";
		}

		$skin_list[$rd[db_org_recno]][go_href]		= zm_conv_url($rd[db_org_recno]);
	}

	return $skin_list;
}
?>