<!--#include virtual="/common/lib/dbcon.asp"-->
<!--#include virtual="/common/lib/func.asp"-->
<!--#include file="config.asp"-->
<%


If is_delete <> "Y" Then Call goMessage_board("접근권한이 없습니다.", Request.ServerVariables("HTTP_REFERER"), "", "", a_num)



'//파라미터정보 *************************************************************************************
b_num		= InputValue(request("b_num"))
a_num		= InputValue(request("a_num"))
status		= InputValue(request("status"))
'//$chk		= InputValue($chk);
chk			= InputValue(request("chk"))
chk			= Split(Replace(chk, " ", ""), ",")
'//**************************************************************************************************


If is_ad_cms <> "Y" then	'//관리자가아닐때 체크

	If SESSION("pwd_chk_" & a_num & "_" & b_num) <> "ok" then

		Call locationhref("pwd.asp?prepage=dele&a_num=" & a_num & "&b_num=" & b_num & "&" & page_info)

	End if
End if


If status = "totdel" then	'//다중삭제

	For z=0 to UBound(chk)
		
		'//이미지 삭제
		SQL_I = "select b_step,b_level from " & a_tablename & " where b_num = " & trim(chk(z))

		Set rs_2 = dbcon.execute( sql_i )
		
		Do Until rs_2.eof

			b_step	= rs_2("b_step")
			b_level	= rs_2("b_level")




			If b_step = 0 and b_level = 0 then		'//일반글일때

				'//이미지 삭제
				SQL_I    = "SELECT b_file1,b_file2,b_file3,b_file4,b_file5 FROM " & a_tablename & " WHERE b_ref = " & chk(z)
				Set RS_I = Dbcon.Execute(SQL_I)

				Do Until rs_i.eof

					b_file1     = RS_I("b_file1")
					b_file2     = RS_I("b_file2")
					b_file3     = RS_I("b_file3")
					b_file4     = RS_I("b_file4")
					b_file5     = RS_I("b_file5")


					strDir		= server.mappath("/data/board/")& "\" & a_tablename & "\"
					strDir2		= server.mappath("/data/board/")& "\" & a_tablename & "\thum\"
			

					If b_file1 <> "" then call dfile(strDir,b_file1)  '삭제
					If b_file2 <> "" then call dfile(strDir,b_file2)  '삭제
					If b_file3 <> "" then call dfile(strDir,b_file3)  '삭제
					If b_file4 <> "" then call dfile(strDir,b_file4)  '삭제
					If b_file5 <> "" then call dfile(strDir,b_file5)  '삭제

					If b_file1 <> "" then call dfile(strDir,b_file1) : call dfile(strDir2,b_file1)  '삭제
					If b_file2 <> "" then call dfile(strDir,b_file2) : call dfile(strDir2,b_file2) '삭제
					If b_file3 <> "" then call dfile(strDir,b_file3) : call dfile(strDir2,b_file3) '삭제
					If b_file4 <> "" then call dfile(strDir,b_file4) : call dfile(strDir2,b_file4) '삭제
					If b_file5 <> "" then call dfile(strDir,b_file5) : call dfile(strDir2,b_file4) '삭제
				
					rs_i.movenext
				loop



				SQL = "Delete From " & a_tablename & " where b_ref = "& trim( chk(z) )
				
				dbcon.execute sql


			Else	'//답변글 일때(해당 목록만 삭제)


				'//이미지 삭제
				SQL_I	= "SELECT b_file1,b_file2,b_file3,b_file4,b_file5 FROM " & a_tablename & " WHERE b_num = " & trim(chk(z))
				Set RS_I = dbcon.execute( sql_i )

				b_file1     = RS_I("b_file1")
				b_file2     = RS_I("b_file2")
				b_file3     = RS_I("b_file3")
				b_file4     = RS_I("b_file4")
				b_file5     = RS_I("b_file5")


				strDir		= server.mappath( "/data/board/" ) &"\" & a_tablename & "\"
				strDir2		= server.mappath( "/data/board/" ) &"\" & a_tablename & "\thum\"

				If b_file1 <> "" then Call dfile(strDir,b_file1) : Call dfile(strDir2,b_file1)		'//삭제
				If b_file2 <> "" then Call dfile(strDir,b_file2) : Call dfile(strDir2,b_file2)		'//삭제
				If b_file3 <> "" then Call dfile(strDir,b_file3) : Call dfile(strDir2,b_file3)		'//삭제
				If b_file4 <> "" then Call dfile(strDir,b_file4) : Call dfile(strDir2,b_file4)		'//삭제
				If b_file5 <> "" then Call dfile(strDir,b_file5) : Call dfile(strDir2,b_file4)		'//삭제

				SQL = "Delete From " & a_tablename & " where b_ref = " & trim(chk(z))
				dbcon.execute sql

			End if
		
			rs_2.movenext
		loop
	next


Else	'//일반삭제


	'//파일 삭제
	SQL_I = "SELECT b_file1,b_file2,b_file3,b_file4, b_file5 FROM " & a_tablename & " WHERE b_num = " & b_num
	Set RS_I = dbcon.execute( sql_i )

	b_file1     = RS_I("b_file1")
	b_file2     = RS_I("b_file2")
	b_file3     = RS_I("b_file3")
	b_file4     = RS_I("b_file4")
	b_file5     = RS_I("b_file5")


	strDir		= server.mappath( "/data/board/" ) & "\" & a_tablename & "\"
	strDir2		= server.mappath( "/data/board/" ) & "\" & a_tablename & "\thum\"

	If  b_file1 <> "" then call dfile(strDir,b_file1) : call dfile(strDir2,b_file1)  '//삭제
	If  b_file2 <> "" then call dfile(strDir,b_file2) : call dfile(strDir2,b_file2) '//삭제
	If  b_file3 <> "" then call dfile(strDir,b_file3) : call dfile(strDir2,b_file3) '//삭제
	If  b_file4 <> "" then call dfile(strDir,b_file4) : call dfile(strDir2,b_file4) '//삭제
	If  b_file5 <> "" then call dfile(strDir,b_file5) : call dfile(strDir2,b_file4) '//삭제


	'//삭제하기
	sql = " DELETE FROM " & a_tablename & " WHERE b_num = " & b_num
	dbcon.execute sql

End if


ok_url = "list.asp?a_num=" & a_num & "&amp;" & page_info
Call loding("0", ok_url)


'//세션소멸....
SESSION("pwd_chk_" & a_num & "_" & b_num) = ""

%>