<%
b_sdate_tmp = InputValue( UploadForm("b_sdate") )
If b_sdate_tmp = "" then
	b_sdate = b_sdate_y & "-" & Right( "0" & b_sdate_m, 2) & "-" & Right("0" & b_sdate_d, 2)
Else
	b_sdate = b_sdate_tmp
End If

b_edate_tmp = InputValue( UploadForm("b_edate") )

If b_edate_tmp = "" then
	b_edate = b_edate_y&"-"&Right(b_edate_m,2)&"-"&Right("0"&b_edate_d,2)
Else
	b_edate = b_edate_tmp
End If


'//*******************  금지단어 체크기능  ***********************
If trim(a_noword) <> "" then
	a_noword = Split(a_noword, ",")		'//제한파일..

	for z=0 To UBound( a_noword )

		iscontent = instr(b_content, a_noword(z))		'//내용에서 검색
		issubject = instr(b_subject, a_noword(z))		'//글제목에서 검색..

		if iscontent > 0 Or issubject > 0 then
			Call Back_back ( a_noword(z) & "은(는) 사용금지단어입니다. \n단어를 삭제하세요." )
		End if

	next
End if
'//*****************************************************************


If w_mode = "W" Or w_mode = "WR" then		'//저장
	
	If a_upload = "Y" then		'//첨부파일 사용일때
		
		'//폴더 없으면 새로 생성
		strDirectory		= server.mappath("/data/board/") & "\" & a_tablename& "\"
		Call FolderCreate( strDirectory )
		

		'//폴더 없으면 새로 썸네일용
		strDirectory2		= strDirectory & "thum\"
		Call FolderCreate( strDirectory2 )

		'//첨부파일체크
		for z = 1 To a_upload_len

			strDir		= strDirectory
			ext_str		= a_nofile

			'파일저장
			b_file		= eval("b_file" & z)
			

			If b_file <> "" Then

				ext_chk_arr = Split( b_file, "." )
				ext_chk = LCase( ext_chk_arr( UBound(ext_chk_arr) ) )

				If ext_chk = "jpg" Or ext_chk = "gif" then
					ww = 130
					hh = 100
					Call GD2_make_thumb( ww, hh, b_file, strDirectory, strDirectory2 )
				End if
			End if
		next

	End if


	'//ref,step,level 체크
	If b_type = "R" then	'//답변이면

		sql = "UPDATE " & a_tablename & " SET b_step = b_step+1  WHERE b_ref = " & b_ref & "  AND b_step > " & b_step
		dbcon.execute sql

		b_step		= b_step + 1
		b_level		= b_level + 1

	End if


	b_cate		= ""
	b_count		= 0
	b_look		= "Y"	'//사용/중지
	'//$b_open		= "Y"; //공개/비공개
	b_id		= SESSION("ss_m_id")
	b_regdate	= getDateFm(Now(), 3)
	b_ip		= request.ServerVariables("REMOTE_ADDR")
	b_chuchun	= 0

	If a_cate = "Y" then
		
		If b_type = "R" then	'//답변이면 //상위분류값을 넣는다..

			SQL = "SELECT b_cate, b_catename FROM " & a_tablename & " WHERE  b_num=" & b_ref
			Set rs_cate = dbcon.execute( sql )
			
			b_cate = rs_cate("b_cate")
			b_catename = rs_cate("b_catename")

			Set rs_cate = nothing

		else

			b_cate_str	= Split(b_cate_tot, ",")
			b_cate		= Trim(b_cate_str(0))
			b_catename	= Trim(b_cate_str(1))

		End if

	else

		b_cate = 0
		b_catename = ""

	End if
	
	b_c_count	= 0
	b_jumin		= SESSION("ss_m_jumin")

	R_Fields_i = "b_type, b_id, b_name, b_pwd, b_subject, b_email, b_jumin, b_phone1, b_phone2, b_phone3, b_cate, b_catename, b_noticechk, b_content, b_ip, b_count, b_look, b_open, b_ref, b_step, b_level, b_regdate, b_chuchun, b_sbjclr, b_temp1, b_temp2, b_temp3, b_temp4, b_temp5, b_temp6, b_temp7, b_keyword, b_c_count, b_zip1, b_zip2, b_addr1, b_addr2 "

	Select Case a_level
		Case "default_calendar", "schedule_sms"
			R_Fields_i = R_Fields_i & ", b_sdate, b_edate"
	End select


	If a_level = "nninc_job" Then
		R_Fields_i = R_Fields_i & ", b_temp9"
	End If

	' 첨부파일
	R_Fields_i = R_Fields_i & ", b_file1, b_file2, b_file3, b_file4, b_file5"

	Call InsertQuery ( R_Fields_i, a_tablename)

	If b_type = "N" then

		sql = "SELECT Max(b_num) as max_b_num FROM " & a_tablename
		Set rs1 = dbcon.execute( sql )

		max_b_num = rs1("max_b_num")

		sql = "UPDATE " & a_tablename & " SET b_ref = " & max_b_num & " WHERE b_num = " & max_b_num
		dbcon.execute sql

	End if

	ok_url = "list.asp?a_num=" & a_num & "&amp;" & page_info



	'일정관리sms일경우
	If a_level = "schedule_sms" Then

		If b_temp1 = "Y" Then	'문자알림 사용시
			
			tran_phone		= b_phone1 & b_phone2 & b_phone3
			RDate			= b_temp2 & " " & b_temp3 & ":" & b_temp4
			tran_callback	= "15449642"
			Msg				= "일정:" & b_sdate & vbcrlf & b_subject
			s_num			= a_num & "_" & max_b_num

			If tran_phone <> "" then	'예약발송

				Call SmsSend(tran_phone, tran_callback, Msg, RDate, s_num)

			End if

		End if

	End if


	' SMS 발송 
	If a_sendsms = "Y" Then

		rtn_url = "http://"&Request.ServerVariables("HTTP_HOST")&"/content/board/"&ok_url

		arr_bbsname = split(a_bbsname, "&gt;")
		sms_bbsname = "[남부교육지원청]"&arr_bbsname(ubound(arr_bbsname)-1)&" "

		If b_type = "N" then	'접수

			msg = sms_bbsname&"게시판에 "&now()&"에 글이 접수 되었습니다."
			If a_sendsms_addr <> "" then	'게시판 담당자에게 sms발송
				sendSms a_sendsms_addr, msg, rtn_url,""
			End If
			
		ElseIf b_type = "R" Then '답변

			sql = "SELECT b_phone1,b_phone2,b_phone3 FROM "&a_tablename&" WHERE b_ref="&b_ref&" and b_step=0 and b_level=0"
			Set rs_sms=dbcon.execute(sql)
			
			If Not rs_sms.eof And Not rs_sms.bof Then
				
				if rs_sms(0) = "010" Or rs_sms(0) = "011" Or rs_sms(0) = "016" Or rs_sms(0) = "017" Or rs_sms(0) = "018" Or rs_sms(0) = "019" Then
				
					msg = sms_bbsname&"게시판에 "&now()&"에 답변이 등록 되었습니다."
					b_phone = rs_sms(0)&rs_sms(1)&rs_sms(2)
						
					If b_phone <> "" then	'작성자(민원인)에게 sms발송
						sendSms b_phone, msg, rtn_url,""
					End If

				End If
				
			End If
			rs_sms.close : Set rs_sms = nothing
			
		End if
	End if



	' email 발송
	If a_sendmail = "Y" Then

		arr_bbsname = split(a_bbsname, "&gt;")
		sms_bbsname = "[남부교육지원청]"&arr_bbsname(ubound(arr_bbsname)-1)&" "

		If b_type = "N" Then '접수
			msg = sms_bbsname&"게시판에 "&now()&"에 글이 접수 되었습니다."
			
			If a_sendmail_addr <> "" then  '게시판 담당자에게 메일발송
				sendMail "web@dgnbe.go.kr", a_sendmail_addr, cc, bcc, msg, msg
			End If
			
		ElseIf b_type = "R" Then '답변
			sql = "SELECT b_email FROM "&a_tablename&" WHERE b_ref="&b_ref&" and b_step=0 and b_level=0"
			Set rs_mail=dbcon.execute(sql)

			If Not rs_mail.eof And Not rs_mail.bof then

				msg = sms_bbsname&"게시판에 "&now()&"에 답변이 등록 되었습니다."
				b_email = rs_mail(0)

				If b_email <> "" Then '작성자(민원인)에게 메일발송
					sendMail "web@dgnbe.go.kr", b_email, cc, bcc, msg, msg
				End if
			End If
			rs_mail.close : Set rs_mail = nothing
		End if
	End if






