<!--#include virtual="/common/lib/dbcon.asp"-->
<!--#include virtual="/common/lib/func.asp"-->
<!--#include file="config.asp"-->
<%
Dim R_Fields
Dim a_num, a_bbsname, a_level, a_type, a_tablename, a_imgline, a_imgwidth, a_imgheight, a_member, a_ad_cms_id, a_ad_cms, a_cate, a_email, a_phone, a_home, a_jumin, a_jumin_opt, a_ftemp1, a_ftemp1_str, a_ftemp2, a_ftemp2_str
Dim a_ftemp3, a_ftemp3_str, a_ftemp4, a_ftemp4_str, a_new, a_upload, a_upload_len, a_nofilesize, a_nofile, a_reply, a_replyOpt, a_command, a_date_list, a_sdate_y,a_sdate_m,a_sdate_d, a_edate_y, a_edate_m, a_edate_d, a_noword
Dim a_width, a_displaysu, a_viewType, a_lt_a, a_lt_b, a_lt_c, a_lt_e, a_lt_f, a_hd_file, a_dt_file, a_writecontent, a_topinclude, a_btminclude, a_skin, a_date, a_edit,a_password, a_password_str
Dim a_sendmail, a_sendmail_addr, a_sendsms, a_sendsms_addr
Dim R_Fields_i, R_Fields_u

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

R_Fields = "a_num, a_bbsname, a_level, a_type, a_tablename, a_imgline, a_imgwidth, a_imgheight, a_member, a_ad_cms_id, a_ad_cms, a_cate, a_email, a_phone, a_home, a_jumin, a_jumin_opt, a_ftemp1, a_ftemp1_str, a_ftemp2, a_ftemp2_str, a_ftemp3, a_ftemp3_str, a_ftemp4, a_ftemp4_str, a_new, a_upload, a_upload_len, a_nofilesize, a_nofile, a_reply, a_replyOpt, a_command, a_date_list, a_sdate_y,a_sdate_m,a_sdate_d, a_edate_y, a_edate_m, a_edate_d, a_noword, a_width, a_displaysu, a_viewType, a_lt_a, a_lt_b, a_lt_c, a_lt_e, a_lt_f, a_hd_file, a_dt_file, a_topinclude, a_btminclude, a_skin, a_date, a_edit,a_password, a_password_str, a_sendmail, a_sendmail_addr, a_sendsms, a_sendsms_addr"


'//파일부분..
R_Fields = R_Fields & ", is_a_hd_file, is_a_dt_file, a_hd_file_del, a_dt_file_del"

Call RequestAll(R_Fields, "UploadForm")


a_sdate = a_sdate_y & "-" & a_sdate_m & "-" & a_sdate_d
a_edate = a_edate_y & "-" & a_edate_m & "-" & a_edate_d


a_header		= InputValue4( UploadForm("a_header") )
a_detail		= InputValue4( UploadForm("a_detail") )
'a_writecontent	= InputValue2( a_writecontent )
a_writecontent	= UploadForm("a_writecontent")

'If a_close<>"Y" Then a_close = "N"

