<%@ Language=VBScript %>
<!--#include virtual="/inc-freehost-function/FreeHostFunction.asp"-->
<!--#include virtual="/inc-freehost-function/FreeHostFunctionMain.asp"-->
<%
Function CLen(HzStr)
L = len(HzStr)
For n=1 to L
If Asc(mid( HzStr,n,1))<0 Then HzNum = HzNum + 1
Next
Clen = L + HzNum
End Function
for each item in Request.Form
if instr(Request.Form(item),"'")>0 then response.Redirect "e.asp?e=出错，请不要输入'字符："&Request.Form(item) 
if instr(Request.Form(item),"&")>0 then response.Redirect "e.asp?e=出错，请不要输入&字符："&Request.Form(item) 
if CLen(Request.Form(item))>50 then response.Redirect "e.asp?e=出错，请不要输入超出50个字母或25个汉字："&Request.Form(item)&" 字数为："&CLen(Request.Form(item))
next

Function Chk_Num(number)
Chk_Num = True
ChkStr = "0123456789"
For cnt = 1 To Len(number)
Str1Chara = Mid(number, cnt, 1)
If InStr(ChkStr, Str1Chara) = 0 Then
Chk_Num = False
Exit For
End If
Next
End Function

	Function CheckStrinAsc(str)
		CheckStrinAsc = True
		If Len(str)=0 Or str = Null Then CheckStrinAsc = False:Exit Function
		For i = 1 To Len(str)
			If asc(mid(str,i,1)) < 0 Then	CheckStrinAsc = False:Exit Function
		Next
		If Len(str)<3 Then	CheckStrinAsc = False:Exit Function
		if CLen(str)>50 Then CheckStrinAsc = False:Exit Function
	End Function

Dim enc
Enddomaintypeid=GetDomaintype(request.form("dn"))

If session("username")="" And session("agentusername")="" And (session("admau")="" and session("DomainNameModid")="") then
	ef=True
	ec="授权非法，有可能是超时造成的。"
elseIf Enddomaintypeid=0 Then
	ef=True
	ec="无效的域名类型！"
elseif Application("onlyone")=true and Request.Form ("period")>1 and not (Enddomaintypeid=9 or Enddomaintypeid=4 or Enddomaintypeid=5) then
	ef=True
	ec="管理员限制了首次注册只能注册一年！"
elseIf not IsNumeric(Request.Form ("period")) Then
	ef=True
	ec="年必须是数字！"
ElseIf Instr(1, Request.Form ("dn"), "'", 1)>0 then
	ef=True
	ec="域名有非法字符！"
ElseIf Enddomaintypeid=2 And Instr(1, Request.Form ("dn"), "64", 1)>0 then
	ef=True
	ec="域名有非法字符64！"
ElseIf Enddomaintypeid=2 And Instr(1, Request.Form ("dn"), "89", 1)>0 then
	ef=True
	ec="域名有非法字符！"
ElseIf Enddomaintypeid=2 And Len(Request.Form ("dn"))<6 then
	ef=True
	ec="域名太短不允许注册！"
ElseIf Request.Form ("uname1")="" then
	ef=True
	ec="单位名称(中文)不能为空"
'ElseIf Enddomaintypeid=2 and CLen(Request.Form ("uname1"))<9 then
'	ef=True
'	ec="CN域名：单位名称必须是四个汉字以上才能注册(不能用个人姓名)"
ElseIf Not CheckStrinAsc(Replace(Replace(Request.Form ("uname2"),".",""),",","")) then
	ef=True
	ec="单位名称(英文)不能为空，输入的内容必须是半角，长度在3-50个字符内。"
ElseIf not Instr(Trim(Request.Form ("uname2")), " ")>1 then
	ef=True
	ec="单位名称(英文)，必须有空格！"
ElseIf Instr(Trim(Request.Form ("uname2")), "  ")>1 then
	ef=True
	ec="单位名称(英文)，空格只能有一个,不能输入两个空格！"
