<%@ Language=VBScript %>
<%if session("username")="" And session("agentusername")="" then
Response.Redirect "e.asp?e=可能超时了，请先登陆"
end if%>
<!--#include virtual="/inc-freehost-function/FreeHostFunction.asp"-->
<!--#include virtual="/inc-freehost-function/FreeHostFunctionMain.asp"-->
<%fcon=Cstr(request.form)
%>
<%
urllogin=Application("Domain_HTTP")&"/login"

if not ef then
If fcon="" then
	ef=True
	ec="保存信息时出错，请您重试一次。"
end if
end if

if not ef then
retdns=P_B(urllogin)
If Instr(1,retdns, "用户名或密码错误", 1)>0 then
	ef=True
	ec="登陆域名接口失败，请检查代理用户名与密码中否正确，请联系管理员。"
elseif Application("onlyone")=true and Request.Form ("years")>1 then
	ef=True
	ec="管理员限制了首次注册只能注册一年！"
end if
end If

if not ef then
conarry=split(LCase(session("selectedDomainName")),",")
for i=0 to ubound(conarry)
if len(conarry(i))>4 Then

aryDom=split(conarry(i),".")
suffix=Right(conarry(i),Len(conarry(i))-Len(aryDom(0)))
searchedDomainName=aryDom(0)
retdns=P_A(Application("Domain_HTTP")&"/newdomain",Application("Domain_HTTP")&"/serviceorder?module=domainregister","module=domainsearch&searchType=IntDomain&action=check&searchedDomainName="&searchedDomainName&"&suffix="&suffix&"&x=76&y=12")


'response.write retdns
'response.end

If retdns="" then
	ef=True
	ec="预注册中域名接口连接出错A！"
end If
finstr=replace(conarry(i),".","")
arystr=split(retdns,finstr)

If UBound(arystr)<1 Then
	ef=True
	ec="这个域名在注册商中原来已注册成功了,请不要重复注册."
end If

If Not ef Then

arystr2=split(arystr(1),""">")
arystr3=split(arystr2(0),"=""")
retdns=P_A(Application("Domain_HTTP")&"/domainreg",Application("Domain_HTTP")&"/newdomain","module=domain2cart&selectedDomainName="&conarry(i)&"&"&finstr&"="&arystr3(1)&"&img.x=85&img.y=21")
'retdns=P_C(Application("Domain_HTTP")&"/domainregister",Application("Domain_HTTP")&"/domainreg",session("dopost_cookieA"))
If retdns="" then
	ef=True
	ec="预注册中域名接口连接出错A！"
End If
retdns=P_A(Application("Domain_HTTP")&"/domainregister",Application("Domain_HTTP")&"/domainreg",fcon)
If retdns="" then
	ef=True
	ec="预注册中域名接口连接出错B！"
End If

End if
'response.write retdns
'response.End
if instr(retdns, "有误")>1 then
	ef=True
	ec="很抱歉,您的注册资料不正确:"
	eout=split(retdns,"输入的")
	eout2=split(eout(1),"</font>")
	eout2(0)=replace(eout2(0)," ","")
	ec=ec&eout2(0)
end if
if instr(retdns, "提交错误的执行模块")>1 then
	ef=True
	ec="很抱歉,您的注册资料不正确或API出错！"
end If

if instr(retdns, "Error_Input")>1 then
	ef=True
	ec="很抱歉,您的注册资料不正确,原因是:"
	eout=split(retdns,"Error_Input")
	eout2=split(eout(1),"</font>")
	eout2(0)=replace(eout2(0)," ","")
	ec=ec&eout2(0)
end if

	exit for
end if
next
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"
	dsdom.Open sql,conn,1,3

conarry=split(session("selectedDomainName"),",")

for i=0 to ubound(conarry)
if len(conarry(i))>4 then
dsdom.addnew
dsdom("username")=session("username")
dsdom("agent1")=session("agentname")

if session("agentusername")<>"" Then
dsdom("username")=session("agentusername")
dsdom("agent1")=session("agentusername")
End if

dsdom("Domain")=trim(conarry(i))

Dim enc
Enddomaintypeid=GetDomaintype(dsdom("Domain"))
If Enddomaintypeid=3 And Right(dsdom("Domain"),"7")=".net.cn" Then dsdom("Domain")=Replace(dsdom("Domain"),".net.cn",".网络")
If Enddomaintypeid=3 And Right(dsdom("Domain"),"7")=".com.cn" Then dsdom("Domain")=Replace(dsdom("Domain"),".com.cn",".公司")
If Enddomaintypeid=3 And Right(dsdom("Domain"),"3")=".cn" Then dsdom("Domain")=Replace(dsdom("Domain")&"_",".cn_",".中国")

dsdom("ServerlistID")=1
dsdom("Domaintype")=""
dsdom("status")="预注册成功"
dsdom("starttime")=NOW
dsdom("postcon")=fcon
dsdom("years")=Clng(request.form("years"))
if dsdom("years")<1 or request.form("years")=""  then dsdom("years")=1
if request.form("years")="" then dsdom("years")=1
dsdom("Domain_API")=3
if Application("DNS_API")=1 then dsdom("DNS_API")=1
dsdom.update
end if

next
dsdom.close
set dsdom=nothing
conn.close
set conn=nothing
if session("agentusername")<>"" Then%>

<!--#include virtual="/inc-freehost-function/htmlwrite.asp"--><%=htmlwrite("html5")%>　域名注册
<%=htmlwrite("html6")%>
<br><br>
<%if session("DomainNameModid")="" then%>
　　<a href="/agent/listmydomain.asp"><font color="#FF0000">预注册成功，马上付费>>></font></a><br><br>
<%else
%>
保存成功。
<%end if%>
<%=htmlwrite("html7")%>

<%else%>
<!--#include virtual="/inc-freehost-function/htmlwrite.asp"--><%=htmlwrite("html2")%>　域名注册
<%=htmlwrite("html3")%>
<br><br>
<%if session("DomainNameModid")="" then%>
　　<a href="/user/listmydomain.asp"><font color="#FF0000">预注册成功，马上付费>>></font></a><br><br>
<%else
%>
保存成功。
<%end if%>
<%=htmlwrite("html4")%>
<%End if%>

<%end if
if ef then
Response.Redirect "e.asp?e="&ec
end if%>
