<%@ Language=VBScript %>
<!--#include virtual="/inc-freehost-function/FreeHostFunction.asp"-->
<!--#include virtual="/inc-freehost-function/FreeHostFunctionMain.asp"-->
<%
 
id=session("DNSAUID")
URLREIP=Application("URLRE_IP")
NodeName=trim(LCASE(Request.Form ("NodeName")))
if NodeName="" then NodeName="@"
If RegExpTest("[^.A-Za-z0-9--@]",NodeName) Then
	ef=True
	ec="输入的域名信息中不能有特殊字符！"
End if
If session("DNSAUID")="" Then
	ef=True
	ec="授权非法，请您先登陆。"
ElseIf not IsNumeric(id)  Then
	ef=True
	ec="ID应该是数字！"
ElseIf Request.Form ("URL")="" then
	ef=True
	ec="不能输入空内容！"
end if


if not ef then
Set conn=Server.CreateObject("ADODB.Connection")
	conn.Open Application("FreeHostDBlink")
	Set dsdm = 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
	dsdm.Open Sql,conn,1,1
if dsdm.Eof 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='"&dsdm("username")&"'"
		if Instr(1,sql, ";", 1)>0 or Instr(1,sql, "--", 1)>0 then
Response.Write "非法字符！"
Response.End
end if
		ds.Open Sql,conn,1,3
if ds.eof then
	ef=True
	ec="用户不存在!"
end if
end if

if not ef then

OriDomain=dsdm("domain")
OriDomain=replace(OriDomain,".中国",".cn")
OriDomain=replace(OriDomain,".公司",".com.cn")
OriDomain=replace(OriDomain,".网络",".net.cn")
newdomain=ComX.idntoac_7i24_com(Cstr(OriDomain))


urlhostname=NodeName&"."&newdomain
urlhostname=replace(urlhostname,"@.","")
Set dsURLRE = Server.CreateObject("ADODB.Recordset")	
		Sql="Select * from FreeHost.FreeHost_Product_URLRE where PdDID='"&id&"' and hostname='"&urlhostname&"'"
			if Instr(1,sql, ";", 1)>0 or Instr(1,replace(sql,"xn-",""), "--", 1)>0 then
outcon="非法字符！"
response.write "非法字符！"
Response.End
end if
	dsURLRE.Open Sql,conn,1,3
if not dsURLRE.Eof then
	ef=True
	ec="这个主机已存在了！"
end if
end if

'response.write "ok"
'response.end


if not ef then
 	Set dsALLDNS = Server.CreateObject("ADODB.Recordset")	
		Sql="Select * from FreeHost.FreeHost_Product_ALLDNS where PdDID='"&id&"' and RRType='CNAME'"
			if Instr(1,sql, ";", 1)>0 or Instr(1,sql, "--", 1)>0 then
outcon="非法字符！"
Response.End
end if
dsALLDNS.Open Sql,conn,1,3	
count=dsALLDNS.recordcount
if count>dsdm("DNScount")-1 then
	ef=True
	ec="超出最大允许的数量了！"
end if
dsALLDNS.close
end if


if not ef then
if Application("openmustre")=true Then
status=""
chXDomain=Replace(NodeName&"."&newdomain,"@.","")
if CheckDomainDB(chXDomain)=false then
	ef=True
	ec="此域名 "&chXDomain&" 没有通过备案，当前状态："&status&"，请到 http://www.miitbeian.gov.cn 查询是否成功备案。"
	If Application("beianupsaok")=True Then	ec="此域名 "&chXDomain&" 尚未在工信部提交备案信息，当前状态："&status&"，请到先到 http://www.miitbeian.gov.cn 提交备案信息。"
end if
end if
end if

if not ef then
dsURLRE.addnew
dsURLRE("username")=dsdm("username")
dsURLRE("PdDID")=dsdm("id")
dsURLRE("hostname")=urlhostname
dsURLRE("homename")=dsURLRE("hostname")
dsURLRE("url")="http://"&replace(lcase(trim(Request.Form ("url"))),"http://","")
dsURLRE("havecheck")="y"
if Application("urlcheck")=true then dsURLRE("havecheck")="n"
dsURLRE("re")=Request.Form ("re")
dsURLRE("status")="正常"
dsURLRE("NodeName")=NodeName
dsURLRE("agent1")=ds("agent1")
dsURLRE("addtime")=now
dsURLRE.update