If a_num = "" then	'//저장

	
	'//테이블 명을 구한다.
	sql = "select a_tablename from board_config order by a_date desc"
	Set rs = dbcon.execute( sql )

	If rs.bof Or rs.eof then
		a_tablename_str = "board_1"
	else

		a_tablename	= rs("a_tablename")
	
		a_tablename	= Split( a_tablename, "_" )
		a_tablename(1)	= a_tablename(1) + 1
		a_tablename_str = a_tablename(0) & "_" & a_tablename(1)

	End if
	Set rs = nothing


	sql    = "SELECT count(a_num) as a_num FROM board_config where a_tablename = '" & a_tablename_str& "'"
	Set rs = dbcon.execute( sql )
	rs_count = rs("a_num")


	if rs_count > 0 Then
		back_back "같은이름의 게시판이 이미 존재합니다."
	End if


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

	'//------------------- 저장공간인 [DATA/게시판명]폴더가 없다면 생성 한다. -------------------
	FolderCreate( server.mappath("/") & "\data\board\" & a_tablename_str & "\")
	'//------------------------------------------------------------------------------------


	'//파일저장
	'//*****************************************
	strDir		= server.mappath("/") & "\data\board\" & a_tablename_str & "\"
	ext_str		= "jpg,gif"

	a_hd_file	= wfile2("a_hd_file", 10, strDir, ext_str)		'필드명, 최대용량, 업로드경로, 허용파일(zip,gif,jpg...)
	a_dt_file   = wfile2("a_dt_file", 10, strDir, ext_str)
	'//*****************************************

	
	R_Fields_i = "a_num, a_bbsname, a_level, a_type, a_tablename, a_imgline, a_imgwidth, a_imgheight, a_member, a_ad_cms_id, a_ad_cms, a_cate, a_email, a_phone, a_home, a_jumin, a_jumin_opt, a_ftemp1, a_ftemp1_str, a_ftemp2, a_ftemp2_str, a_ftemp3, a_ftemp3_str, a_ftemp4, a_ftemp4_str, a_new, a_upload, a_upload_len, a_nofilesize, a_nofile, a_reply, a_replyOpt, a_command, a_date_list, a_sdate, a_edate, a_noword, a_width, a_displaysu, a_viewType, a_lt_a, a_lt_b, a_lt_c, a_lt_e, a_lt_f, a_header, a_hd_file, a_detail, a_dt_file, a_writecontent, a_topinclude, a_btminclude, a_skin, a_date, a_edit, a_password, a_password_str, a_sendmail, a_sendmail_addr, a_sendsms, a_sendsms_addr"
	
	
	a_num		= get_idx_add()
	a_date		= getDateFm(Now(), 3)
	a_tablename	= a_tablename_str


	Call InsertQuery (R_Fields_i, "board_config")


	sql = "CREATE TABLE [dbo].[" & a_tablename_str & "] ("
	sql = sql & "[b_num] [int] IDENTITY (1, 1) NOT NULL ,"
	sql = sql & "[b_type] [char] (1) COLLATE Korean_Wansung_CI_AS NULL ,"
	sql = sql & "[b_id] [varchar] (30) COLLATE Korean_Wansung_CI_AS NULL ,"
	sql = sql & "[b_name] [varchar] (30) COLLATE Korean_Wansung_CI_AS NULL ,"
	sql = sql & "[b_pwd] [varchar] (30) COLLATE Korean_Wansung_CI_AS NULL ,"
	sql = sql & "[b_subject] [varchar] (200) COLLATE Korean_Wansung_CI_AS NULL ,"
	sql = sql & "[b_email] [varchar] (200) COLLATE Korean_Wansung_CI_AS NULL ,"
	sql = sql & "[b_jumin] [varchar] (13) COLLATE Korean_Wansung_CI_AS NULL ,"
	sql = sql & "[b_phone1] [varchar] (4) COLLATE Korean_Wansung_CI_AS NULL ,"
	sql = sql & "[b_phone2] [varchar] (4) COLLATE Korean_Wansung_CI_AS NULL ,"
	sql = sql & "[b_phone3] [varchar] (4) COLLATE Korean_Wansung_CI_AS NULL ,"
	sql = sql & "[b_cate] [int] NULL ,"
	sql = sql & "[b_catename] [varchar] (100) COLLATE Korean_Wansung_CI_AS NULL ,"
	sql = sql & "[b_noticechk] [char] (1) COLLATE Korean_Wansung_CI_AS NULL ,"
	sql = sql & "[b_content] [text] COLLATE Korean_Wansung_CI_AS NULL ,"
	sql = sql & "[b_ip] [varchar] (15) COLLATE Korean_Wansung_CI_AS NULL ,"
	sql = sql & "[b_count] [int] NULL ,"
	sql = sql & "[b_look] [char] (1) COLLATE Korean_Wansung_CI_AS NULL ,"
	sql = sql & "[b_open] [char] (1) COLLATE Korean_Wansung_CI_AS NULL ,"
	sql = sql & "[b_ref] [int] NULL ,"
	sql = sql & "[b_step] [int] NULL ,"
	sql = sql & "[b_level] [int] NULL ,"
	sql = sql & "[b_regdate] [varchar] (30) COLLATE Korean_Wansung_CI_AS NULL ,"
	sql = sql & "[b_chuchun] [int] NULL ,"
	sql = sql & "[b_sbjclr] [varchar] (10) COLLATE Korean_Wansung_CI_AS NULL ,"
	sql = sql & "[b_sdate] [varchar] (10) COLLATE Korean_Wansung_CI_AS NULL ,"
	sql = sql & "[b_edate] [varchar] (10) COLLATE Korean_Wansung_CI_AS NULL ,"
	sql = sql & "[b_temp1] [varchar] (50) COLLATE Korean_Wansung_CI_AS NULL ,"
	sql = sql & "[b_temp2] [varchar] (50) COLLATE Korean_Wansung_CI_AS NULL ,"
	sql = sql & "[b_temp3] [varchar] (50) COLLATE Korean_Wansung_CI_AS NULL ,"
	sql = sql & "[b_temp4] [varchar] (50) COLLATE Korean_Wansung_CI_AS NULL ,"
	sql = sql & "[b_temp5] [varchar] (50) COLLATE Korean_Wansung_CI_AS NULL ,"
	sql = sql & "[b_temp6] [varchar] (50) COLLATE Korean_Wansung_CI_AS NULL ,"
	sql = sql & "[b_temp7] [varchar] (50) COLLATE Korean_Wansung_CI_AS NULL ,"
	sql = sql & "[b_temp8] [text] COLLATE Korean_Wansung_CI_AS NULL ,"
	sql = sql & "[b_file1] [varchar] (300) COLLATE Korean_Wansung_CI_AS NULL ,"
	sql = sql & "[b_file2] [varchar] (300) COLLATE Korean_Wansung_CI_AS NULL ,"
	sql = sql & "[b_file3] [varchar] (300) COLLATE Korean_Wansung_CI_AS NULL ,"
	sql = sql & "[b_file4] [varchar] (300) COLLATE Korean_Wansung_CI_AS NULL ,"
	sql = sql & "[b_file5] [varchar] (300) COLLATE Korean_Wansung_CI_AS NULL ,"
	sql = sql & "[b_keyword] [varchar] (100) COLLATE Korean_Wansung_CI_AS NULL ,"
	sql = sql & "[b_c_count] [int] NULL ,"
	sql = sql & "[b_zip1] [varchar] (3) COLLATE Korean_Wansung_CI_AS NULL ,"
	sql = sql & "[b_zip2] [varchar] (3) COLLATE Korean_Wansung_CI_AS NULL ,"
	sql = sql & "[b_addr1] [varchar] (100) COLLATE Korean_Wansung_CI_AS NULL ,"
	sql = sql & "[b_addr2] [varchar] (100) COLLATE Korean_Wansung_CI_AS NULL "
	sql = sql & ")"

	dbcon.execute sql

	'//뷰생성
	ViewCreate()

	ok_url = "list.asp"


Else	'//수정

	strDir		= server.mappath("/") & "\data\board\" & a_tablename & "\"
	ext_str		= "jpg,gif"
	a_hd_file	= wfile2("a_hd_file", 10, strDir, ext_str)
	a_dt_file	= wfile2("a_dt_file", 10, strDir, ext_str)

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

		Call dfile(strDir, is_a_hd_file)

	Else						'//첨부파일 없으면

		a_hd_file = is_a_hd_file

		If a_hd_file_del = "Y" Then		'//첨부파일만 삭제
			Call dfile(strDir, is_a_hd_file)
			a_hd_file = ""
		End if

	End if


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

		Call dfile( strDir, is_a_hd_file)

	Else	'//첨부파일 없으면
		
		a_dt_file = is_a_dt_file

		If a_dt_file_del = "Y" then		'//첨부파일만 삭제
			Call dfile( strDir, is_a_dt_file )
			a_dt_file = ""
		End if

	End if
	
	'response.write a_edate
	'response.end
	


	R_Fields_u = "a_bbsname, a_level, a_type, a_imgline, a_imgwidth, a_imgheight, a_member, a_ad_cms_id, a_ad_cms, a_cate, a_email, a_phone, a_home, a_jumin, a_jumin_opt, a_ftemp1, a_ftemp1_str, a_ftemp2, a_ftemp2_str, a_ftemp3, a_ftemp3_str, a_ftemp4, a_ftemp4_str, a_new, a_upload, a_upload_len, a_nofilesize, a_nofile, a_reply, a_replyOpt, a_command, a_date_list, a_sdate, a_edate, a_noword, a_width, a_displaysu, a_viewType, a_lt_a, a_lt_b, a_lt_c, a_lt_e, a_lt_f, a_header, a_hd_file, a_detail, a_dt_file, a_writecontent, a_topinclude, a_btminclude, a_skin, a_edit, a_password, a_password_str, a_sendmail, a_sendmail_addr, a_sendsms, a_sendsms_addr"


	Call UpdateQuery ( R_Fields_u, "board_config", "where a_num =" & a_num )

	ok_url = "list.asp?" & page_info

	ViewCreate()


'	If a_close = "Y" Then
'		sql = "update " & a_tablename & " set b_open = 'N' "
'	Else
'		sql = "update " & a_tablename & " set b_open = 'Y' "
'	End if

End if


Call loding ("0", ok_url)

%>