'ElseIf Instr(Trim(Request.Form ("uname2")), ".")>1 then
'	ef=True
'	ec="单位名称(英文)，不能有.号！"	
'ElseIf Not CheckStrinAsc(Request.Form ("uname3")) then
'	ef=True
'	ec="单位名称(拼音)不能为空，输入的内容必须是半角，长度在3-50个字符内。"
'ElseIf Request.Form ("uname4")="" and CLen(Request.Form ("uname4"))>10 and Not CheckStrinAsc(Request.Form ("uname4")) then
'	ef=True
'	ec="单位名称：(缩写)不能为空，输入的内容必须是半角，而且不能超过10个字符"
ElseIf Request.Form ("rname1")="" then
	ef=True
	ec="单位负责人：（中文）不能为空"
ElseIf Not CheckStrinAsc(Request.Form ("rname2")) then
	ef=True
	ec="单位负责人：（英文）不能为空，输入的内容必须是半角，长度在3-50个字符内。"
ElseIf not Instr(Trim(Request.Form ("rname2")), " ")>1 then
	ef=True
	ec="单位负责人(英文)，必须有空格！"
ElseIf Instr(Trim(Request.Form ("rname2")), "  ")>1 then
	ef=True
	ec="单位负责人(英文)，空格只能有一个,不能输入两个空格！"
ElseIf Request.Form ("uprov")="" then
	ef=True
	ec="省份：不能为空"
ElseIf Request.Form ("ucity1")="" then
	ef=True
	ec="城市：（中文）不能为空"
ElseIf Not CheckStrinAsc(Request.Form ("ucity2")) then
	ef=True
	ec="城市：（英文）不能为空，输入的内容必须是半角，长度在3-50个字符内。"
ElseIf Request.Form ("uaddr1")="" then
	ef=True
	ec="街道地址：（中文）不能为空"
ElseIf Len(Request.Form ("uaddr1"))<6 then
	ef=True
	ec="街道地址：（中文）必须在6个字以上的长度"
ElseIf Not CheckStrinAsc(Request.Form ("uaddr2")) then
	ef=True
	ec="街道地址：（英文）不能为空，输入的内容必须是半角，长度在3-50个字符内。"
ElseIf Len(Request.Form ("uaddr2"))<6 then
	ef=True
	ec="街道地址：（英文）必须在6个字以上的长度"
'ElseIf Request.Form ("location")="" then
'	ef=True
'	ec="单位所在地点(中文)不能为空"
ElseIf Request.Form ("uzip")="" then
	ef=True
	ec="邮政编码：不能为空"
elseIf not Chk_Num(Request.Form ("uzip")) Then
	ef=True
	ec="邮政编码必须是半角数字！"
ElseIf Request.Form ("uemail")="" then
	ef=True
	ec="电子邮件：不能为空"
'ElseIf Request.Form ("aname1")="" then
'	ef=True
'	ec="姓名：（中文）不能为空"
'ElseIf Not CheckStrinAsc(Request.Form ("aname2")) then
'	ef=True
'	ec="姓名：（英文）不能为空，输入的内容必须是半角，长度在3-50个字符内。"
'ElseIf not Instr(Trim(Request.Form ("aname2")), " ")>1 then
'	ef=True
'	ec="姓名：（英文）中必须有空格！"
ElseIf Trim(Request.Form ("utela"))="" then
	ef=True
	ec="注册人电话区号不能为空"
elseIf not Chk_Num(Request.Form ("utela")) Then
	ef=True
	ec="注册人电话区号必须是半角数字！"
elseIf len(Request.Form ("utela"))>4 Then
	ef=True
	ec="注册人电话区号不能超过4位！"
elseIf len(Request.Form ("utela"))<2 Then
	ef=True
	ec="注册人电话区号不能小于2位！	"
ElseIf Trim(Request.Form ("ufaxa"))="" then
	ef=True
	ec="注册人传真区号不能为空"
elseIf not Chk_Num(Request.Form ("ufaxa")) Then
	ef=True
	ec="注册人传真区号必须是半角数字！"
elseIf len(Request.Form ("ufaxa"))>4 Then
	ef=True
	ec="注册人传真区号不能超过4位！"