Set dnsserver = Server.CreateObject("ADODB.Recordset")	
	Sql="Select * from FreeHost.FreeHost_ServerDNSlist"
	dnsserver.Open Sql,conn,1,1
while not dnsserver.eof
outcon=DNSOP(dnsserver("site"),"/RecordDelete "&newdomain&" "&dsURLRE("NodeName")&" CNAME",dnsserver("FreeHostsharekey"))
outcon=DNSOP(dnsserver("site"),"/RecordDelete "&newdomain&" "&dsURLRE("NodeName")&" A",dnsserver("FreeHostsharekey"))
dnsserver.movenext
wend
dnsserver.close

 	Set dsALLDNS = Server.CreateObject("ADODB.Recordset")	
		Sql="Select * from FreeHost.FreeHost_Product_ALLDNS where PdDID='"&id&"' and NodeName='"&NodeName&"' and (RRType='CNAME' or RRType='A')"
'		response.write sql
'				response.end
			if Instr(1,sql, ";", 1)>0 or Instr(1,sql, "--", 1)>0 then
outcon="非法字符！"
Response.End
end if
	dsALLDNS.Open Sql,conn,1,3	
while not dsALLDNS.eof
dsALLDNS.delete
dsALLDNS.movenext
wend
dsALLDNS.close

 	Set dsALLDNS = Server.CreateObject("ADODB.Recordset")	
		Sql="Select * from FreeHost.FreeHost_Product_ALLDNS where PdDID='"&id&"'"
			if Instr(1,sql, ";", 1)>0 or Instr(1,sql, "--", 1)>0 then
outcon="非法字符！"
Response.End
end if
	dsALLDNS.Open Sql,conn,1,3	
count=dsALLDNS.recordcount
dsALLDNS.addnew
dsALLDNS("username")=dsdm("username")
dsALLDNS("PdDID")=dsdm("id")
dsALLDNS("RRType")="CNAME"
dsALLDNS("RRData")=URLREIP
dsALLDNS("NodeName")=NodeName
dsALLDNS("TTL")=3600
dsALLDNS("mxper")=10
dsALLDNS.update
dsALLDNS.close

'新加zone
if count=0 then
Set dnsserver = Server.CreateObject("ADODB.Recordset")	
	Sql="Select * from FreeHost.FreeHost_ServerDNSlist"
	dnsserver.Open Sql,conn,1,1
while not dnsserver.eof
outcon=DNSOP(dnsserver("site"),"/zoneadd "&newdomain&" /Primary",dnsserver("FreeHostsharekey"))
dnsserver.movenext
wend
dnsserver.close
end if


Set dnsserver = Server.CreateObject("ADODB.Recordset")	
	Sql="Select * from FreeHost.FreeHost_ServerDNSlist"
	dnsserver.Open Sql,conn,1,1
while not dnsserver.eof
outcon=DNSOP(dnsserver("site"),"/RecordAdd "&newdomain&" "&NodeName&" CNAME "&URLREIP,dnsserver("FreeHostsharekey"))
dnsserver.movenext
wend
dnsserver.close


