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

'm_id : 회원ID
'msg : 메세지
'tran_callback : 회신번호
'tran_phone : 수신번호 ex) 0111231234,0171231234
'rtn_url : 리턴URL  ex) http://nninc.co.kr

m_id			= inputValue( Request("mms_m_id") )
msg				= inputValue( Request("mms_msg") )
tran_callback	= inputValue( Request("mms_tran_callback") )
tran_phone		= inputValue( Request("mms_tran_phone") )
rtn_url			= inputValue( Request("mms_rtn_url"))
tran_etc1		= inputValue( Request("mms_tran_etc1"))
send_date		= inputValue( Request("mms_send_date"))	'YYYYMMDDHHNNSS

If m_id="" Or msg="" Or tran_callback="" Or tran_phone="" Then
	Response.End
End If



If Instr(msg, "[국민건강검진]통지서") <> 0 Then Response.end
If Instr(msg, ".host") <> 0 Then Response.end
If Instr(msg, ".wiki") <> 0 Then Response.end

If rtn_url = "" Then rtn_url = Request.ServerVariables("HTTP_REFERER")

Rdate = Date()& " " & Hour(now)&":"&Minute(now)
tran_callback = Replace(tran_callback, "-", "")

subject = StringToHTML( msg, 30, false )
now_date = Replace( Date(), "-", "" ) & Right("0"&hour(now), 2) & Right("0"&minute(now), 2) & Right("0"&second(now), 2)

SCHEDULE_TYPE = 0
If send_date<>"" then
	If now_date < send_date Then
		SCHEDULE_TYPE = 1
	End If
Else
	send_date = now_date
End if


tran_phone = Replace(tran_phone, "-" , "")
tran_phone = Replace(tran_phone, " " , "")

tran_phone_arr = Split(tran_phone,",")
z=0
For i = 0 To UBound( tran_phone_arr )
	If tran_phone_arr(i) <> "" then
		z = z + 1
	End if
Next


If smsSelect2(m_id) >= (z*3) Then

	tran_phone_arr = Split(tran_phone,",")
	z = 0
	
	For i = 0 To UBound( tran_phone_arr )
		If tran_phone_arr(i) <> "" then
			tran_phone = tran_phone_arr(i)
			
			
			sql = "insert into SDK_MMS_SEND( user_id, subject, now_date, send_date, dest_count, dest_info, msg_type, mms_msg, content_count, content_data, callback, RESERVED1, RESERVED2, RESERVED3, RESERVED4, SCHEDULE_TYPE) values('"
			sql = sql & m_id & "','"
			sql = sql & subject & "', '"
			sql = sql & now_date & "','"
			sql = sql & send_date & "', '"
			sql = sql & "1', '"
			sql = sql & "noname^" & tran_phone & "', '"
			sql = sql & "0', '"
			sql = sql & Msg & "', '"
			sql = sql & "1', '"
			sql = sql & "', '"
			sql = sql & tran_callback & "', '"
			sql = sql & tran_etc1 & "', '"
			sql = sql & "', '"
			sql = sql & "', '"
			sql = sql & "', '"
			sql = sql & SCHEDULE_TYPE & "'"
			sql = sql & ")"
			executeQuery( sql )

			
			z = z + 1
		End if

	Next

	sql = "update member set M_g_sms = M_g_sms - "&(z*3)&" where M_id = '"&m_id&"'"
	executeQuery( sql )

Else
	Response.write "err"
End if

Dbcon.close
Set Dbcon = Nothing

If rtn_url <> "" then
	response.redirect rtn_url
End if
%>
