<%@ Language=VBScript %>
<!--#include virtual="/inc-freehost-function/FreeHostFunction.asp"-->
<!--#include virtual="/inc-freehost-function/FreeHostFunctionMain.asp"-->
<%Response.Redirect "/dns/2/default.asp"
id=session("DNSAUID")
If session("DNSAUID")="" Then
	ef=True
	ec="授权非法，请您先登陆。"
ElseIf not IsNumeric(id)  Then
	ef=True
	ec="ID应该是数字！"
end if

if not ef Then

'Response.Redirect "http://mgt.dns.com.cn/main/api_login.php?Domain=red8341&Suffix=.cn&Passwd=8gSLXmyYr2&EppOwner=agent13555"

Set conn=Server.CreateObject("ADODB.Connection")
	conn.Open Application("FreeHostDBlink")
	Set dsdom = Server.CreateObject("ADODB.Recordset")	
		Sql="Select * from FreeHost.FreeHost_Product_Domain where id='"&id&"'"
			if Instr(1,sql, ";", 1)>0 or Instr(1,sql, "--", 1)>0 then
outcon="非法字符！"
Response.End
end if
	dsdom.Open Sql,conn,1,3
if dsdom.Eof then
	ef=True
	ec="不存在的域名！"
end if
end if

if not ef Then
Dim enc
Enddomaintypeid=GetDomaintype(dsdom("Domain"))
end if


if not ef then
	Set oDomain = server.CreateObject("DevKit.Core.APIDomain")
	oDomain.setAgent Application("Domain_Agent_username_1"),Application("Domain_Agent_password_1_API")
	oDomain.setPostDebug(true)
	oDomain.setDomainName(dsdom("Domain"))
	enc="ENG"
	domtemp2=replace(replace(dsdom("Domain"),".",""),"-","")
	if RegExpTest("[^A-Za-z0-9]",domtemp2) then
	enc="CHI"
	end if
    oDomain.setEncode(enc)

	If oDomain.domainGetStatus() Then 
		dsdom("inipass")=oDomain.getCipher()
		dsdom.update
	Else 
		ef=True
	    ec= oDomain.getCode()&oDomain.getMessage()
	End If 
	Set oDomain = nothing
end if

if not ef then
domarry=split(dsdom("domain"),".")
domainpass=dsdom("inipass")
domtemp=right(session("domain"),len(session("domain"))-len(domarry(0)))
'Response.Write 
'on error resume next
urld="http://mgt.dns.com.cn/main/api_login.php?Domain="&domarry(0)&"&Suffix="&domtemp&"&Passwd="&domainpass&"&EppOwner="&Application("Domain_Agent_username_1")
Response.Redirect urld

out=DOGETDNS(urld,"http://mgt.dns.com.cn/main/domain_login.php")

response.write out
response.end

end if

if not ef then
if out="" or  Instr(out, "错误")>0 then
	ef=True
	ec="联系域名数据库不成功，可能是网络忙，也可以稍后再试一次！"
end if
end if

if not ef then
'http://mgt.dns.com.cn/main/control/domain_control_step10.php?PHPSESSID=3213e56cc1ff5b149979aade738d1513
tar="http://mgt.dns.com.cn/main/control/domain_control_step10.php?"&session("dopost_cookie")
tar=replace(tar,"; path=/","")
'response.write session("dopost_cookie")
'response.end
out2=GETHTTPS_DNS_1(tar,"http://mgt.dns.com.cn")
out2=replace(out2,"<a href=""","<a href=""dnsaction.asp?/main/control/")
out2=replace(out2,"/images/","http://mgt.dns.com.cn/images/")
out2=replace(out2,"dnsaction.asp?/main/control/domain_manage_logout.php","/dns/logininfo.asp?")
out2=replace(out2,"an4.gif"" width=""130"" height=""106""","an4.gif"" width=""0"" height=""0""")
out2=replace(out2,"MyDNS功能","")
out2=replace(out2,"an5.gif"" width=""130"" height=""106""","an4.gif"" width=""0"" height=""0""")
out2=replace(out2,"查看域名证书","")
out2=replace(out2,"<img src=""http://mgt.dns.com.cn/images/mydns/an4.gif"" width=""0"" height=""0"" border=""0"">","")
end if

if not ef then
If Instr(retdns, "请重新登录")>0 then
	ef=True
	ec="超时了，请再登陆一次！"
end if
end if
if not ef then
%>
<%=out2%>
<%end if
if ef then
Response.Redirect "e.asp?e="&ec
end if

Function DOGETDNS(tar,ref)
  Dim returnstr
  body=Cstr(body)
	Set xml = Server.CreateObject("Msxml2.ServerXMLHTTP.3.0")
xml.setTimeouts FreeHost_t1, FreeHost_t2, FreeHost_t3, FreeHost_t4
xml.Open "GET", tar, False
xml.setRequestHeader "REFERER",ref
xml.send body
cookie = xml.getResponseHeader("Set-Cookie")
'Response.Write cookie
session("dopost_cookie")=cookie
sID = mid(cookie,instr(1,cookie,"=")+1,instr(1,cookie,";")-(instr(1,cookie,"=")+1))
returnstr = bytes2BSTR(xml.responsebody)
	DOGETDNS = returnstr
End Function

Function GETHTTPS_DNS_1(tar,ref)
Dim returnstr
Set xml = Server.CreateObject("Msxml2.ServerXMLHTTP.3.0")
xml.setTimeouts FreeHost_t1, FreeHost_t2, FreeHost_t3, FreeHost_t4
xml.Open "GET", tar, False
xml.setRequestHeader "REFERER",ref
xml.setRequestHeader "COOKIE", left(session("dopost_cookie"),instr(1,session("dopost_cookie"),";")-1)
xml.setRequestHeader "COOKIE", left(session("dopost_cookie"),instr(1,session("dopost_cookie"),";")-1)
xml.send
returnstr = bytes2BSTR(xml.responsebody)
	GETHTTPS_DNS_1 = returnstr
End Function
%>