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

	'────────────────────────────────────────────────────
	' 나눔 PHP 모듈에서 사용중 175.126.77.226 / 112.216.151.211
	' 의성교육지원청 사용중
	'────────────────────────────────────────────────────

	'm_id : 회원ID
	'msg : 메세지
	'tran_callback : 회신번호
	'tran_phone : 수신번호 ex) 0111231234,0171231234
	'rtn_url : 리턴URL  ex) http://nninc.co.kr
	
	m_id			= inputValue( Request("sms_m_id") )
	msg				= inputValue( Request("sms_msg") )
	tran_callback	= inputValue( Request("sms_tran_callback") )
	tran_phone		= inputValue( Request("sms_tran_phone") )
	rtn_url			= inputValue( Request("sms_rtn_url"))
	tran_etc1			= inputValue( Request("sms_tran_etc1"))

	If m_id = "knuhglobal" Then '국제의료만 리턴유알엘 다르게..크롬에서 안되길래..
		rtn_url			= Request("sms_rtn_url")
		rtn_url			= Replace(rtn_url, "&amp;","&")
	End If 

	'Response.write "a=" & m_id
	'Response.end
	'msg = Replace(msg, "&amp;","&")

	If Instr(msg, "[국민건강검진]통지서") <> 0 Then Response.end
	If Instr(msg, ".host") <> 0 Then Response.end
	If Instr(msg, ".wiki") <> 0 Then Response.end
	
	If tran_callback = "" Then tran_callback = tran_callback1&tran_callback2&tran_callback3
	If rtn_url = "" Then rtn_url = Request.ServerVariables("HTTP_REFERER")

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

	If smsSelect2(m_id) > 0 Then
		tran_phone_arr = Split(tran_phone,",")
		z = 0
		
		For i = 0 To UBound( tran_phone_arr )
			If Trim(tran_phone_arr(i)) <> "" then
				tran_phone = Replace(tran_phone_arr(i), "-", "")
				
				SQL = "Insert into em_tran(tran_id, tran_phone, tran_callback, tran_status, tran_date, tran_msg, tran_etc1) values ("
				SQL = SQL & "'"&m_id&"','"&tran_phone&"', '"&tran_callback&"', '1', '"&Rdate&"', '"&Msg&"', '"& tran_etc1 &"')"
'				response.write sql & "<br />"
				Dbcon.Execute sql

				z = z + 1
			End if

		Next

		sql = "update member set M_g_sms = M_g_sms - "&z&" where M_id = '"&m_id&"'"
		'response.write z
		Dbcon.Execute sql
	
	End if

	Dbcon.close
	Set Dbcon = Nothing

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