<?
	$addLinkString = "";
	
	$addLinkString .= (!empty($mc))?"&mc=".$mc:"";
	$addLinkString .= (!empty($table))?"&table=".$table:"";
	$addLinkString .= (!empty($board_cd))?"&board_cd=".$board_cd:"";
	$addLinkString .= (!empty($srchField))?"&srchField=".$srchField:"";
	$addLinkString .= (!empty($srchText))?"&srchText=".urlencode($srchText):"";
	$addLinkString .= (!empty($srchCate))?"&srchCate=".urlencode($srchCate):"";
	$addLinkString .= (!empty($cpage))?"&cpage=".$cpage:"";
	$addLinkString .= (!empty($srchCenter_gb))?"&srchCenter_gb=".$srchCenter_gb:"";
	$addLinkString .= (!empty($srchOrder))?"&srchOrder=".urlencode($srchOrder):"";
	
	checkFilter($title);
	checkFilter($content);

	//==================================
	$view = getBoardView($atcl_seq);
	$session_name = 'SECRET_'.$view['board_cd'].'_'.$view['atcl_seq'];

	if($bBoardAdmin){
	}else if(!empty($member['mb_seq']) && $member['mb_seq'] == $view['reg_seq']){
	}else if(!empty($_SESSION[$session_name])){	
	}else{
		alert('비밀글에 열람권한이 없습니다.');
	}
	//==================================
	$html_fg = $board['html_fg'];
	$secret_fg = ($board['bsecret_fg'] == "BSECRETFG3")?"SECRETFG01":"";
	//=====================================

	$email = (!empty($email_1) && !empty($email_2)) ? $email_1."@".$email_2 : "";
	$tel_no = (!empty($tel_no_1) && !empty($tel_no_2) && !empty($tel_no_3)) ? $tel_no_1."-".$tel_no_2."-".$tel_no_3 : "";
	$ctel_no = (!empty($ctel_no_1) && !empty($ctel_no_2) && !empty($ctel_no_3)) ? $ctel_no_1."-".$ctel_no_2."-".$ctel_no_3 : "";

	$phone_dt = (!empty($phone_ymd) && !empty($phone_h)) ? $phone_ymd." ".$phone_h : "";

	$sqlString  = "";	
	$sqlString .= " UPDATE md_board SET ";
	$sqlString .= (!empty($board_cate))?" board_cate = '$board_cate',":"";
	//$sqlString .= " ref_seq = '$ref_seq',";
	//$sqlString .= " ref_dep = '$ref_dep',";
	//$sqlString .= " ref_level = '$ref_level',";
	$sqlString .= (!empty($title))?" title = '$title',":"";
	$sqlString .= (!empty($content))?" content = '$content',":"";
	//$sqlString .= " re_content_1 = '$re_content_1',";
	//$sqlString .= " re_content_2 = '$re_content_2',";
	$sqlString .= (!empty($link_1))?" link_1 = '$link_1',":"";
	$sqlString .= (!empty($link_2))?" link_2 = '$link_2',":"";
	$sqlString .= (!empty($link_mms))?" link_mms = '$link_mms',":"";
	$sqlString .= (!empty($html_mms))?" html_mms = '$html_mms',":"";
	//관리자 화면이 아닐경우, 플래그 값 변경 불가
	if(strstr($mc,"MN")){
		//$sqlString .= (!empty($re_content))?" re_content = '$re_content',":"re_content = null,";
		$sqlString .= (!empty($html_fg))?" html_fg = '$html_fg',":"html_fg = null,";
		$sqlString .= (!empty($disp_fg))?" disp_fg = '$disp_fg',":"disp_fg = null,";
		$sqlString .= (!empty($notice_fg))?" notice_fg = '$notice_fg',":"notice_fg = null,";
		$sqlString .= (!empty($main_fg))?" main_fg = '$main_fg',":"main_fg = null,";
		$sqlString .= (!empty($best_fg))?" best_fg = '$best_fg',":"best_fg = null,";
	}
	$sqlString .= (!empty($secret_fg))?" secret_fg = '$secret_fg',":"secret_fg = null,";
	$sqlString .= (!empty($age_gb))?" age_gb = '$age_gb',":"age_gb = null,";
	$sqlString .= (!empty($center_gb))?" center_gb = '$center_gb',":"center_gb = null,";
	$sqlString .= (!empty($read_cnt))?" read_cnt = '$read_cnt',":"";
	$sqlString .= (!empty($tel_no))?" tel_no = '$tel_no',":"";
	$sqlString .= (!empty($ctel_no))?" ctel_no = '$ctel_no',":"";
	$sqlString .= (!empty($fax_no))?" fax_no = '$fax_no',":"";
	$sqlString .= (!empty($email))?" email = '$email',":"";
	$sqlString .= (!empty($age))?" age = '$age',":"";
	$sqlString .= (!empty($md_seq))?" md_seq = '$md_seq',":"";

	$sqlString .= (!empty($mb_name))?" mb_name = '$mb_name',":"";
	//$sqlString .= " mb_passwd = '$mb_passwd',";
	$sqlString .= (!empty($zipcode))?" zipcode = '$zipcode',":"";
	$sqlString .= (!empty($addr_1))?" addr_1 = '$addr_1',":"";
	$sqlString .= (!empty($addr_2))?" addr_2 = '$addr_2',":"";
	//$sqlString .= " mb_fg = '$mb_fg',";
	//$sqlString .= " stat1_gb = '$stat1_gb',";
	//$sqlString .= " stat2_gb = '$stat2_gb',";
	$sqlString .= (!empty($reg_dt))?" reg_dt = '$reg_dt',":"";
	//$sqlString .= " del_dt = '$del_dt',";

	$sqlString .= (!empty($br_cd))?" br_cd = '$br_cd',":"";

	$sqlString .= (!empty($title_color))?" title_color = '$title_color',":"";
	$sqlString .= (!empty($title_size))?" title_size = '$title_size',":"";
	$sqlString .= (!empty($title_bold))?" title_bold = '$title_bold',":"";

	$sqlString .= (!empty($email_r_fg))?" email_r_fg = '$email_r_fg',":"email_r_fg = null,";
	$sqlString .= (!empty($phone_r_fg))?" phone_r_fg = '$phone_r_fg',":"phone_r_fg = null,";
	$sqlString .= (!empty($course_fg))?" course_fg = '$course_fg'," : "";


	$sqlString .= (!empty($tmp_1))?" tmp_1 = '$tmp_1',":"";
	$sqlString .= (!empty($tmp_2))?" tmp_2 = '$tmp_2',":"";
	$sqlString .= (!empty($tmp_3))?" tmp_3 = '$tmp_3',":"";
	$sqlString .= (!empty($tmp_4))?" tmp_4 = '$tmp_4',":"";
	$sqlString .= (!empty($tmp_5))?" tmp_5 = '$tmp_5',":"";
	$sqlString .= (!empty($tmp_6))?" tmp_6 = '$tmp_6',":"";
	$sqlString .= (!empty($tmp_7))?" tmp_7 = '$tmp_7',":"";
	$sqlString .= (!empty($tmp_8))?" tmp_8 = '$tmp_8',":"";
	$sqlString .= (!empty($tmp_9))?" tmp_9 = '$tmp_9',":"";
	$sqlString .= (!empty($tmp_10))?" tmp_10 = '$tmp_10' ":"";

	$sqlString .= " upd_seq = '".$member['mb_seq']."', ";
	$sqlString .= " upd_dt = now() ";
	$sqlString .= "  Where atcl_seq = '$atcl_seq'";
	
	sql_query($sqlString);
	//===============================
	if(!empty($file_1)) $addFileString  = " file_1 = '$file_1', ";
	if(!empty($file_2)) $addFileString .= " file_2 = '$file_2', ";
	if(!empty($file_3)) $addFileString .= " file_3 = '$file_3', ";
	if(!empty($file_4)) $addFileString .= " file_4 = '$file_4', ";
	if(!empty($file_5)) $addFileString .= " file_5 = '$file_5', ";
	//===============================

	$upload = array();
	$upload = uploadFiles("md_board", $_FILES, $upload);

	deleteFiles($del_file_seq);

	InsertFiles("md_board", $atcl_seq, $upload, $addFileString, $files_memo);
	//==============================================
	updateBoardCnt($board_cd);
	
	$returnUrl = $md['script_name']."?page=$page&file=view&atcl_seq=".$atcl_seq.$addLinkString;

	goto_url($returnUrl);
?>