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

<!--#include file = "config.asp" -->

<%

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


R_Fields = "b_l_num, info_url, b_l_code, b_l_img, b_l_url, b_l_chk, b_l_sdate, b_l_edate, b_l_subject, b_l_memo, b_l_wdate, b_l_mdate, b_l_img_del, b_l_img2"
R_Fields = R_Fields & ", b_l_sdate_y, b_l_sdate_m, b_l_sdate_d, b_l_edate_y, b_l_edate_m, b_l_edate_d"
R_Fields = R_Fields & ", b_l_img "

Call RequestAll (R_Fields, "UploadForm")
b_l_memo	= InputValue2(b_l_memo)

If Len(b_l_sdate_m)=1 Then b_l_sdate_m = "0"&b_l_sdate_m
If Len(b_l_sdate_d)=1 Then b_l_sdate_d = "0"&b_l_sdate_d
If Len(b_l_edate_m)=1 Then b_l_edate_m = "0"&b_l_edate_m
If Len(b_l_edate_d)=1 Then b_l_edate_d = "0"&b_l_edate_d

b_l_sdate = b_l_sdate_y&"-"&b_l_sdate_m&"-"&b_l_sdate_d
b_l_edate = b_l_edate_y&"-"&b_l_edate_m&"-"&b_l_edate_d


' ------------------- 저장공간인 [DATA]폴더가 없다면 생성 한다. -------------------
FolderCreate(server.MapPath("/")&"/data/banner/")
' ------------------------------------------------------------------------------------




If b_l_num = "" then ' 저장
	
	
	' 이미지파일저장
	' *****************************************
	strDir		= server.mappath("/")&"\data\banner\"
	ext_str		= "jpg,gif"
	b_l_img		= wfile2("b_l_img", 10, strDir, ext_str)
	' *****************************************


	' 순서
	' *****************************************
	sql = " SELECT isnull(max(b_l_code),0) FROM banner"
	Set Rs = Dbcon.Execute (sql)
	b_l_code = rs(0)
	rs.close : Set rs = Nothing
	
	b_l_code = b_l_code + 1
	' *****************************************

	
	R_Fields_i = "info_url, b_l_code, b_l_img, b_l_url, b_l_chk, b_l_sdate, b_l_edate, b_l_subject, b_l_memo, b_l_wdate, b_l_mdate"
	
	b_l_wdate = getDateFm(now,3)
	b_l_mdate = getDateFm(now,3)


	Call InsertQuery(R_Fields_i, "banner")

	ok_url = "list.asp"


else ' 수정


	strDir		= server.mappath("/") & "\data\banner\"
	ext_str		= "jpg,gif"
	b_l_img		= wfile2("b_l_img", 10, strDir, ext_str)


	If b_l_img <> "" then ' 첨부파일이 있으면
		
		Call dfile(strDir, b_l_img2)

	else
		
		b_l_img = b_l_img2

		If b_l_img_del <> "" then ' 첨부파일만 삭제
			Call dfile(strDir, b_l_img2)
			b_l_img = ""
		End if

	End if



	R_Fields = "info_url, b_l_img, b_l_url, b_l_chk, b_l_sdate, b_l_edate, b_l_subject, b_l_memo, b_l_mdate"

	b_l_mdate = getDateFm(now,4)

	Call UpdateQuery (R_Fields, "banner", "where b_l_num="&b_l_num)

	ok_url = "list.asp"


End If

Dbcon.close : Set Dbcon = nothing

Call loding("0", ok_url)

%>