elseIf w_mode = "M" then	'//수정


	If a_upload = "Y" then	'//첨부파일 사용일때
		
		'//폴더 없으면 새로 생성
		strDirectory		= server.mappath("/data/board/") & "\" & a_tablename & "\"
		Call FolderCreate( strDirectory )
		

		'//폴더 없으면 새로 썸네일용
		strDirectory2		= strDirectory & "thum\"
		Call FolderCreate( strDirectory2 )


		'//------------------------------------------------------------------------------
		For z=1 To a_upload_len

			'파일저장
			b_file		= eval("b_file" & z)

			If b_file <> "" then		'//첨부파일 있으면

				strDir		= strDirectory
				strDir2		= strDirectory2

				ext_chk_arr = Split( b_file, "." )
				ext_chk = LCase( ext_chk_arr( UBound(ext_chk_arr) ) )

				If ext_chk = "jpg" Or ext_chk = "gif" then
				'//이미지파일저장
				'//*****************************************
				'//썸네일
				If a_level="nninc_tour" Then	' 대구방문의 해 - 관광정보 게시판
					ww = 166
					hh = 106
				Else
					ww = 130
					hh = 100
				End if
				Call GD2_make_thumb( ww, hh, b_file, strDirectory, strDirectory2 )

				End If
				'//*****************************************

			End if

		next

	End if
	'//------------------------------------------------------------------------------

	if a_cate = "Y" then

		If b_type = "R" then	'//답변이면

			SQL = "SELECT b_cate, b_catename FROM " & a_tablename & " WHERE b_num=" & b_ref
			Set rs_cate = dbcon.execute( sql )

			b_cate = rs_cate("b_cate")
			b_catename = rs_cate("b_catename")

		else

			b_cate_str	= Split(b_cate_tot, ",")
			b_cate		= Trim(b_cate_str(0))
			b_catename	= Trim(b_cate_str(1))
		End if

		R_Fields2 = ",b_cate, b_catename"

	End if

	R_Fields = "b_name, b_pwd, b_subject, b_email, b_phone1, b_phone2, b_phone3,  b_noticechk, b_content, b_sbjclr, b_temp1, b_temp2, b_temp3, b_temp4, b_temp5, b_temp6, b_temp7, b_keyword, b_open" & R_Fields2
	R_Fields = R_Fields & ", b_file1, b_file2, b_file3, b_file4, b_file5"
	

	Select Case a_level
		Case "default_calendar", "schedule_sms"
			R_Fields = R_Fields & ", b_sdate, b_edate"
	End select

	If a_level = "nninc_job" then		' 알림마당 > 인력풀 > 구직 (김천교육청)
		R_Fields = R_Fields & ", b_temp9 "
	End if

	If a_home = "Y" then	'//주소사용시
		R_Fields = R_Fields & ", b_zip1, b_zip2, b_addr1, b_addr2"
	End if


	Call UpdateQuery ( R_Fields, a_tablename, " where b_num=" & b_num )

	ok_url = "list.asp?a_num=" & a_num & "&amp;" & page_info


	
	'일정관리sms일경우
	If a_level = "schedule_sms" Then

		'기존 문자알람 삭제
		sql = "delete from em_tran where tran_etc2 = '" & a_num & "_" & b_num & "'"
		'Response.write sql
		'Response.end
		dbcon.execute sql 


		If b_temp1 = "Y" Then	'문자알림 사용시
			
			tran_phone		= b_phone1 & b_phone2 & b_phone3
			RDate			= b_temp2 & " " & b_temp3 & ":" & b_temp4
			tran_callback	= "15449642"
			Msg				= "일정:"& b_sdate & vbcrlf & b_subject
			s_num			= a_num & "_" & b_num

			If tran_phone <> "" then	'예약발송

				Call SmsSend(tran_phone, tran_callback, Msg, RDate, s_num)

			End if

		End if

	End if

End if


prepage = UploadForm("prepage")
If prepage <> "" Then ok_url = prepage

Call loding ("0", ok_url)

%>