elseIf len(Request.Form ("ufaxa"))<2 Then
	ef=True
	ec="注册人传真区号不能小于2位！"
'ElseIf Trim(Request.Form ("atela"))="" then
'	ef=True
'	ec="管理人电话区号不能为空"
'elseIf not Chk_Num(Request.Form ("atela")) Then
'	ef=True
'	ec="管理人电话区号必须是半角数字！"
'elseIf len(Request.Form ("atela"))>4 Then
'	ef=True
'	ec="管理人电话区号不能超过4位！"
'ElseIf Trim(Request.Form ("afaxa"))="" then
'	ef=True
'	ec="管理人传真区号不能为空"
'elseIf not Chk_Num(Request.Form ("afaxa")) Then
'	ef=True
'	ec="管理人传真区号必须是半角数字！"
'elseIf len(Request.Form ("afaxa"))>4 Then
'	ef=True
'	ec="管理人传真区号不能超过4位！"

ElseIf Trim(Request.Form ("uteln"))="" then
	ef=True
	ec="注册人电话号码不能为空"
elseIf not Chk_Num(Request.Form ("uteln")) Then
	ef=True
	ec="注册人电话号码必须是半角数字！"
elseIf len(Request.Form ("uteln"))>8 Then
	ef=True
	ec="注册人电话号码不能超过8位,请用固定号码！"
elseIf len(Request.Form ("uteln"))<7 Then
	ef=True
	ec="注册人电话号码不能小于7位,请用固定号码！"
elseIf clng(Request.Form ("uteln"))=88888888 Or clng(Request.Form ("uteln"))=8888888 Or clng(Request.Form ("uteln"))=0 Or clng(Request.Form ("uteln"))=12345678 Or clng(Request.Form ("uteln"))=1234567 Then
	ef=True
	ec="注册人电话号码不能为8888888/0000000/12345678/1234567/8888888/000000,请用固定号码！"
ElseIf Trim(Request.Form ("ufaxn"))="" then
	ef=True
	ec="注册人传真号码不能为空"
elseIf not Chk_Num(Request.Form ("ufaxn")) Then
	ef=True
	ec="注册人传真号码必须是半角数字！"
elseIf len(Request.Form ("ufaxn"))>8 Then
	ef=True
	ec="注册人传真号码不能超过8位,请用固定号码！"
elseIf len(Request.Form ("ufaxn"))<7 Then
	ef=True
	ec="注册人传真号码不能小于7位,请用固定号码！"
elseIf clng(Request.Form ("ufaxn"))=88888888 Or clng(Request.Form ("ufaxn"))=8888888 Or clng(Request.Form ("ufaxn"))=0 Or clng(Request.Form ("ufaxn"))=12345678 Or clng(Request.Form ("ufaxn"))=1234567 Then
	ef=True
	ec="注册人传真号码不能为8888888/0000000/12345678/1234567/8888888/000000,请用固定号码！"
'ElseIf Request.Form ("ateln")="" then
'	ef=True
'	ec="管理人电话号码不能为空"
'elseIf not Chk_Num(Request.Form ("ateln")) Then
'	ef=True
'	ec="管理人电话号码必须是半角数字！"
'elseIf len(Request.Form ("ateln"))>8 Then
'	ef=True
'	ec="管理人电话号码不能超过8位,请用固定号码！"
'elseIf len(Request.Form ("ateln"))<7 Then
'	ef=True
'	ec="管理人电话号码不能小于7位,请用固定号码！"
'ElseIf Request.Form ("afaxn")="" then
'	ef=True
'	ec="管理人传真号码不能为空"
'elseIf not Chk_Num(Request.Form ("afaxn")) Then
'	ef=True
'	ec="管理人传真号码必须是半角数字！"
'elseIf len(Request.Form ("afaxn"))>8 Then
'	ef=True
'	ec="管理人传真号码不能超过8位,请用固定号码！"
'elseIf len(Request.Form ("afaxn"))<7 Then
'	ef=True
'	ec="管理人传真号码不能小于7位,请用固定号码！"
ElseIf RegExpTest("^[\w-]+(\.[\w-]+)*@[\w-]+(\.[\w-]+)+$",Request("uemail"))=False then
	ef=True
	ec="注册人信息的内容：Email无效"
