<%@ Language=VBScript %>
<!--#include virtual="/inc-freehost-function/FreeHostFunction.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
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,1
if dsdom.Eof then
	ef=True
	ec="不存在的域名！"
end if
end if
if not ef then
if dsdom("Domain_API")=1 then
urllogin="http://agent.dns.com.cn/cgi-bin/Agent/AgentLogin"
urlA="http://agent.dns.com.cn/cgi-bin/epp1/PreManageNew"
urlB="http://agent.dns.com.cn/cgi-bin/epp1/PreInfo?Number=1"
urlC="http://agent.dns.com.cn/cgi-bin/epp1/PreDomainNew"
urlX="http://agent.dns.com.cn/cgi-bin/Domain/DomainQuery"
elseif dsdom("Domain_API")=2 then
urllogin="https://www.paycenter.com.cn/cgi-bin/nEWpAYcENTER/Agent/AgentLogin"
urlA="https://www.paycenter.com.cn/cgi-bin/nEWpAYcENTER/vpp/PreManage"
urlB="https://www.paycenter.com.cn/cgi-bin/nEWpAYcENTER/vpp/PreInfo?Number=1"
urlC="https://www.paycenter.com.cn/cgi-bin/nEWpAYcENTER/vpp/PreDomain"
urlX="https://www.paycenter.com.cn/cgi-bin/nEWpAYcENTER/Domain/DomainModifyPW01"
urlP="https://www.paycenter.com.cn/cgi-bin/nEWpAYcENTER/Domain/DomainModifyPW"
elseif dsdom("Domain_API")=3 then
urllogin=Application("Domain_HTTP")&"/login"
elseif dsdom("Domain_API")=4 then
urllogin=Application("Domain_HTTP")&"/login"
end if
end if

if not ef then
domainpass=dsdom("inipass")
out=POSTLOGIN3(Application("Domain_HTTP")&"/domainportal",Application("Domain_HTTP")&"/domainportal","module=login&domainname="&dsdom("domain")&"&password="&domainpass&"&img.x=42&img.y=20")
out=GETHTTPS(Application("Domain_HTTP")&"/domainportal?module=domainshow",Application("Domain_HTTP")&"/domainportal")

if out="" or  Instr(out, "错误")>0 then
retdns=P_B(urllogin)
If Instr(1,retdns, "用户名或密码错误", 1)>0 then
	ef=True
	ec="登陆域名接口失败，请检查代理用户名与密码中否正确，请联系管理员。"
end if


if not ef then

retdns=P_A(Application("Domain_HTTP")&"/domainlist",Application("Domain_HTTP")&"/domainlist","module=domainlist&searchtype=self&username=&domain="&URLEncoding(dsdom("Domain"))&"&timemode=0?_date1=?_date2=&ordermode=-----------&Submit=%B2%E9%D1%AF")
passarry=split(retdns,"/domainpanel?id=")
passarry2=split(passarry(1),"&module=domainshow")
retdns=P_A(Application("Domain_HTTP")&"/domainpanel",Application("Domain_HTTP")&"/domainpanel?id="&passarry2(0)&"&module=pwd","module=pwdmodify&id="&passarry2(0)&"&pwd="&URLEncoding(domainpass)&"&cfpwd="&URLEncoding(domainpass)&"&Submit=%C8%B7+%B6%A8")
If Instr(1,retdns, "修改成功", 1)<0 then
	ef=True
	ec="同步密码失败，可能是网络忙，也可以重试一次！"
else
out=POSTLOGIN3(Application("Domain_HTTP")&"/domainportal",Application("Domain_HTTP")&"/domainportal","module=login&domainname="&dsdom("domain")&"&password="&domainpass&"&img.x=42&img.y=20")
out=GETHTTPS(Application("Domain_HTTP")&"/domainportal?module=domainshow",Application("Domain_HTTP")&"/domainportal")
end if


end if
end if
end if


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

if not ef Then
out=replace(out,"_default/domainportal/","")
out=replace(out,"domainportal?module=pwd","")
out=replace(out,"dnsportal?domainname="&dsdom("domain"),"")
out=replace(out,"domainportal?module=urlforword","")
out=replace(out,"domainportal?module=logout","/dns/logininfo.asp")
out=replace(out,"domainportal?module=certification","")
out=replace(out,"domainportal?","dnsaction.asp?/domainportal?")
out=replace(out,"v2/","http://www.bizcn.com/_default/domainportal/v2/")
out=replace(out,"/http://","http://")
out=replace(out,"修改域名管理密码","")
out=replace(out,"URL转发","")
out=replace(out,"获取证书","")
out=replace(out,"DNS解析管理","")
out=replace(out,"修改域名DNS","")

end if

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

Function POSTLOGIN3(tar,ref,body)
session("httpscookie")=""
Set xml = Server.CreateObject("WinHttp.WinHttpRequest.5.1")
xml.Option(6)=0
xml.setTimeouts 20000, 20000, 20000, 240000
xml.Open "POST", tar, False
xml.setRequestHeader "Content-Length",Len(body)
xml.setRequestHeader "CONTENT-TYPE","application/x-www-form-urlencoded"
xml.setRequestHeader "Accept-Encoding","none"
xml.setRequestHeader "REFERER",ref
xml.send body
session("httpscookie") = xml.getResponseHeader("Set-Cookie")
 POSTLOGIN3=bytes2BSTR(xml.responsebody)
Set xml = Nothing
End Function

%>