<%@ 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

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("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("status")<>"预注册成功" then
	ef=True
	ec="处于预注册状态的域名才能确认，请您联系管理员处理，注意所有注册失败的域名请不要重新注册。"
end if
end If

if not ef then
if dsdom("Domain_API")<>5 then
	ef=True
	ec="这是万网的接口。"
end if
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
yearstr=dsdom("years")
if yearstr="" then
	ef=True
	ec="未能找到注册的时间长度！"
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
	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=5
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
end if


if not ef then
dsdom("status")="失败"
dsdom.update
Application.lock
Application("domainoptime")=now
Application("domainoplock")=true
Application.unlock


on error resume next

			strdns1=dsdom("dns1")
			strdns2=dsdom("dns2")
			userid			=Application("Domain_Agent_username_5")			'万网数字ID
			password		=Application("Domain_Agent_password_5")		'万网数字ID密码
			email			=Application("Domain_Agent_username_5_emamil")	'万网注册email
			vtime			= FormatDate(now())
			userstr			=md5(userid&password&email&vtime)



			category		="domain"
			Select Case Enddomaintypeid
			Case 1 :tep_DomainTypes_net_cn="com"
			Case 30 :tep_DomainTypes_net_cn="com"
			Case 2 :tep_DomainTypes_net_cn="cn"
			Case 3 :tep_DomainTypes_net_cn="cnch"
			Case 4 :tep_DomainTypes_net_cn="biz"
			Case 5 :tep_DomainTypes_net_cn="info"
'			Case 6 :tep_DomainTypes_net_cn=""'----万网不支持通用网址
			Case 7 :tep_DomainTypes_net_cn="comch"
			Case 8 :tep_DomainTypes_net_cn="cc"
			Case 9 :tep_DomainTypes_net_cn="mobi"
			Case 10 :tep_DomainTypes_net_cn="tv"
'			Case 11 :tep_DomainTypes_net_cn="hk"
'			Case 12 :tep_DomainTypes_net_cn="tw"
			Case 13 :tep_DomainTypes_net_cn="bizch"
'			Case 14 :tep_DomainTypes_net_cn="infoch"----万网不支持
			Case 15 :tep_DomainTypes_net_cn="ccch"
'			Case 16 :tep_DomainTypes_net_cn="mobich"----万网不支持
			Case 17 :tep_DomainTypes_net_cn="tvch"
'			Case 18 :tep_DomainTypes_net_cn="hkch"----万网不支持
'			Case 19 :tep_DomainTypes_net_cn="twch"----万网不支持
			Case 20 :tep_DomainTypes_net_cn="name"
			End Select
			productid		=trim(tep_DomainTypes_net_cn)	'万网域名类型临时变量
			action			=trim("activate")
			
			vsendStr		="userid="&userid&"&userstr="&userstr&"&vtime="&vtime
			
			vsendStr		=vsendStr&"&category="&category
			vsendStr		=vsendStr&"&productid="&productid
			vsendStr		=vsendStr&"&action="&action
			
			vsendStr		=vsendStr&"&domain="&server.URLEncode(dsdom("Domain"))
			vsendStr		=vsendStr&"&domainpwd="&vtime
			vsendStr		=vsendStr&"&vyear="&dsdom("years")
			vsendStr		=vsendStr&"&dns1="&strdns1
			vsendStr		=vsendStr&"&dns2="&strdns2
			vsendStr		=vsendStr&"&address_zh="&server.URLEncode(dsdom("strAddressCN"))
			vsendStr		=vsendStr&"&name="&server.URLEncode(dsdom("strNameCN"))
			vsendStr		=vsendStr&"&organization_zh="&server.URLEncode(dsdom("strCompanyCN"))
			vsendStr		=vsendStr&"&manager="&server.URLEncode(dsdom("strManager"))
			vsendStr		=vsendStr&"&organization_type="&server.URLEncode(dsdom("strTrade"))
			vsendStr		=vsendStr&"&ccity="&server.URLEncode(dsdom("strCityCN"))
			vsendStr		=vsendStr&"&cstate="&server.URLEncode(dsdom("strProvince"))
			vsendStr		=vsendStr&"&address_en="&server.URLEncode(dsdom("strAddressEN"))
			vsendStr		=vsendStr&"&lastname="&server.URLEncode(LCase(Split(dsdom("strNameEN")," ")(1)))
			vsendStr		=vsendStr&"&firstname="&server.URLEncode(LCase(Split(dsdom("strNameEN")," ")(0)))
			vsendStr		=vsendStr&"&organization_en="&server.URLEncode(LCase(dsdom("strCompanyEN")))
			vsendStr		=vsendStr&"&city="&server.URLEncode(LCase(dsdom("strCityEN")))
			vsendStr		=vsendStr&"&state="&server.URLEncode(dsdom("strProvince"))
			vsendStr		=vsendStr&"&postcode="&server.URLEncode(dsdom("strPostcode"))
			vsendStr		=vsendStr&"&country=CN"
			vsendStr		=vsendStr&"&phone=86-0"&dsdom("intPhoneAreaCode")&dsdom("intPhoneNumber")
			vsendStr		=vsendStr&"&fax=86-"&"0"&dsdom("intFaxAreaCode")&dsdom("intFaxNumber")
			vsendStr		=vsendStr&"&email="&server.URLEncode(dsdom("strEmail"))
			vsendStr		=vsendStr&"&admin_same_as=2"
			vsendStr		=vsendStr&"&tech_same_as=2"
			vsendStr		=vsendStr&"&bill_same_as=2"
			'vsendStr=LIT_URLEncoding(vsendStr)

				'		Response.Write vsendStr
				'		Response.End

			retdns=LIT_RetrunStr("http://api.hichina.com/wwwnetcn.aspx",vsendStr)

If retdns="" then
	ef=True
	ec="操作失败，但款项已扣。您的定单已经更改为手工受理,我们将为您手工处理，请稍侯进入域名管理刷新或联系管理员。注意不要重复尝试！可能的原因是原始注册商的网络不正常"
	retdns=ec
	FreeHost_oplog session("username"),"失败","款项已扣，域名注册时由于原始注册商的网络不正常等原因操作失败:"&dsdom("Domain")
end if

'			Response.Write retdns
'			Response.Write(retdns):Response.End()
dim returncodevalue,failreason
xmlvalue(retdns)
			If Instr(retdns,"200")<=0 Then
				retdns= "返回状态码:"&returncodevalue&" 原因:"&failreason&" 注意！相关的款项已被扣除，您的定单已经更改为手工受理,我们将为您手工处理，请稍侯进入域名管理刷新或联系管理员。注意不要重复尝试！"
				ef=True
				ec=retdns
				FreeHost_oplog session("username"),"失败","域名注册:"&dsdom("Domain")&"<br>"&retdns
			Else
				FreeHost_oplog session("username"),"信息","注册时返回："&retdns&":"&dsdom("Domain")
			End If		
		

dsdom("retdns")=retdns
dsdom.update

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

if not ef then
'赠送的邮箱
'开通邮箱
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("agentusername"),"信息","代理帮用户开通域名"&dsdom("Domain")&"赠送邮箱产品ID:"&dsphemail("id")
retemail="赠送的邮箱产品已开通"
end if
'结束赠送


end if


if not ef then
'UPDATE
dsdom("inipass")=vtime
dsdom("starttime")=starttime
dsdom("endtime")=temptime
dsdom("agent1")=ds("agent1")
dsdom("Domaintype")=""
dsdom("status")="正常"
dsdom.update

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
%>
<!--#include virtual="/inc-freehost-function/htmlwrite.asp"--><%=htmlwrite("html2")%>　马上支付
<%=htmlwrite("html3")%>
<br><br>
<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">恭喜您的域名开通成功，以下是您的资料<%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"><%=dsdom("inipass")%></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小时后生效，<br></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%>
