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


<%

rootPath = server.MapPath("/")
Set UploadForm = Server.CreateObject("DEXT.FileUpload")
UploadForm.DefaultPath = rootPath&"\data\"


' 파라미터정보 *************************************************************************************
eb_pk		= InputValue(UploadForm("eb_pk"))
ebp_idx		= InputValue(UploadForm("ebp_idx"))
status		= InputValue(UploadForm("status"))
' **************************************************************************************************



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

	chk = Replace(UploadForm("chk")," ", "")
	arr_chk = Split(chk,",")

	For z=0 To UBound(arr_chk)

		sql = "Select ebp_pageimg from ebook_page where ebp_idx="&arr_chk(z)
		Set Rs = Dbcon.Execute (sql)
		ebp_pageimg = rs("ebp_pageimg")
		rs.close : Set rs = nothing


		' 이미지 삭제
		strDir		= rootPath & "\data\ebook\"&eb_pk&"\"
		strDir2	= rootPath & "\data\ebook\"&eb_pk&"\middle\"
		strDir3	= rootPath & "\data\ebook\"&eb_pk&"\small\"

		If ebp_pageimg <> "" then
			Call dfile( strDir, ebp_pageimg) ' 삭제
			Call dfile( strDir2, ebp_pageimg_org)
			Call dfile( strDir3, ebp_pageimg_org)
		End if

		' 페이지 삭제
		sql = " delete from ebook_page where ebp_idx="&arr_chk(z)
		Dbcon.execute sql
	next


Else ' 일반삭제
	
	' 삭제하기

	sql = "Select ebp_pageimg from ebook_page where ebp_idx="&ebp_idx
	Set Rs = Dbcon.Execute (sql)
	ebp_pageimg	= rs("ebp_pageimg")


	' 이미지 삭제
	strDir		= rootPath & "\data\ebook\"&eb_pk&"\"
	strDir2	= rootPath & "\data\ebook\"&eb_pk&"\middle\"
	strDir3	= rootPath & "\data\ebook\"&eb_pk&"\small\"

	If ebp_pageimg <> "" then
		Call dfile( strDir, ebp_pageimg) ' 삭제
		Call dfile( strDir2, ebp_pageimg_org)
		Call dfile( strDir3, ebp_pageimg_org)
	End if

	' 페이지 삭제
	sql = " delete from ebook_page where ebp_idx="&ebp_idx
	Dbcon.execute sql

End if

Dbcon.close : Set Dbcon = Nothing

ok_url = "write_ui.asp?eb_pk="&eb_pk
Call loding ("0", ok_url)

%>