'ElseIf RegExpTest("^[\w-]+(\.[\w-]+)*@[\w-]+(\.[\w-]+)+$",Request("aemail"))=False then
'	ef=True
'	ec="管理人信息的内容：Email无效"
end if

if not ef then
 
hostname=Request.form("dn")
hostname=ComX.idntoac_7i24_com(cstr(hostname))
hostname=replace(hostname,".","")
hostname=replace(hostname,"xn--","")
If RegExpTest("[^A-Za-z0-9--]",hostname) Then
	ef=True
	ec="请输入合法的域名！"
end if
end if

if not ef then
Set conn=Server.CreateObject("ADODB.Connection")
	conn.Open Application("FreeHostDBlink")

if session("DomainNameModid")=""  Then '不是修改
Domain_API=0
	Set RsDlist = Server.CreateObject("ADODB.Recordset")	
		Sql="Select * from FreeHost.FreeHost_DomainProductlist where id="&Enddomaintypeid
		RsDlist.Open Sql,conn,1,1
if not RsDlist.eof Then
Domain_API=RsDlist("regapi")
Else
response.write "没有这个类型"
response.end
end If
If Application("usercanselectapi")=true Then
If Application("api1")=True And request.form("usercanselectapi")=1 Then Domain_API=request.form("usercanselectapi")
If Application("api2")=True And request.form("usercanselectapi")=2 Then Domain_API=request.form("usercanselectapi")
If Application("api3")=True And request.form("usercanselectapi")=3 Then Domain_API=request.form("usercanselectapi")
If Application("api4")=True And request.form("usercanselectapi")=4 Then Domain_API=request.form("usercanselectapi")
If Application("api5")=True And request.form("usercanselectapi")=5 Then Domain_API=request.form("usercanselectapi")
If Application("api6")=True And request.form("usercanselectapi")=6 Then Domain_API=request.form("usercanselectapi")
If Application("api7")=True And request.form("usercanselectapi")=7 Then Domain_API=request.form("usercanselectapi")
End if'有这个类型
End if'不是修改



Set dsdom = Server.CreateObject("ADODB.Recordset")
sql="Select * from FreeHost.FreeHost_Product_Domain"
if session("DomainNameModid")<>"" then sql="Select * from FreeHost.FreeHost_Product_Domain where id='"&session("DomainNameModid")&"'"
	dsdom.Open sql,conn,1,3
if session("DomainNameModid")="" 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")=lcase(trim(request.form("dn")))
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_",".中国")

if session("DomainNameModid")="" And Domain_API<>0 Then dsdom("Domain_API")=Domain_API


dsdom("ServerlistID")=1
dsdom("Domaintype")=""
dsdom("status")="预注册成功"
dsdom("starttime")=NOW
end if

dsdom("years")=request.form("period")
'dsdom("postcon")=fcon
if Application("DNS_API")=1 then dsdom("DNS_API")=1


dsdom("uname1")=Trim(request.form("uname1"))
dsdom("uname2")=Trim(request.form("uname2"))
'dsdom("uname3")=request.form("uname3")
'dsdom("uname4")=request.form("uname4")
dsdom("rname1")=Trim(request.form("rname1"))
dsdom("rname2")=Trim(request.form("rname2"))
dsdom("ust")=Trim(request.form("ust"))
dsdom("uprov")=Trim(request.form("uprov"))
dsdom("ucity1")=Trim(request.form("ucity1"))
dsdom("ucity2")=Trim(request.form("ucity2"))
dsdom("uaddr1")=Trim(request.form("uaddr1"))
dsdom("uaddr2")=Trim(request.form("uaddr2"))
'dsdom("location")=request.form("location")
dsdom("uzip")=Trim(request.form("uzip"))
dsdom("utelc")=Trim(request.form("utelc"))
dsdom("utela")=Trim(request.form("utela"))
dsdom("uteln")=Trim(request.form("uteln"))
'dsdom("utele")=request.form("utele")
dsdom("ufaxc")=Trim(request.form("ufaxc"))
dsdom("ufaxa")=Trim(request.form("ufaxa"))
dsdom("ufaxn")=Trim(request.form("ufaxn"))
'dsdom("ufaxe")=request.form("ufaxe")
dsdom("uemail")=Trim(request.form("uemail"))
'dsdom("aname1")=request.form("aname1")
'dsdom("aname2")=request.form("aname2")
'dsdom("atelc")=request.form("atelc")
'dsdom("atela")=request.form("atela")
'dsdom("ateln")=request.form("ateln")
'dsdom("atele")=request.form("atele")
'dsdom("afaxc")=request.form("afaxc")
'dsdom("afaxa")=request.form("afaxa")
'dsdom("afaxn")=request.form("afaxn")
'dsdom("afaxe")=request.form("afaxe")
'dsdom("aemail")=Trim(request.form("aemail"))
if request.form("istemplate")="y" then
dsdom("istemplate")="y"
else
dsdom("istemplate")="n"
end if