%>
<HTML><HEAD><TITLE>Mydns</TITLE>
<META content="text/html; charset=gb2312" http-equiv=Content-Type>
<style type="text/css">
<!--
BODY {
	FONT-FAMILY: Verdana, Arial, Helvetica, sans-serif; FONT-SIZE: 12px
}
TABLE {
	FONT-FAMILY: Verdana, Arial, Helvetica, sans-serif; FONT-SIZE: 12px
}
TR {
	FONT-FAMILY: Verdana, Arial, Helvetica, sans-serif; FONT-SIZE: 12px
}
TD {
	FONT-FAMILY: Verdana, Arial, Helvetica, sans-serif; FONT-SIZE: 12px
}
P {
	FONT-FAMILY: Verdana, Arial, Helvetica, sans-serif; FONT-SIZE: 12px
}
INPUT {
	COLOR: #000000; FONT-FAMILY: Verdana, Arial, Helvetica, sans-serif; FONT-SIZE: 12px
}
SELECT {
	COLOR: #000000; FONT-FAMILY: Verdana, Arial, Helvetica, sans-serif; FONT-SIZE: 12px
}
TEXTAREA {
	COLOR: #000000; FONT-FAMILY: Verdana, Arial, Helvetica, sans-serif; FONT-SIZE: 12px
}
BODY {
	BACKGROUND: #ffffff; COLOR: #000000
}
.inputText {
	BACKGROUND: #ffffff; BORDER-BOTTOM: #c0c0c0 1px solid; BORDER-LEFT: #c0c0c0 1px solid; BORDER-RIGHT: #c0c0c0 1px solid; BORDER-TOP: #c0c0c0 1px solid
}
.inputRadio {
	BACKGROUND: #e8e8e8
}
.formHeader {
	BACKGROUND: #d0d0d0; COLOR: #000000; FONT-WEIGHT: bold
}
.formSubHeader {
	BACKGROUND: #e0e0e0; COLOR: #000000; FONT-WEIGHT: bold
}
.formItem {
	BACKGROUND: #e8e8e8; COLOR: #000000
}
.formText {
	BACKGROUND: #f0f0f0; COLOR: #000000
}
.formError {
	COLOR: #ff0000
}
.mainBorder {
	BACKGROUND: #666666
}
.mainHeader {
	BACKGROUND: #ffffff
}
.mainBody {
	BACKGROUND: #ffffff
}
.mainItem {
	BACKGROUND: #cccccc; FONT-WEIGHT: bold
}
.mainFooter {
	BACKGROUND: #ffffff
}
.mboxBorder {
	BORDER-BOTTOM: #d0d0d0 1px solid; BORDER-LEFT: #d0d0d0 1px solid; BORDER-RIGHT: #d0d0d0 1px solid; BORDER-TOP: #d0d0d0 1px solid
}
A {
	COLOR: #ff9900; TEXT-DECORATION: none
}
A:link {
	COLOR: #ff9900
}
A:visited {
	COLOR: #ff9900
}
A:active {
	COLOR: #ff9900; TEXT-DECORATION: underline
}
PRE {
	FONT-FAMILY: Lucida Console, Verdana, Arial, Helvetica, sans-serif; FONT-SIZE: 12px
}
-->
</style>
</head>
<BODY onload="" topmargin="0">
<TABLE border=0 align="center" cellPadding=0 cellSpacing=0 class=mainBorder>
  <TBODY>
  <TR>
     <TD>
        <table border="0" cellspacing="0" cellpadding="0" align="center" height="46">
                <tr>
                  <td height="46" width="84%" rowspan="2">&nbsp;</td>
                  <td height="30" width="16%">&nbsp;</td>
                </tr>
                <tr>
                  <td height="16" width="16%">&nbsp;</td>
                </tr>
       </table>
     </TD>
  </TR>
  <TR>
    <TD>
 <table align="center" bgcolor="#cccccc" border="0" cellpadding="3" cellspacing="1" class="content" width="700">
        <tbody> 
        <tr bgcolor="#e8e8e8"> 
          <td class="content" height="28"> 
            <div align="center"> <font color="#000000" size=12px><span style="letter-spacing: 2"><font size="2"><b> 
                  MYDNS </b></font></span></font></div>
          </td>
        </tr>
        <tr> 
              <td bgcolor="#ffffff" height="81" class="unnamed1"><font face="宋体" size="2"><span style="letter-spacing: 2">
              　　操作成功<span class="unnamed1"><br>
              <br>　　
              <a href="mydns.asp?id=<%=dsdm("id")%>">[返回]</a></span></span></font></td>
        </tr>
        <tr> 
              <td bgcolor="#ffffff" class="unnamed1"><span style="letter-spacing: 2"></span></td>
        </tr>
        </tbody> 
      </table>
  
            </TD>
</TR></TABLE></TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE>
</BODY></HTML>
<%
dsdm.close
end if
if ef then
Response.Redirect "e.asp?e="&ec
end if%>
