<%@ Language=VBScript %>
<!--#include virtual="/inc-freehost-function/FreeHostEmail.asp"-->
<!--#include virtual="/inc-freehost-function/FreeHostFunction.asp"-->
<!--#include virtual="/inc-freehost-function/FreeHostFunctionMain.asp"-->
<%
Response.Write "此文件已不再使用！请升级"
Response.End

urllogin="https://cp.35.com/cgi-bin/chinese/login.cgi"

If session("username")="" Then
	ef=True
	ec="授权非法，有可能是超时造成的。"
ElseIf Request("id")="" Then
	ef=True
	ec="请选择产品！"
ElseIf not IsNumeric(Request("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 username='"&session("username")&"' and id='"&Request.QueryString ("id")&"'"
if Instr(1,sql, ";", 1)>0 or Instr(1,sql, "--", 1)>0 then
Response.Write "非法字符！"
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
if dsdom("Domain_API")<>4 then
	ef=True
	ec="这是中频的接口。"
end if
end if

if not ef then
on error resume next
If TOLOGINDNS_CH(urllogin)=false then
If TOLOGINDNS_CH(urllogin)=false then
	ef=True
	ec="登陆域名接口失败，可能是网络忙的原因造成的，请再试一次，或请联系管理员。"
end if
end if
end if

if not ef then
'dsdom("years")=1'设置为1年，强行
yearstr=dsdom("years")
'dsdom.update
'fcon=dsdom("postcon")
end If

if not ef then
Enddomaintypeid=GetDomaintype(dsdom("Domain"))
end if


if not ef then
	Set dsDlist = Server.CreateObject("ADODB.Recordset")	
		Sql="Select * from FreeHost.FreeHost_DomainProductlist where id='"&Enddomaintypeid&"'"
		dsDlist.Open Sql,conn,1,1
if dsDlist.eof then
	ef=True
	ec="管理员没有定义域名的价格，请联系管理员！"
else
usermoney=dsDlist("usermoney")
myrealcost=dsDlist("usermoneyagn")
end if
end if

if not ef then
	Set ds = Server.CreateObject("ADODB.Recordset")	
		Sql="Select * from FreeHost.FreeHost_USER where username='"&session("username")&"'"
		ds.Open Sql,conn,3,2
if ds.eof then
	ef=True
	ec="用户不存在!"
end if
end if

if not ef then
if ds("password")<>session("password") then
	ef=True
	ec="密码不正确!"
end if
end if

if not ef then
	Set dspre = Server.CreateObject("ADODB.Recordset")	
	Sql="Select * from FreeHost.FreeHost_Preopen_Product where username='"&ds ("username")&"' and haveget='n' and type1='"&dsDlist("Domaintype")&"'"
	dspre.Open Sql,conn,1,3
if not dspre.Eof then
if Clng(yearstr)=1 then
havehostget=true
havehostgetcon="赠送"
end if
end if
end if

if not ef then
if DateDiff("s", Application("domainoptime"),NOW )<Application("domainopmax") and Application("domainoplock")=true then
	ef=True
	ec="系统繁忙，前一个操作尚未处理完，请您稍等两分钟后再试，谢谢您的支持。"
end if
end if

if not ef then
Application.lock
Application("domainoptime")=now
Application("domainoplock")=true
Application.unlock

dim starttime,temptime,pdtype
pdtype=dsdom("Domain")
starttime=NOW
temptime=dateadd("yyyy",yearstr,now)

dim ef,ec,Userpaymoney,forpaytype,olduser_money,moneych,newuser_money,oldagn_money,mymoneych,newagn_money,Useragentname,agent_UP,agent_thisgree_cost,agent_this_name,logfor,pubisagnSer,AgnRunasUser,RsDlist,regapi
regapi=4
set RsDlist=dsDlist
Userpaymoney=dsDlist("usermoney")
if havehostget=false then
forpayyear=yearstr
else
forpayyear=999
end if
set RsUserds=ds
Useragentname=ds("agent1")
forpaytype="域名产品"
forpayid=dsDlist("id")
logfor="用户区开通(域名"&dsdom("Domain")&")"
if havehostget then logfor=logfor&"(虚拟主机赠送免费开通)"
pubisagnSer=isAgnHostSer
AgnRunasUser=session("AgnRunasUser")
session("moneylog_pdid")=dsdom("id")
DoPayMoneyDomainNew
Application.lock
Application("domainoplock")=false
Application.unlock
end if

if not ef then
if havehostget=true then
dspre("haveget")="y"
dsdom("isbyhost")="y"
dsdom("Hosttype")=dspre("type1")
dsdom("byid")=dspre("byid")
dspre.update
dspre.close
'删除重复
		Sql="delete from FreeHost.FreeHost_Preopen_Product where byid="&dsdom("byid")&" and haveget='n'"
  conn.Execute Sql
end if



'赠送的邮箱
'开通邮箱
starttime=now
	Set dsemailpdlist = Server.CreateObject("ADODB.Recordset")	
	Sql="Select * from FreeHost.FreeHost_EmailProductlist where Domaintype='"&dsDlist("Domaintype")&"' and isbydomain='y'"
	dsemailpdlist.Open Sql,conn,1,1
if not dsemailpdlist.Eof then
Set dsphemail = Server.CreateObject("ADODB.Recordset")	
	Sql="Select * from FreeHost.FreeHost_Product_Email where username='"&ds ("username")&"'"
	dsphemail.Open Sql,conn,1,3
dsphemail.addnew
dsphemail("username")=ds("username")
dsphemail("ServerlistID")=dsemailpdlist("ServerlistID")
dsphemail("Emailtype")=dsemailpdlist("Emailtype")
dsphemail("starttime")=starttime
dsphemail("endtime")=temptime
dsphemail("bydomain")=dsdom("id")
dsphemail("istest")="n"
dsphemail("emailcount")=dsemailpdlist("emailcount")
dsphemail("userspacelimt")=dsemailpdlist("userspacelimt")
dsphemail("domainspacelimt")=dsemailpdlist("domainspacelimt")
dsphemail("domainmustsame")=dsemailpdlist("domainmustsame")
dsphemail("status")="正常"
if ds("agent1")<>"n" then
dsphemail("agent1")=ds("agent1")
else
dsphemail("agent1")="n"
end if
dsphemail.update
dsphemail.close
	Set dsphemail = Server.CreateObject("ADODB.Recordset")	
	Sql="Select * from FreeHost.FreeHost_Product_Email where starttime='"&starttime&"' and username='"&ds("username")&"'"
	dsphemail.Open Sql,conn,1,1
FreeHost_oplog session("username"),"信息","用户自己开通域名"&dsdom("Domain")&"赠送邮箱产品ID:"&dsphemail("id")
retemail="赠送的邮箱产品已开通"
end if
'结束赠送



end if


if not ef then
%>
<!--#include virtual="/inc-freehost-function/htmlwrite.asp"--><%=htmlwrite("html2")%>　马上支付
<%=htmlwrite("html3")%>
<script language="JavaScript" type="text/JavaScript">
alert('请注意：为了让您的交易顺利完成，必须在页面显示完成1分钟后才能关闭游览器。') 
</script>
<%response.flush()%>
<%
dsdom("status")="失败"
dsdom.update
Application.lock
Application("domainoptime")=now
Application("domainoplock")=true
Application.unlock
fcon=dsdom("postcon")
fcon=replace(fcon,"&check_sum=bb541c5e7c882cc2aeecd922dcf415c3&str1=ykR6Em",Application("Domain_Agent_username_4_checksum"))'新的
fcon=replace(fcon,"&check_sum=2adba1b7fd52f80423b217aa66eebf9a&str1=tbyDgj",Application("Domain_Agent_username_4_checksum"))'旧的


if Enddomaintypeid=1 Or Enddomaintypeid=30 then '.com
retdns=TOLOGINDNS_CH_POST("https://cp.35.com/cgi-bin/chinese/reg_direct_ocust2.cgi","https://cp.35.com/cgi-bin/chinese/reg_direct_ocust1.cgi",fcon)
elseif Enddomaintypeid=2 then '.cn
retdns=TOLOGINDNS_CH_POST("https://cp.35.com/cgi-bin/chinese/cn_reg_cust2.cgi","https://cp.35.com/cgi-bin/chinese/cn_reg_cust1.cgi",fcon)
elseif Enddomaintypeid=7 then '中文.com
retdns=TOLOGINDNS_CH_POST("https://cp.35.com/cgi-bin/chinese/reg_mul_domain.cgi","https://cp.35.com/cgi-bin/chinese/reg_mul_begin.cgi",fcon)
elseif Enddomaintypeid=3 then '中文.cn
retdns=TOLOGINDNS_CH_POST("https://cp.35.com/cgi-bin/chinese/reg_cn_domain.cgi","https://cp.35.com/cgi-bin/chinese/reg_cn_second.cgi",fcon)
end if

if retdns="" then
if Enddomaintypeid=1  Or Enddomaintypeid=30 then '.com
retdns=TOLOGINDNS_CH_POST("https://cp.35.com/cgi-bin/chinese/reg_direct_ocust2.cgi","https://cp.35.com/cgi-bin/chinese/reg_direct_ocust1.cgi",fcon)
elseif Enddomaintypeid=2 then '.cn
retdns=TOLOGINDNS_CH_POST("https://cp.35.com/cgi-bin/chinese/cn_reg_cust2.cgi","https://cp.35.com/cgi-bin/chinese/cn_reg_cust1.cgi",fcon)
elseif Enddomaintypeid=7 then '中文.com
retdns=TOLOGINDNS_CH_POST("https://cp.35.com/cgi-bin/chinese/reg_mul_domain.cgi","https://cp.35.com/cgi-bin/chinese/reg_mul_begin.cgi",fcon)
elseif Enddomaintypeid=3 then '中文.cn
retdns=TOLOGINDNS_CH_POST("https://cp.35.com/cgi-bin/chinese/reg_cn_domain.cgi","https://cp.35.com/cgi-bin/chinese/reg_cn_second.cgi",fcon)
end if
end if


FreeHost_oplog session("username"),"执行","域名注册:"&dsdom("Domain")
dsdom("retdns")=retdns
dsdom.update

Application.lock
Application("domainoplock")=false
Application.unlock

end if

if not ef then
if retdns="" then
ec="由于网络连接原因操作并不成功。但款项已扣。您的定单已经更改为手工受理,我们将为您手工处理，请稍侯进入域名管理刷新或联系管理员。注意不要重复尝试！"
	FreeHost_oplog session("username"),"失败","域名注册:"&dsdom("Domain")&ec
%>
<%=ec%>
<%=htmlwrite("html4")%>
<%
response.end
end if
end if

if not ef then
if (instr(retdns, "尚无资金帐户")>1 or instr(retdns, "帐户上只能支付")>1 or instr(retdns, "资金不足")>1) then
ec="由于网络连接原因操作并不成功。但款项已扣。您的定单已经更改为手工受理,我们将为您手工处理，请稍侯进入域名管理刷新或联系管理员。请不要重试。原因：域名接口上帐户金额不足。"
	FreeHost_oplog session("username"),"失败","域名注册:"&dsdom("Domain")&ec
%>
<%=ec%>
<%=htmlwrite("html4")%>
<%
response.end
end if
end if

if not ef then
if instr(retdns, "注册成功")<1 then
	ef=True
	ec="操作失败，但款项已扣。您的定单已经更改为手工受理,我们将为您手工处理，请稍侯进入域名管理刷新或联系管理员。请不要重试。原因："
dnsarry=split(retdns,"注册系统提示信息")
dnsarry2=split(replace(dnsarry(1),"</center></h2><hr>",""),"<hr>")
	ec=ec&dnsarry2(0)
	FreeHost_oplog session("username"),"失败","域名注册:"&dsdom("Domain")&ec
%><%=ec%>
	<%=htmlwrite("html4")%>
<%
response.end
end if
end if

if not ef then
'UPDATE

dsdom("starttime")=starttime
dsdom("endtime")=temptime
dsdom("agent1")=ds("agent1")
dsdom("Domaintype")=""
dsdom("status")="正常"
'dsdom("inipass")="abc123"
if Application("DNS_API")=1 then
dsdom("DNS_API")=Application("DNS_API")
end if
dsdom.update
'action

dim Subject,body
emaildomainopen
ret=Send2Mail(conn,ds("username"),Subject,body)

If Application("smsdomainopen")=True And (ds("agent1")="n" Or Application("agncangetsms")=True) Then
Dim username
username=ds("username")
mobi=Trim(ds("mobi"))
smsContent=Application("smsdomainopencon")
'恭喜！您的域名已开通了！用户名：#用户名#域名：#域名#到期时间是：#到期时间#您的帐户余款是：#金额# 元
smsContent=Replace(smsContent,"#用户名#",ds("username"))
smsContent=Replace(smsContent,"#域名#",dsdom("domain"))
smsContent=Replace(smsContent,"#到期时间#",formatdatetime(dsdom("endtime"),1))
smsContent=Replace(smsContent,"#金额#",newuser_money)
ret=SendSms(mobi,smsContent,0,Now,"")
End if

end if



if not ef then
%>
<table width="65%"  border="0" align="center" cellpadding="0" cellspacing="0" bordercolor="#FF0000">
  <tr align="center" bordercolor="#000000" bgcolor="#999999">
    <td height="39" colspan="4"><font color="#000000">　　　</font><font color="#990000"><font color="#FF0000">您的域名会在</font></font> <font color="#FF0000"><strong>1分钟</strong></font> <font color="#990000"><font color="#FF0000">内自动开通，以下是您的资料<%if havehostget then%><font color=blue><%=havehostgetcon%></font><%end if%>：</font></font></td>
  </tr>
  <tr bordercolor="#000000" bgcolor="#EEEEEE">
    <td width="44%" height="30"><font color="#000000"> 　　　 您的原金额：</font></td>
    <td width="56%" colspan="3"><font color="#000000"><%=olduser_money%>元</font></td>
  </tr>
  <tr bordercolor="#000000" bgcolor="#EEEEEE">
    <td height="41"><font color="#000000">　　　 您的金额变化：</font></td>
    <td colspan="3"><font color=#000000><%=moneych%> 元</font></td>
  </tr>
  <tr bordercolor="#000000" bgcolor="#EEEEEE">
    <td height="39"><font color="#000000">　　　 您的新金额：</font></td>
    <td colspan="3"><font color="#000000"><%=newuser_money%> 元</font></td>
  </tr>
  <tr bordercolor="#000000">
    <td height="37" bgcolor="#eeeeee"><font color="#000000">　　　 您的域名是：</font></td>
    <td colspan="3" bgcolor="#eeeeee"><%=dsdom("Domain")%></td>
  </tr>
  <tr bordercolor="#000000">
    <td height="37" bgcolor="#eeeeee"><font color="#000000"> 　　　 到期时间是：</font></td>
    <td colspan="3" bgcolor="#eeeeee"><%=temptime%></td>
  </tr>
  <tr align="center" bordercolor="#000000" bgcolor="#eeeeee">
    <td height="39" colspan="4"><font color="#000000"> 新注册的域名会在24小时后生效</font></td>
  </tr>

<%If Right(dsdom("Domain"),"7")=".gov.cn" then%>
  <tr align="center" bordercolor="#000000" bgcolor="#E4EAF2">
    <td height="39" colspan="4"><font color="#000000"> 注意：<br>
您注册的是.gov.cn类域名，请您联系管理员提交审核材料才能注册成功。
</td>
  </tr>
<%End if%>

</table>
<br><br><br>
<%=htmlwrite("html4")%>
<%end if
if ef then
Response.Redirect "e.asp?e="&ec
end if%>