if request.form("dns1")<>"" Then
dsdom("dns1")=Trim(request.form("dns1"))
dsdom("dns2")=Trim(request.form("dns2"))
End If

If Application("api7select")=2 And request.form("country")<>"" Then
dsdom("country")=Trim(request.form("country"))
End If
'response.write dsdom("postcon")&"<br><br>"

'checksum=MD5("Register"+Application("Domain_Agent_username_2")+Application("Domain_Agent_password_2_API")+request.form("dn")+Trim(request.form("aemail"))+Trim(request.form("uname2")))
'response.write "dn="&server.URLEncode(dsdom("Domain"))&"&enc="&enc&"&period="&dsdom("years")&"&client="&Application("Domain_Agent_username_2")&"&uname1="&server.URLEncode(dsdom("uname1"))&"&uname2="&server.URLEncode(dsdom("uname2"))&"&uname3="&server.URLEncode(dsdom("uname2"))&"&uname4="&server.URLEncode(dsdom("uname2"))&"&rname1="&server.URLEncode(dsdom("rname1"))&"&rname2="&server.URLEncode(dsdom("rname2"))&"&ust=CN"&"&uprov="&server.URLEncode(dsdom("uprov"))&"&ucity1="&server.URLEncode(dsdom("ucity1"))&"&ucity2="&server.URLEncode(dsdom("ucity2"))&"&uaddr1="&server.URLEncode(dsdom("uaddr1"))&"&uaddr2="&server.URLEncode(dsdom("uaddr2"))&"&location="&server.URLEncode(dsdom("uaddr1"))&"&uzip="&server.URLEncode(dsdom("uzip"))&"&utelc="&server.URLEncode(dsdom("utelc"))&"&utela="&server.URLEncode(dsdom("utela"))&"&uteln="&server.URLEncode(dsdom("uteln"))&"&ufaxc="&server.URLEncode(dsdom("ufaxc"))&"&ufaxa="&server.URLEncode(dsdom("ufaxa"))&"&ufaxn="&server.URLEncode(dsdom("ufaxn"))&"&ufaxe="&server.URLEncode(dsdom("ufaxe"))&"&uemail="&server.URLEncode(dsdom("uemail"))&"&aname1="&server.URLEncode(dsdom("uname1"))&"&aname2="&server.URLEncode(dsdom("uname2"))&"&atelc="&server.URLEncode(dsdom("utelc"))&"&atela="&server.URLEncode(dsdom("utela"))&"&ateln="&server.URLEncode(dsdom("uteln"))&"&atele="&server.URLEncode(dsdom("utele"))&"&afaxc="&server.URLEncode(dsdom("ufaxc"))&"&afaxa="&server.URLEncode(dsdom("ufaxa"))&"&afaxn="&server.URLEncode(dsdom("ufaxn"))&"&afaxe="&server.URLEncode(dsdom("ufaxe"))&"&aemail="&server.URLEncode(dsdom("uemail"))&"&dns1="&server.URLEncode(dsdom("dns1"))&"&dns2="&server.URLEncode(dsdom("dns2"))&"&checksum="&checksum

'response.end

dsdom.update
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%>
