<%@ codepage = 65001 %>
<% Response.CharSet = "UTF-8" %> 
<%
'Option Explicit

Response.CacheControl = "no-cache"
Response.AddHeader "Pragma","no-cache"
Response.Expires = 0
Response.Buffer = true

Dim enc_reqNum   ' 암호화된 요청번호
Dim enc_vDiscrNo ' 암호화된 가상식별번호
Dim enc_name     ' 암호화된 성명
Dim enc_result   ' 암호화된 실명확인결과값

Dim dec_reqNum   ' 복호화된 요청번호
Dim dec_vDiscrNo ' 복호화된 가상식별번호
Dim dec_name     ' 복호화된 성명
Dim dec_result   ' 복호화된 실명확인결과값

Dim dec


a_num		 = request("a_num")
prepage		= request("prepage")
If prepage="" Then prepage="/"



'임시
'SESSION("ss_m_name") = "테스트"
'SESSION("ss_m_jumin") = "8202192000000"
'Call goPage(prepage)




enc_retInfo   = request("retInfo")
If enc_retInfo <> "" then

	' 복호화 ----------------------------------------------------------------------------------
	On Error Resume Next

	Set dec = Server.CreateObject("SCIVName_V1.Hmac")

	If(Err.Number <> 0) Then
		Response.Write "Error 1 :: ("& Err.Number &") " & Err.Description & vbCrlf & "<br><br>"
	End IF

	dec_retInfo = dec.Decryption(enc_retInfo)      ' 복호화 된 통합 파라미터

	If(Err.Number <> 0) Then
		Response.Write "Error 2 :: ("& Err.Number &") " & Err.Description & vbCrlf & "<br><br>"
	End IF


	' 파라미터 Parsing------------------------------------------------------------------------
	totInfo = split(dec_retInfo,"/")

	dec_reqNum = totInfo(0)
	dec_vDiscrNo = totInfo(1)
	dec_name = totInfo(2)
	dec_result = totInfo(3)
	dec_discrHash = totInfo(4)
	dec_msg = totInfo(5)

	' -----------------------------------------------------------------------------------------

	cmpMsg = dec.HMacEncript(dec_reqNum & dec_vDiscrNo & dec_result)

	If dec_msg = cmpMsg Then
		msgChk = "정상"
	End If

	Set dec = Nothing
	' -----------------------------------------------------------------------------------------

	Select Case dec_result
		Case 2
			Call goMessage( "성명 또는 주민번호를 확인하십시오.", "/content/board/name.php?a_num="&a_num,"","","")
		Case 5
			Call goMessage( "실명인증시스템오류입니다.\n\n잠시후 다시 시도하십시오.", "/content/board/name.php?a_num="&a_num,"","","")
	End Select
	'=====실명확인=========



	SESSION("ss_m_name")	= dec_name
	SESSION("ss_m_jumin")	= dec_vDiscrNo

	Call goPage(prepage)


End If


'//페이지 이동 및 메세지 출력
sub goMessage(msg, prepage, ok, no, a_num)
	Dim querystring
	'//$msg = mb_convert_encoding($msg, "UTF-8", "EUC-KR");
	querystring = "msg=" & server.urlencode(msg)
	querystring = querystring & "&prepage=" & server.urlencode(prepage)
	querystring = querystring & "&ok=" & server.urlencode(ok)
	querystring = querystring & "&no=" & server.urlencode(no)
	querystring = querystring & "&a_num=" & server.urlencode(a_num)
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="ko" lang="ko">
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<script type="text/javascript">
	<!--

		try{
			window.opener.location.href='<%="/content/board/message.asp?" & querystring%>';
			window.opener = 'nothing';
			window.open('','_parent','');
			window.close();
		}catch(e){
			location.href='<%="/content/board/message.asp?" & querystring%>';
		}

	//-->
	</script>
</head>
<body>
</body>
</html>
<%
	response.end
End Sub





'//페이지 이동 및 메세지 출력
sub goPage(url)
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="ko" lang="ko">
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<script type="text/javascript">
	<!--
		try{
			window.opener.location.href="<%=url%>";
			window.opener = 'nothing';
			window.open('','_parent','');
			window.close();
		}catch(e){

			location.href="<%=url%>";
		}
	//-->
	</script>
	<title>페이지이동</title>
</head>
<body>
</body>
</html>
<%
	response.end
End Sub

%>
